Pawn.CMD.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2016-2018 urShadow
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #if !defined PAWNCMD_INC_
  25. #define PAWNCMD_INC_
  26. #define PAWNCMD_INCLUDE_VERSION 320
  27. #if !defined __cplusplus
  28. public _pawncmd_version = PAWNCMD_INCLUDE_VERSION;
  29. #pragma unused _pawncmd_version
  30. public bool:_pawncmd_is_gamemode = !defined FILTERSCRIPT;
  31. #pragma unused _pawncmd_is_gamemode
  32. native PC_Init(); // internal
  33. native PC_RegAlias(const cmd[], const alias[], ...);
  34. native PC_SetFlags(const cmd[], flags);
  35. native PC_GetFlags(const cmd[]);
  36. native PC_EmulateCommand(playerid, const cmdtext[]);
  37. native PC_RenameCommand(const cmd[], const newname[]);
  38. native PC_CommandExists(const cmd[]);
  39. native PC_DeleteCommand(const cmd[]);
  40. native CmdArray:PC_GetCommandArray();
  41. native CmdArray:PC_GetAliasArray(const cmd[]);
  42. native PC_GetArraySize(CmdArray:arr);
  43. native PC_FreeArray(&CmdArray:arr);
  44. native PC_GetCommandName(CmdArray:arr, index, dest[], size = sizeof dest);
  45. #if defined PC_OnInit
  46. forward PC_OnInit();
  47. #endif
  48. #if defined OnPlayerCommandReceived
  49. forward OnPlayerCommandReceived(playerid, cmd[], params[], flags);
  50. #endif
  51. #if defined OnPlayerCommandPerformed
  52. forward OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags);
  53. #endif
  54. #define cmd:%0(%1) \
  55. forward pc_cmd_%0(%1); \
  56. public pc_cmd_%0(%1)
  57. #define alias:%0(%1); \
  58. forward pc_alias_%0(); \
  59. public pc_alias_%0() \
  60. PC_RegAlias(#%0, %1);
  61. #define flags:%0(%1); \
  62. forward pc_flags_%0(); \
  63. public pc_flags_%0() \
  64. PC_SetFlags(#%0, %1);
  65. #define CMD cmd
  66. #define COMMAND cmd
  67. #define callcmd::%0(%1) \
  68. pc_cmd_%0(%1)
  69. #define PC_HasFlag(%0,%1) \
  70. (PC_GetFlags(%0) & %1)
  71. #if !defined isnull
  72. #define isnull(%0) \
  73. ((!(%0[0])) || (((%0[0]) == '\1') && (!(%0[1]))))
  74. #endif
  75. #if defined FILTERSCRIPT
  76. public OnFilterScriptInit()
  77. {
  78. PC_Init();
  79. #if defined PawnCmd_OnFilterScriptInit
  80. PawnCmd_OnFilterScriptInit();
  81. #endif
  82. return 1;
  83. }
  84. #if defined _ALS_OnFilterScriptInit
  85. #undef OnFilterScriptInit
  86. #else
  87. #define _ALS_OnFilterScriptInit
  88. #endif
  89. #define OnFilterScriptInit PawnCmd_OnFilterScriptInit
  90. #if defined PawnCmd_OnFilterScriptInit
  91. forward PawnCmd_OnFilterScriptInit();
  92. #endif
  93. #else
  94. public OnGameModeInit()
  95. {
  96. PC_Init();
  97. #if defined PawnCmd_OnGameModeInit
  98. PawnCmd_OnGameModeInit();
  99. #endif
  100. return 1;
  101. }
  102. #if defined _ALS_OnGameModeInit
  103. #undef OnGameModeInit
  104. #else
  105. #define _ALS_OnGameModeInit
  106. #endif
  107. #define OnGameModeInit PawnCmd_OnGameModeInit
  108. #if defined PawnCmd_OnGameModeInit
  109. forward PawnCmd_OnGameModeInit();
  110. #endif
  111. #endif
  112. #endif // !__cplusplus
  113. #endif // !PAWNCMD_INC_