1
0

y_groups.inc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*----------------------------------------------------------------------------*-
  2. =======================================
  3. y_groups - Player group abstractions!
  4. =======================================
  5. Description:
  6. Admin levels, gangs, teams etc - they're all "groups" of people, this
  7. provides an abstraction for all of these collections.
  8. Legal:
  9. Version: MPL 1.1
  10. The contents of this file are subject to the Mozilla Public License Version
  11. 1.1 (the "License"); you may not use this file except in compliance with
  12. the License. You may obtain a copy of the License at
  13. http://www.mozilla.org/MPL/
  14. Software distributed under the License is distributed on an "AS IS" basis,
  15. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  16. for the specific language governing rights and limitations under the
  17. License.
  18. The Original Code is the SA:MP script information include.
  19. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  20. Portions created by the Initial Developer are Copyright (C) 2008
  21. the Initial Developer. All Rights Reserved.
  22. Contributors:
  23. ZeeX, koolk
  24. Thanks:
  25. Peter, Cam - Support.
  26. ZeeX - Very productive conversations.
  27. koolk - IsPlayerinAreaEx code.
  28. TheAlpha - Danish translation.
  29. breadfish - German translation.
  30. Fireburn - Dutch translation.
  31. yom - French translation.
  32. 50p - Polish translation.
  33. Zamaroht - Spanish translation.
  34. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  35. for me to strive to better.
  36. Pixels^ - Running XScripters where the idea was born.
  37. Matite - Pestering me to release it and using it.
  38. Very special thanks to:
  39. Thiadmer - PAWN.
  40. Kye/Kalcor - SA:MP.
  41. SA:MP Team past, present and future - SA:MP.
  42. Version:
  43. 1.0
  44. Changelog:
  45. 29/11/10:
  46. First version
  47. -*----------------------------------------------------------------------------*/
  48. #include <YSI\internal\y_version>
  49. #undef _inc_y_groups
  50. #include <YSI\internal\y_nogroups>
  51. #if defined YSI_GROUPS_LAST
  52. #if YSI_GROUPS_LAST == 25
  53. #undef _GROUP_MAKE_NAME
  54. #undef _GROUP_MAKE_LIMIT
  55. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  56. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  57. #elseif YSI_GROUPS_LAST == 22
  58. #undef _GROUP_MAKE_NAME
  59. #undef _GROUP_MAKE_LIMIT
  60. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  61. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  62. #elseif YSI_GROUPS_LAST == 9
  63. #undef _GROUP_MAKE_NAME
  64. #undef _GROUP_MAKE_LIMIT
  65. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  66. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  67. #elseif YSI_GROUPS_LAST == 8
  68. #undef _GROUP_MAKE_NAME
  69. #undef _GROUP_MAKE_LIMIT
  70. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  71. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  72. #endif
  73. #undef YSI_GROUPS_LAST
  74. #endif
  75. #if defined _YSI_GROUPS_FIRST_HALF
  76. #undef _YSI_GROUPS_FIRST_HALF
  77. #endif
  78. // First, detect which library has included this. If none then it was the user.
  79. #if defined _inc_y_classes
  80. #if !defined _YSI_GROUP_CLASSES_INCLUDED
  81. // Although this is included before _GROUP_MAKE_NAME is set, it will
  82. // still be the correct value eventually.
  83. // Mark this library as existing.
  84. #define _YSI_GROUP_CLASSES_INCLUDED
  85. // These all need doing twice - once here and once below.
  86. #if defined _YSI_HAS_GROUP_SYSTEM
  87. #include <YSI\internal\y_groupfirst>
  88. #endif
  89. #undef _GROUP_MAKE_NAME
  90. #undef _GROUP_MAKE_LIMIT
  91. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  92. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  93. #if defined _YSI_HAS_GROUP_SYSTEM
  94. #include <YSI\internal\y_groupsecond>
  95. #include <YSI\internal\y_classgroups>
  96. #endif
  97. #include <YSI\internal\y_groupsingle>
  98. // End.
  99. #endinput
  100. #endif
  101. #endif
  102. #if defined _inc_y_commands
  103. #if !defined _YSI_GROUP_COMMANDS_INCLUDED
  104. // Although this is included before _GROUP_MAKE_NAME is set, it will
  105. // still be the correct value eventually.
  106. // Mark this library as existing.
  107. #define _YSI_GROUP_COMMANDS_INCLUDED
  108. // These all need doing twice - once here and once below.
  109. #if defined _YSI_HAS_GROUP_SYSTEM
  110. #include <YSI\internal\y_groupfirst>
  111. #endif
  112. #undef _GROUP_MAKE_NAME
  113. #undef _GROUP_MAKE_LIMIT
  114. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  115. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  116. #if defined _YSI_HAS_GROUP_SYSTEM
  117. #include <YSI\internal\y_groupsecond>
  118. #endif
  119. #include <YSI\internal\y_groupsingle>
  120. // End.
  121. #endinput
  122. #endif
  123. #endif
  124. #if defined _YSI_ALLOW_INTERNAL_TEST
  125. #if defined _inc_y_inttest
  126. #if !defined _YSI_GROUP_INTTEST_INCLUDED
  127. // Mark this library as existing.
  128. #define _YSI_GROUP_INTTEST_INCLUDED
  129. // These all need doing twice - once here and once below.
  130. #if defined _YSI_HAS_GROUP_SYSTEM
  131. #include <YSI\internal\y_groupfirst>
  132. #endif
  133. #undef _GROUP_MAKE_NAME
  134. #undef _GROUP_MAKE_LIMIT
  135. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  136. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  137. #if defined _YSI_HAS_GROUP_SYSTEM
  138. #include <YSI\internal\y_groupsecond>
  139. #endif
  140. #include <YSI\internal\y_groupsingle>
  141. // End.
  142. #endinput
  143. #endif
  144. #endif
  145. #if defined _inc_y_inttest2
  146. #if !defined _YSI_GROUP_INTTEST2_INCLUDED
  147. // Mark this library as existing.
  148. #define _YSI_GROUP_INTTEST2_INCLUDED
  149. // These all need doing twice - once here and once below.
  150. #if defined _YSI_HAS_GROUP_SYSTEM
  151. #include <YSI\internal\y_groupfirst>
  152. #endif
  153. #undef _GROUP_MAKE_NAME
  154. #undef _GROUP_MAKE_LIMIT
  155. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  156. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  157. #if defined _YSI_HAS_GROUP_SYSTEM
  158. #include <YSI\internal\y_groupsecond>
  159. #endif
  160. //#include <YSI\internal\y_groupsingle>
  161. // End.
  162. #endinput
  163. #endif
  164. #endif
  165. #endif
  166. // || ||
  167. // =============================================================================
  168. // || ||
  169. #define _YSI_GROUPS_FIRST_HALF
  170. // || ||
  171. // =============================================================================
  172. // || ||
  173. // User inclusion.
  174. #if !defined _YSI_HAS_GROUP_SYSTEM
  175. #define _YSI_HAS_GROUP_SYSTEM
  176. // Include the main code.
  177. #include <a_samp>
  178. #include <YSI\internal\y_grouponce>
  179. // Include code for previous libraries.
  180. #if defined _YSI_GROUP_CLASSES_INCLUDED
  181. // This only needs to be done if the library was previously included.
  182. #define _YSIM_OVERRIDE 22
  183. #include <YSI\y_master>
  184. // Include the first half of the file for the call chain.
  185. #include <YSI\internal\y_groupfirst>
  186. #undef _GROUP_MAKE_NAME
  187. #undef _GROUP_MAKE_LIMIT
  188. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  189. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  190. // Include the second half of the file for the methods.
  191. #include <YSI\internal\y_groupsecond>
  192. #include <YSI\internal\y_classgroups>
  193. #endif
  194. #if defined _YSI_GROUP_COMMANDS_INCLUDED
  195. // This only needs to be done if the library was previously included.
  196. #define _YSIM_OVERRIDE 25
  197. #include <YSI\y_master>
  198. // Include the first half of the file for the call chain.
  199. #include <YSI\internal\y_groupfirst>
  200. #undef _GROUP_MAKE_NAME
  201. #undef _GROUP_MAKE_LIMIT
  202. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  203. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  204. // Include the second half of the file for the methods.
  205. #include <YSI\internal\y_groupsecond>
  206. #endif
  207. // Internal test library.
  208. #if defined _YSI_ALLOW_INTERNAL_TEST
  209. #if defined _YSI_GROUP_INTTEST_INCLUDED
  210. #define _YSIM_OVERRIDE 9
  211. #include <YSI\y_master>
  212. #include <YSI\internal\y_groupfirst>
  213. #undef _GROUP_MAKE_NAME
  214. #undef _GROUP_MAKE_LIMIT
  215. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  216. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  217. #include <YSI\internal\y_groupsecond>
  218. #endif
  219. #if defined _YSI_GROUP_INTTEST2_INCLUDED
  220. #define _YSIM_OVERRIDE 8
  221. #include <YSI\y_master>
  222. #include <YSI\internal\y_groupfirst>
  223. #undef _GROUP_MAKE_NAME
  224. #undef _GROUP_MAKE_LIMIT
  225. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  226. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  227. #include <YSI\internal\y_groupsecond>
  228. #endif
  229. #endif
  230. #endif
  231. // Now include any user defined libraries.
  232. #if defined GROUP_LIBRARY_NAME
  233. #if defined GROUP_LIBRARY_SIZE
  234. // Include the generic group code for this new custom group.
  235. #if defined _YSIM_MANUAL_SET
  236. #define _YSIM_RESET_USER
  237. #endif
  238. #include <YSI\y_master>
  239. //#include <YSI\internal\y_groupsingle>
  240. #include <YSI\internal\y_groupfirst>
  241. #undef _GROUP_MAKE_NAME
  242. #undef _GROUP_MAKE_LIMIT
  243. #define _GROUP_MAKE_NAME GROUP_LIBRARY_NAME
  244. #define _GROUP_MAKE_LIMIT GROUP_LIBRARY_SIZE
  245. #undef _YSI_GROUPS_FIRST_HALF
  246. // Include the second half of the file for the methods.
  247. #include <YSI\internal\y_groupsecond>
  248. #define _YSI_GROUPS_FIRST_HALF
  249. #include <YSI\internal\y_groupsingle>
  250. // Remove the definitions.
  251. //#undef GROUP_LIBRARY_SIZE
  252. //#undef GROUP_LIBRARY_NAME
  253. #else
  254. #error You must define both GROUP_LIBRARY_SIZE and GROUP_LIBRARY_NAME.
  255. #endif
  256. #else
  257. #if defined GROUP_LIBRARY_SIZE
  258. #error You must define both GROUP_LIBRARY_SIZE and GROUP_LIBRARY_NAME.
  259. #endif
  260. #endif