y_groups.inc 14 KB

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