Pawn.CMD.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2016-2020 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_VERSION 333
  27. #define PAWNCMD_INCLUDE_VERSION PAWNCMD_VERSION // backward compatibility
  28. #if !defined __cplusplus
  29. public _pawncmd_version = PAWNCMD_VERSION;
  30. #pragma unused _pawncmd_version
  31. public bool:_pawncmd_is_gamemode = !defined FILTERSCRIPT;
  32. #pragma unused _pawncmd_is_gamemode
  33. native PC_Init(); // internal
  34. native PC_RegAlias(const cmd[], const alias[], ...);
  35. native PC_SetFlags(const cmd[], flags);
  36. native PC_GetFlags(const cmd[]);
  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_GetCommandName(CmdArray:arr, index, dest[], size = sizeof dest);
  44. native PC_FreeArray(&CmdArray:arr);
  45. native PC_EmulateCommand(playerid, const cmdtext[]);
  46. #if defined PC_OnInit
  47. forward PC_OnInit();
  48. #endif
  49. #if defined OnPlayerCommandReceived
  50. forward OnPlayerCommandReceived(playerid, cmd[], params[], flags);
  51. #endif
  52. #if defined OnPlayerCommandPerformed
  53. forward OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags);
  54. #endif
  55. #define cmd:%0(%1) \
  56. forward pc_cmd_%0(%1); \
  57. public pc_cmd_%0(%1)
  58. #define alias:%0(%1) \
  59. forward pc_alias_%0(); \
  60. public pc_alias_%0() \
  61. PC_RegAlias(#%0, %1);
  62. #define flags:%0(%1) \
  63. forward pc_flags_%0(); \
  64. public pc_flags_%0() \
  65. PC_SetFlags(#%0, %1);
  66. #define CMD cmd
  67. #define COMMAND cmd
  68. #define callcmd::%0(%1) \
  69. pc_cmd_%0(%1)
  70. #define PC_HasFlag(%0,%1) \
  71. (PC_GetFlags(%0) & %1)
  72. #if !defined isnull
  73. #define isnull(%0) \
  74. ((!(%0[0])) || (((%0[0]) == '\1') && (!(%0[1]))))
  75. #endif
  76. #if defined FILTERSCRIPT
  77. public OnFilterScriptInit()
  78. {
  79. PC_Init();
  80. #if defined PawnCmd_OnFilterScriptInit
  81. PawnCmd_OnFilterScriptInit();
  82. #endif
  83. return 1;
  84. }
  85. #if defined _ALS_OnFilterScriptInit
  86. #undef OnFilterScriptInit
  87. #else
  88. #define _ALS_OnFilterScriptInit
  89. #endif
  90. #define OnFilterScriptInit PawnCmd_OnFilterScriptInit
  91. #if defined PawnCmd_OnFilterScriptInit
  92. forward PawnCmd_OnFilterScriptInit();
  93. #endif
  94. #else
  95. public OnGameModeInit()
  96. {
  97. PC_Init();
  98. #if defined PawnCmd_OnGameModeInit
  99. PawnCmd_OnGameModeInit();
  100. #endif
  101. return 1;
  102. }
  103. #if defined _ALS_OnGameModeInit
  104. #undef OnGameModeInit
  105. #else
  106. #define _ALS_OnGameModeInit
  107. #endif
  108. #define OnGameModeInit PawnCmd_OnGameModeInit
  109. #if defined PawnCmd_OnGameModeInit
  110. forward PawnCmd_OnGameModeInit();
  111. #endif
  112. #endif
  113. #endif // !__cplusplus
  114. #endif // !PAWNCMD_INC_