y_groups.inc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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 YSI groups include.
  19. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  20. Portions created by the Initial Developer are Copyright (C) 2011
  21. the Initial Developer. All Rights Reserved.
  22. Contributors:
  23. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  24. Thanks:
  25. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  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, whose limits continue to amaze me!
  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 "internal\y_version"
  49. #if !defined _inc_y_groups
  50. #error Did you do <YSI/y_groups> instead of the required <YSI\y_groups>?
  51. #endif
  52. #undef _inc_y_groups
  53. #include "internal\y_nogroups"
  54. #include "internal\y_plugins"
  55. /*#if defined YSI_GROUPS_LAST
  56. #if YSI_GROUPS_LAST == 25
  57. #undef _GROUP_MAKE_NAME
  58. #undef _GROUP_MAKE_LIMIT
  59. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  60. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  61. #elseif YSI_GROUPS_LAST == 22
  62. #undef _GROUP_MAKE_NAME
  63. #undef _GROUP_MAKE_LIMIT
  64. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  65. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  66. #elseif YSI_GROUPS_LAST == 9
  67. #undef _GROUP_MAKE_NAME
  68. #undef _GROUP_MAKE_LIMIT
  69. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  70. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  71. #elseif YSI_GROUPS_LAST == 8
  72. #undef _GROUP_MAKE_NAME
  73. #undef _GROUP_MAKE_LIMIT
  74. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  75. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  76. #endif
  77. #undef YSI_GROUPS_LAST
  78. #endif*/
  79. #if defined _YSI_GROUPS_FIRST_HALF
  80. #undef _YSI_GROUPS_FIRST_HALF
  81. #endif
  82. // First, detect which library has included this. If none then it was the user.
  83. #if defined _inc_y_classes
  84. #if !defined _YSI_GROUP_CLASSES_INCLUDED
  85. // Although this is included before _GROUP_MAKE_NAME is set, it will
  86. // still be the correct value eventually.
  87. // Mark this library as existing.
  88. #define _YSI_GROUP_CLASSES_INCLUDED
  89. // These all need doing twice - once here and once below.
  90. //#if defined _YSI_HAS_GROUP_SYSTEM
  91. // #include "internal\y_groupfirst"
  92. //#endif
  93. #undef _GROUP_MAKE_NAME
  94. #undef _GROUP_MAKE_LIMIT
  95. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  96. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  97. #if defined _YSI_HAS_GROUP_SYSTEM
  98. #include "internal\y_groupsecond"
  99. #include "internal\y_classgroups"
  100. #endif
  101. #include "internal\y_groupsingle"
  102. // End.
  103. #endinput
  104. #endif
  105. #endif
  106. #if defined _inc_y_commands
  107. #if !defined _YSI_GROUP_COMMANDS_INCLUDED
  108. // Although this is included before _GROUP_MAKE_NAME is set, it will
  109. // still be the correct value eventually.
  110. // Mark this library as existing.
  111. #define _YSI_GROUP_COMMANDS_INCLUDED
  112. // These all need doing twice - once here and once below.
  113. //#if defined _YSI_HAS_GROUP_SYSTEM
  114. // #include "internal\y_groupfirst"
  115. //#endif
  116. #undef _GROUP_MAKE_NAME
  117. #undef _GROUP_MAKE_LIMIT
  118. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  119. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  120. #if defined _YSI_HAS_GROUP_SYSTEM
  121. #include "internal\y_groupsecond"
  122. #endif
  123. #include "internal\y_groupsingle"
  124. // End.
  125. #endinput
  126. #endif
  127. #endif
  128. #if defined _inc_y_areas
  129. #if !defined _YSI_GROUP_AREAS_INCLUDED
  130. // Although this is included before _GROUP_MAKE_NAME is set, it will
  131. // still be the correct value eventually.
  132. // Mark this library as existing.
  133. #define _YSI_GROUP_AREAS_INCLUDED
  134. // These all need doing twice - once here and once below.
  135. //#if defined _YSI_HAS_GROUP_SYSTEM
  136. // #include "internal\y_groupfirst"
  137. //#endif
  138. #undef _GROUP_MAKE_NAME
  139. #undef _GROUP_MAKE_LIMIT
  140. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_AREAS
  141. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_AREAS
  142. #if defined _YSI_HAS_GROUP_SYSTEM
  143. #include "internal\y_groupsecond"
  144. #endif
  145. #include "internal\y_groupsingle"
  146. // End.
  147. #endinput
  148. #endif
  149. #endif
  150. #if defined _YSI_ALLOW_INTERNAL_TEST
  151. #if defined _inc_y_inttest
  152. #if !defined _YSI_GROUP_INTTEST_INCLUDED
  153. // Mark this library as existing.
  154. #define _YSI_GROUP_INTTEST_INCLUDED
  155. // These all need doing twice - once here and once below.
  156. //#if defined _YSI_HAS_GROUP_SYSTEM
  157. // #include "internal\y_groupfirst"
  158. //#endif
  159. #undef _GROUP_MAKE_NAME
  160. #undef _GROUP_MAKE_LIMIT
  161. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  162. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  163. #if defined _YSI_HAS_GROUP_SYSTEM
  164. #include "internal\y_groupsecond"
  165. #endif
  166. #include "internal\y_groupsingle"
  167. // End.
  168. #endinput
  169. #endif
  170. #endif
  171. #if defined _inc_y_inttest2
  172. #if !defined _YSI_GROUP_INTTEST2_INCLUDED
  173. // Mark this library as existing.
  174. #define _YSI_GROUP_INTTEST2_INCLUDED
  175. // These all need doing twice - once here and once below.
  176. //#if defined _YSI_HAS_GROUP_SYSTEM
  177. // #include "internal\y_groupfirst"
  178. //#endif
  179. #undef _GROUP_MAKE_NAME
  180. #undef _GROUP_MAKE_LIMIT
  181. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  182. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  183. #if defined _YSI_HAS_GROUP_SYSTEM
  184. #include "internal\y_groupsecond"
  185. #endif
  186. #include "internal\y_groupsingle"
  187. // End.
  188. #endinput
  189. #endif
  190. #endif
  191. #endif
  192. // || ||
  193. // =============================================================================
  194. // || ||
  195. #define _YSI_GROUPS_FIRST_HALF
  196. // || ||
  197. // =============================================================================
  198. // || ||
  199. // User inclusion.
  200. #if !defined _YSI_HAS_GROUP_SYSTEM
  201. #define _YSI_HAS_GROUP_SYSTEM
  202. // Include the main code.
  203. #include <a_samp>
  204. #include "internal\y_grouponce"
  205. // Include code for previous libraries.
  206. #if defined _YSI_GROUP_CLASSES_INCLUDED
  207. // This only needs to be done if the library was previously included.
  208. #define _YSIM_OVERRIDE 22
  209. #include "y_master"
  210. // Include the first half of the file for the call chain.
  211. //#include "internal\y_groupfirst"
  212. #undef _GROUP_MAKE_NAME
  213. #undef _GROUP_MAKE_LIMIT
  214. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CLASSES
  215. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CLASSES
  216. // Include the second half of the file for the methods.
  217. #include "internal\y_groupsecond"
  218. #include "internal\y_classgroups"
  219. #endif
  220. #if defined _YSI_GROUP_COMMANDS_INCLUDED
  221. // This only needs to be done if the library was previously included.
  222. #define _YSIM_OVERRIDE 25
  223. #include "y_master"
  224. // Include the first half of the file for the call chain.
  225. //#include "internal\y_groupfirst"
  226. #undef _GROUP_MAKE_NAME
  227. #undef _GROUP_MAKE_LIMIT
  228. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_CMD
  229. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_CMD
  230. // Include the second half of the file for the methods.
  231. #include "internal\y_groupsecond"
  232. #endif
  233. #if defined _YSI_GROUP_AREAS_INCLUDED
  234. // This only needs to be done if the library was previously included.
  235. #define _YSIM_OVERRIDE 18
  236. #include "y_master"
  237. // Include the first half of the file for the call chain.
  238. //#include "internal\y_groupfirst"
  239. #undef _GROUP_MAKE_NAME
  240. #undef _GROUP_MAKE_LIMIT
  241. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_AREAS
  242. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_AREAS
  243. // Include the second half of the file for the methods.
  244. #include "internal\y_groupsecond"
  245. #endif
  246. #if defined _YSI_PLUGINS_STREAMER
  247. #if defined _YCM_q@
  248. #define _YSIM_OVERRIDE 16
  249. #endif
  250. #include "y_master"
  251. // Include the first half of the file for the call chain.
  252. //#include "internal\y_groupfirst"
  253. //#undef _GROUP_MAKE_NAME
  254. //#undef _GROUP_MAKE_LIMIT
  255. //#define _GROUP_MAKE_NAME<%0...%1> %0SObject%1
  256. //#define _GROUP_MAKE_LIMIT<%0...%1>
  257. // Include the second half of the file for the methods.
  258. //#include "internal\y_groupsecond"
  259. #include "internal\y_incognitostreamer"
  260. #endif
  261. // Internal test library.
  262. #if defined _YSI_ALLOW_INTERNAL_TEST
  263. #if defined _YSI_GROUP_INTTEST_INCLUDED
  264. #define _YSIM_OVERRIDE 9
  265. #include "y_master"
  266. //#include "internal\y_groupfirst"
  267. #undef _GROUP_MAKE_NAME
  268. #undef _GROUP_MAKE_LIMIT
  269. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST
  270. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST
  271. #include "internal\y_groupsecond"
  272. #endif
  273. #if defined _YSI_GROUP_INTTEST2_INCLUDED
  274. #define _YSIM_OVERRIDE 8
  275. #include "y_master"
  276. //#include "internal\y_groupfirst"
  277. #undef _GROUP_MAKE_NAME
  278. #undef _GROUP_MAKE_LIMIT
  279. #define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_INTTEST2
  280. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_INTTEST2
  281. #include "internal\y_groupsecond"
  282. #endif
  283. #endif
  284. // Recursive group functions to make groups of groups. Make this code pure
  285. // client code so that 90% of it is not included ever.
  286. /*#define _YSIM_OVERRIDE 24
  287. //#define YSIM_C_ENABLE
  288. #include "y_master"
  289. #undef _GROUP_MAKE_NAME
  290. #undef _GROUP_MAKE_LIMIT*/
  291. /*#define _GROUP_MAKE_NAME _GROUP_MAKE_NAME_GROUP
  292. #define _GROUP_MAKE_LIMIT _GROUP_MAKE_LIMIT_GROUP
  293. #define _GROUP_MAKE_TAG Group
  294. //#include "internal\y_groupsecond"
  295. #undef _YSI_GROUPS_FIRST_HALF
  296. // Disable the OnPlayerConnect code.
  297. #undef ghook
  298. #define ghook%0On%1(%2) stock _GROUP_MAKE_NAME<On%2...>(%3)
  299. #include "internal\y_groupsecond"
  300. #undef ghook
  301. #define ghook group_hook
  302. #define _YSI_GROUPS_FIRST_HALF
  303. #define _GROUP_MAKE_TAG Group
  304. #include "internal\y_groupsingle"*/
  305. // These need VERY different defaults.
  306. #endif
  307. // Now include any user defined libraries.
  308. #if defined GROUP_LIBRARY_NAME
  309. #if defined GROUP_LIBRARY_SIZE
  310. // Include the generic group code for this new custom group.
  311. #if defined _YSIM_MANUAL_SET
  312. #define _YSIM_RESET_USER
  313. #endif
  314. #include "y_master"
  315. //#include "internal\y_groupsingle"
  316. //#include "internal\y_groupfirst"
  317. #undef _GROUP_MAKE_NAME
  318. #undef _GROUP_MAKE_LIMIT
  319. #define _GROUP_MAKE_NAME GROUP_LIBRARY_NAME
  320. #define _GROUP_MAKE_LIMIT GROUP_LIBRARY_SIZE
  321. //#if defined GROUP_LIBRARY_TAG
  322. // #define _GROUP_MAKE_TAG GROUP_LIBRARY_TAG
  323. //#endif
  324. #undef _YSI_GROUPS_FIRST_HALF
  325. // Include the second half of the file for the methods.
  326. #include "internal\y_groupsecond"
  327. #define _YSI_GROUPS_FIRST_HALF
  328. #include "internal\y_groupsingle"
  329. // Remove the definitions.
  330. //#undef GROUP_LIBRARY_SIZE
  331. //#undef GROUP_LIBRARY_NAME
  332. #else
  333. #error You must define both GROUP_LIBRARY_SIZE and GROUP_LIBRARY_NAME.
  334. #endif
  335. #else
  336. #if defined GROUP_LIBRARY_SIZE
  337. #error You must define both GROUP_LIBRARY_SIZE and GROUP_LIBRARY_NAME.
  338. #endif
  339. #endif
  340. // Revert to the user's included definition if y_groups was included after all
  341. // group using libraries and after explicit y_master inclusion.
  342. //#include "internal\y_grouprevert"
  343. //#define YSI_SET_LAST_GROUP 24
  344. #include "internal\y_grouprevert"