Guest User

Gang System: Saving gangs, Custom Zones

a guest
Apr 13th, 2014
2,389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.18 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define COLOR_LIGHTBLUE 0x33CCFFAA
  5. #define COLOR_RED 0xAA3333AA
  6. #define COLOR_GREY 0xAFAFAFAA
  7. #define COLOR_YELLOW 0xFFFF00AA
  8. #define COLOR_PINK 0xFF66FFAA
  9. #define COLOR_BLUE 0x0000BBAA
  10. #define COLOR_WHITE 0xFFFFFFAA
  11. #define COLOR_DARKRED 0x660000AA
  12. #define COLOR_ORANGE 0xFF9900AA
  13. #define COLOR_BRIGHTRED 0xFF0000AA
  14. #define COLOR_INDIGO 0x4B00B0AA
  15. #define COLOR_VIOLET 0x9955DEEE
  16. #define COLOR_LIGHTRED 0xFF99AADD
  17. #define COLOR_SEAGREEN 0x00EEADDF
  18. #define COLOR_GRAYWHITE 0xEEEEFFC4
  19. #define COLOR_LIGHTNEUTRALBLUE 0xabcdef66
  20. #define COLOR_GREENISHGOLD 0xCCFFDD56
  21. #define COLOR_LIGHTBLUEGREEN 0x0FFDD349
  22. #define COLOR_NEUTRALBLUE 0xABCDEF01
  23. #define COLOR_LIGHTCYAN 0xAAFFCC33
  24. #define COLOR_LEMON 0xDDDD2357
  25. #define COLOR_MEDIUMBLUE 0x63AFF00A
  26. #define COLOR_NEUTRAL 0xABCDEF97
  27. #define COLOR_BLACK 0x00000000
  28. #define COLOR_NEUTRALGREEN 0x81CFAB00
  29. #define COLOR_DARKGREEN 0x12900BBF
  30. #define COLOR_LIGHTGREEN 0x24FF0AB9
  31. #define COLOR_DARKBLUE 0x300FFAAB
  32. #define COLOR_BLUEGREEN 0x46BBAA00
  33. #define COLOR_PINK 0xFF66FFAA
  34. #define COLOR_LIGHTBLUE 0x33CCFFAA
  35. #define COLOR_DARKRED 0x660000AA
  36. #define COLOR_ORANGE 0xFF9900AA
  37. #define COLOR_PURPLE 0x800080AA
  38. #define COLOR_GRAD1 0xB4B5B7FF
  39. #define COLOR_GRAD2 0xBFC0C2FF
  40. #define COLOR_RED1 0xFF0000AA
  41. #define COLOR_GREY 0xAFAFAFAA
  42. #define COLOR_GREEN 0x33AA33AA
  43. #define COLOR_RED 0xAA3333AA
  44. #define COLOR_YELLOW 0xFFFF00AA
  45. #define COLOR_WHITE 0xFFFFFFAA
  46. #define COLOR_BROWN 0x993300AA
  47. #define COLOR_CYAN 0x99FFFFAA
  48. #define COLOR_TAN 0xFFFFCCAA
  49. #define COLOR_PINK 0xFF66FFAA
  50. #define COLOR_KHAKI 0x999900AA
  51. #define COLOR_LIME 0x99FF00AA
  52. #define COLOR_SYSTEM 0xEFEFF7AA
  53. #define COLOR_GRAD2 0xBFC0C2FF
  54. #define COLOR_GRAD4 0xD8D8D8FF
  55. #define COLOR_GRAD6 0xF0F0F0FF
  56. #define COLOR_GRAD2 0xBFC0C2FF
  57. #define COLOR_GRAD3 0xCBCCCEFF
  58. #define COLOR_GRAD5 0xE3E3E3FF
  59. #define COLOR_GRAD1 0xB4B5B7FF
  60.  
  61. #define MAX_BANDS 100 // Max Groups 100. You can change to max up to 500!
  62.  
  63. enum ginfo
  64. {
  65. grname[75],
  66. leader,
  67. active
  68. };
  69.  
  70. enum pginfo
  71. {
  72. gid,
  73. order,
  74. invited,
  75. attemptjoin
  76. };
  77.  
  78. new BAND[MAX_PLAYERS][pginfo];
  79. new BANDinfo[MAX_BANDS][ginfo];
  80.  
  81. public OnFilterScriptInit()
  82. {
  83. for(new x; x<MAX_PLAYERS; x++)
  84. {
  85. BAND[x][gid] = -1;
  86. BAND[x][order] = -1;
  87. BAND[x][invited] = -1;
  88. BAND[x][attemptjoin] = -1;
  89. }
  90. return 1;
  91. }
  92.  
  93. public OnPlayerConnect(playerid)
  94. {
  95. BAND[playerid][gid] = -1;
  96. BAND[playerid][invited] = -1;
  97. BAND[playerid][attemptjoin] = -1;
  98. return 1;
  99. }
  100.  
  101. public OnPlayerDisconnect(playerid, reason)
  102. {
  103. return 1;
  104. }
  105.  
  106. COMMAND:gangcreate(playerid, params[])
  107. {
  108. if(BAND[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "Leave your band with {FFFFFF}/Gangleave{FF0000} before creating a new one!");
  109. if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Gangcreate{FF0000} (Gang name 3-50 characters)!");
  110. if(IsBANDTaken(params)) return SendClientMessage(playerid, 0xFF0000, "ERROR: Gang name is already in Use!");
  111. CreateBAND(params, playerid);
  112. return 1;
  113. }
  114.  
  115. COMMAND:gangleave(playerid, params[])
  116. {
  117. if(BAND[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "ERROR:You are not in a Gang to leave one!");
  118. LeaveBAND(playerid, 0);
  119. return 1;
  120. }
  121.  
  122. COMMAND:gangaccept(playerid, params[])
  123. {
  124. if(BAND[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "You are not the leader of the Gang, you cannot invite people!");
  125. new cid;
  126. if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Gangaccept{FF0000} [id]");
  127. cid = strval(params);
  128. if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "Player Is not connected!");
  129. if(BAND[cid][gid] == BAND[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "Player Is already in your band!");
  130. if(BAND[cid][invited] == BAND[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "Player has already been invited to your band!");
  131. if(BAND[cid][attemptjoin] == BAND[playerid][gid]) return BANDJoin(cid, BAND[playerid][gid]);
  132. BAND[cid][invited] = BAND[playerid][gid];
  133. new string[125], pname[24];
  134. GetPlayerName(playerid, pname, 24);
  135. format(string, sizeof(string), "You have been invited to join Band {FFFFFF}%s(ID.%d){FFCC66} by {FFFFFF}%s(ID.%d). /Gangjoin %d", BANDinfo[BAND[playerid][gid]][grname], BAND[playerid][gid], pname, playerid, BAND[playerid][gid]);
  136. SendClientMessage(cid, 0xFFCC66, string);
  137. GetPlayerName(cid, pname, 24);
  138. format(string, sizeof(string), "You have invited {FFFFFF}%s(ID.%d){FFCC66} to join your band!", pname, cid);
  139. SendClientMessage(playerid, 0xFFCC66, string);
  140. return 1;
  141. }
  142.  
  143. COMMAND:gangowner(playerid, params[])
  144. {
  145. if(BAND[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "You are not the leader of the Gang, you cannot change the leader!");
  146. new cid;
  147. if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Gangowner{FF0000} [id]");
  148. cid = strval(params);
  149. if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "Player Is not connected!");
  150. if(cid == playerid) return SendClientMessage(playerid, 0xFF0000, "ERROR: You are now Gang Leader :D!");
  151. if(BAND[playerid][gid] != BAND[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "Player Is not in your Gang!");
  152. ChangeMemberOrder(BAND[playerid][gid], 1);
  153. BAND[playerid][order] = BANDMembers(BAND[playerid][gid]);
  154. return 1;
  155. }
  156. COMMAND:gangjoin(playerid, params[])
  157. {
  158. if(BAND[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "You are already in a Gang! Leave your current one before joining another one!");
  159. new grid;
  160. if( (isnull(params) && BAND[playerid][invited] != -1 ) || ( strval(params) == BAND[playerid][invited] && BAND[playerid][invited] != -1) ) return BANDJoin(playerid, BAND[playerid][invited]);
  161. if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Gangjoin{FF0000} [id]");
  162. grid = strval(params);
  163. if(!BANDinfo[grid][active]) return SendClientMessage(playerid, COLOR_RED, "ERROR: You wanted to join band which doesnt Exsist!!");
  164. BAND[playerid][attemptjoin] = grid;
  165. new string[125], pname[24];
  166. GetPlayerName(playerid, pname, 24);
  167. format(string, sizeof(string), "You have requested to join band %s(ID:%d)", BANDinfo[grid][grname], grid);
  168. SendClientMessage(playerid, 0xFFCC66, string);
  169. format(string, sizeof(string), "{FFFFFF}%s(ID.%d) {FFCC66}has requested to join your Gang. Type /Gangaccept %d to accept him!", pname, playerid, playerid);
  170. SendMessageToLeader(grid, string);
  171. return 1;
  172. }
  173.  
  174. COMMAND:gangkick(playerid, params[])
  175. {
  176. if(BAND[playerid][order] != 1) return SendClientMessage(playerid, COLOR_RED, "ERROR:You are not the leader of a Gang, you cannot kick!");
  177. new cid;
  178. if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Gangkick{FF0000} [id]");
  179. cid = strval(params);
  180. if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "Player Is not connected!");
  181. if(cid == playerid) return SendClientMessage(playerid, 0xFF0000, "You cannot kick yourself, silly.");
  182. if(BAND[playerid][gid] != BAND[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "Player Is not in your Gang!");
  183. LeaveBAND(cid, 1);
  184. return 1;
  185. }
  186.  
  187. COMMAND:bm(playerid, params[])
  188. {
  189. if(BAND[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "ERROR: You are not in Band. You cannot Talk over Radio!");
  190. if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: ! [message]. WARNING! Its ICly!");
  191. new pname[24], string[140+24];
  192. GetPlayerName(playerid, pname, 24);
  193. format(string, sizeof(string), "%s(ID.%d): %s", pname, playerid, params);
  194. SendMessageToAllBANDMembers(BAND[playerid][gid], string);
  195. return 1;
  196. }
  197. COMMAND:gangsinfo(playerid, params[])
  198. {
  199. if(BAND[playerid][gid] == -1) return SendClientMessage(playerid, COLOR_GREEN, "ERROR: You are not in Gang. To check Gang Stats, go in your Gang!");
  200. SendClientMessage(playerid, COLOR_GREEN ,"Warning: Gang Stats are Currently Under Construction! Need ideas for it. ");
  201. return 1;
  202. }
  203.  
  204. COMMAND:ganglist(playerid, params[])
  205. {
  206. if(isnull(params) && BAND[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/Ganglist{FF0000} [id]");
  207. if(isnull(params))
  208. {
  209. DisplayBANDMembers(BAND[playerid][gid], playerid);
  210. return 1;
  211. }
  212. new grid = strval(params);
  213. if(!BANDinfo[grid][active]) return SendClientMessage(playerid, 0xFF0000, "The band ID you have entered is not active!");
  214. DisplayBANDMembers(grid, playerid);
  215. return 1;
  216. }
  217.  
  218. COMMAND:gangs(playerid, params[])
  219. {
  220. ListBANDs(playerid);
  221. return 1;
  222. }
  223.  
  224. COMMAND:grl(playerid, params[])
  225. return cmd_gangleave(playerid, params);
  226.  
  227. COMMAND:grc(playerid, params[])
  228. return cmd_gangcreate(playerid, params);
  229.  
  230. COMMAND:gri(playerid, params[])
  231. return cmd_gangaccept(playerid, params);
  232.  
  233. COMMAND:grlead(playerid, params[])
  234. return cmd_gangowner(playerid, params);
  235.  
  236. COMMAND:grj(playerid, params[])
  237. return cmd_gangjoin(playerid, params);
  238.  
  239. COMMAND:grk(playerid, params[])
  240. return cmd_gangkick(playerid, params);
  241.  
  242. COMMAND:gm(playerid, params[])
  243. return cmd_bm(playerid, params);
  244.  
  245. COMMAND:grlist(playerid, params[])
  246. return cmd_ganglist(playerid, params);
  247.  
  248.  
  249. stock DisplayBANDMembers(BANDid, playerid)
  250. {
  251. new amount[2], string[200], shortstr[55], pname[24];
  252. format(string, sizeof(string), "Band Members for %s(ID:%d)", BANDinfo[BANDid][grname], BANDid);
  253. SendClientMessage(playerid, 0xFFFFFF, string);
  254. string = "";
  255. for(new x; x<MAX_PLAYERS; x++)
  256. {
  257. if(BAND[x][gid] == BANDid)
  258. {
  259. amount[0] ++;
  260. amount[1] ++;
  261. GetPlayerName(x, pname, 24);
  262. if(BANDinfo[BANDid][leader] != x) format(shortstr, sizeof(shortstr), "%s(%d),", pname, x);
  263. if(BANDinfo[BANDid][leader] == x) format(shortstr, sizeof(shortstr), "[Leader]%s(%d),", pname, x);
  264. if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
  265. if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
  266. if(amount[0] == 6)
  267. {
  268. strdel(string, strlen(string)-1, strlen(string));
  269. SendClientMessage(playerid, 0xFFCC66, string);
  270. string = "";
  271. amount[0] = 0;
  272. }
  273. }
  274. }
  275. strdel(string, strlen(string)-1, strlen(string));
  276. if(amount[0] != 0) SendClientMessage(playerid, 0xFFCC66, string);
  277. return 1;
  278. }
  279.  
  280. stock ListBANDs(playerid)
  281. {
  282. new amount[2], string[200], shortstr[55];
  283. SendClientMessage(playerid, 0xFFFFFF, "Current Active Gangs:");
  284. for(new x=0; x<MAX_BANDS; x++)
  285. {
  286. if(BANDinfo[x][active])
  287. {
  288. amount[0] ++;
  289. amount[1] ++;
  290. format(shortstr, sizeof(shortstr), "%s(ID:%d)", BANDinfo[x][grname], x);
  291. if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
  292. if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
  293. if(amount[0] == 4)
  294. {
  295. SendClientMessage(playerid, 0xFFCC66, string);
  296. string = "";
  297. amount[0] = 0;
  298. }
  299. }
  300. }
  301. if(amount[1] == 0) SendClientMessage(playerid, 0xFFFF00, "There are currently no active gangs!");
  302. if(amount[1] != 0) SendClientMessage(playerid, 0xFFCC66, string);
  303. return 1;
  304. }
  305.  
  306.  
  307.  
  308.  
  309. stock SendMessageToLeader(BANDi, message[])
  310. return SendClientMessage(BANDinfo[BANDi][leader], 0xFFCC66, message);
  311.  
  312. stock BANDJoin(playerid, BANDi)
  313. {
  314. BAND[playerid][gid] = BANDi;
  315. BAND[playerid][order] = BANDMembers(BANDi);
  316. BAND[playerid][attemptjoin] = -1;
  317. BAND[playerid][invited] = -1;
  318. new pname[24], string[130];
  319. GetPlayerName(playerid, pname, 24);
  320. format(string, sizeof(string), "%s is now in your Gang!", pname);
  321. SendMessageToAllBANDMembers(BANDi, string);
  322. format(string, sizeof(string), "You are now in gang %s(ID:%d)", BANDinfo[BANDi][grname] ,BANDi);
  323. SendClientMessage(playerid, 0xFFCC66, string);
  324. return 1;
  325. }
  326.  
  327. stock FindNextSlot()
  328. {
  329. new id;
  330. while(BANDinfo[id][active]) id ++;
  331. return id;
  332. }
  333.  
  334. stock IsBANDTaken(grpname[])
  335. {
  336. for(new x; x<MAX_BANDS; x++)
  337. {
  338. if(BANDinfo[x][active] == 1)
  339. {
  340. if(!strcmp(grpname, BANDinfo[x][grname], true) && strlen(BANDinfo[x][grname]) != 0) return 1;
  341. }
  342. }
  343. return 0;
  344. }
  345.  
  346. stock BANDInvite(playerid, BANDid)
  347. return BAND[playerid][invited] = BANDid;
  348.  
  349. stock CreateBAND(grpname[], owner)
  350. {
  351. new slotid = FindNextSlot();
  352. BANDinfo[slotid][leader] = owner;
  353. format(BANDinfo[slotid][grname], 75, "%s", grpname);
  354. BANDinfo[slotid][active] = 1;
  355. BAND[owner][gid] = slotid;
  356. BAND[owner][order] = 1;
  357. new string[120];
  358. format(string, sizeof(string), "You created Gang %s(ID:%d)", grpname, slotid);
  359. SendClientMessage(owner, 0xFFCC66, string);
  360. return slotid;
  361. }
  362.  
  363. stock LeaveBAND(playerid, reason)
  364. {
  365. new BANDid = BAND[playerid][gid], orderid = BAND[playerid][order], string[100], pname[24];
  366. BAND[playerid][gid] = -1;
  367. BAND[playerid][order] = -1;
  368. BANDCheck(BANDid, orderid);
  369. GetPlayerName(playerid, pname, 24);
  370. if(reason == 0)
  371. {
  372. format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} has left the Gang!", pname, playerid);
  373. SendClientMessage(playerid, 0xFFCC66, "You are leave from the gang");
  374. }
  375. if(reason == 1)
  376. {
  377. format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} has kicked from the Gang!", pname, playerid);
  378. SendClientMessage(playerid, 0xFFCC66, "You are kicked from the gang!");
  379. }
  380. if(reason == 2) format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} has left your Gang (Disconnected)!", pname, playerid);
  381. SendMessageToAllBANDMembers(BANDid, string);
  382. return 1;
  383. }
  384.  
  385. stock BANDCheck(BANDid, orderid)
  386. {
  387. new gmems = BANDMembers(BANDid);
  388. if(!gmems) BANDinfo[BANDid][active] = 0;
  389. if(gmems != 0) ChangeMemberOrder(BANDid, orderid);
  390. return 1;
  391. }
  392.  
  393. stock BANDMembers(BANDid)
  394. {
  395. if(!BANDinfo[BANDid][active]) return 0;
  396. new BANDmembers;
  397. for(new i; i<MAX_PLAYERS; i++) if(BAND[i][gid] == BANDid) BANDmembers++;
  398. return BANDmembers;
  399. }
  400.  
  401. stock ChangeMemberOrder(BANDid, orderid)
  402. {
  403. for(new x; x<MAX_PLAYERS; x++)
  404. {
  405. if(BAND[x][gid] != BANDid || BAND[x][order] < orderid) continue;
  406. BAND[x][order] --;
  407. if(BAND[x][order] == 1)
  408. {
  409. BANDinfo[BANDid][leader] = x;
  410. new string[128], pname[24];
  411. GetPlayerName(x, pname, 24);
  412. format(string, sizeof(string), "{FFFFFF}%s(ID.%d){FFCC66} is now Gang Leader! Congratiulations!", pname, x);
  413. SendMessageToAllBANDMembers(BANDid, string);
  414. }
  415. }
  416. return 1;
  417. }
  418.  
  419. stock SendMessageToAllBANDMembers(BANDid, message[])
  420. {
  421. if(!BANDinfo[BANDid][active]) return 0;
  422. for(new x; x<MAX_PLAYERS; x++) if(BAND[x][gid] == BANDid) SendClientMessage(x, 0xFFCC66, message);
  423. return 1;
  424. }
Advertisement
Add Comment
Please, Sign In to add comment