Guest User

Groups1

a guest
Aug 5th, 2017
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.07 KB | None | 0 0
  1. //====================================================================[includes]
  2. #include <a_samp>
  3. #include <a_mysql>
  4. #include <izcmd>
  5. #include <sscanf2>
  6. #include <easydialog>
  7. #include <foreach>
  8. #include <y_iterate>
  9. //=================================================================[definitions]
  10. //root 7IMe0bx7BrG4dexg
  11. #define mysql_host ""
  12. #define mysql_user ""
  13. #define mysql_pass ""
  14. #define mysql_data ""
  15.  
  16. #define MAX_PERMISSION 5
  17. #define MAX_GROUPP 10
  18.  
  19.  
  20. #define SCM SendClientMessage
  21.  
  22. #define COLOR_GREY 0xAFAFAFAA
  23. #define COLOR_RED 0xB22222FF
  24. #define COLOR_GREEN 0x9ACD32AA
  25.  
  26. #define MAX_RANKS 5000//increase this if you like. Tho i'd prefer to put a limit for max player's group ranks.
  27. #define MAX_GROUPS 500//you can change it, if you know what you are doing.
  28. #undef MAX_PLAYERS
  29. #define MAX_PLAYERS 100
  30. #if !defined isnull
  31. #define isnull(%1) \
  32. ((%1[0] == 0) || (%1[0] == 1 && %1[1] == 0))
  33. #endif
  34.  
  35.  
  36. //=======================[variables etc]========================================
  37. new RankSelected[MAX_PLAYERS];
  38. new TempGroupID[MAX_PLAYERS];
  39. new SQL;
  40. //==============================================================================
  41. enum groupsDATA
  42. {
  43. ORM:ORM_ID,
  44. gID,
  45. gName[128],
  46. gLeaderName[32],
  47. gchat,
  48. gCredits,
  49. gResources,
  50. gWarWins,
  51. gWarLosses,
  52. gDraws,
  53. gScore
  54. };
  55. new GroupInfo[MAX_GROUPS][groupsDATA];
  56.  
  57. enum ranksDATA
  58. {
  59. ORM:ORM_ID2,
  60. rID,
  61. rgID,//group id
  62. rName[56],
  63. rLevel,
  64. rPermission[MAX_PERMISSION]// 0-NO 1-YES
  65. };
  66. new RankInfo[MAX_RANKS][ranksDATA];
  67. //==============================================================================
  68.  
  69. enum playerDATA
  70. {
  71. ORM:ORM_ID3,
  72. pID,
  73. pName[MAX_PLAYER_NAME],
  74. grouppid[MAX_GROUPP],//here [MAX_GROUPP] represents maximum number of groups for a player
  75. prID[MAX_GROUPP],//useful for locating rank id instead of name.
  76. groupcontribution,
  77. gWarKills,
  78. pGroups //should be limited to the number of MAX player groups.
  79. };
  80. new pInfo[MAX_PLAYERS][playerDATA];
  81. new groupvariables[MAX_PLAYERS][2];
  82. new Iterator:Groups<MAX_PLAYERS>;
  83. new Iterator:Ranks<MAX_RANKS>;
  84.  
  85. //==============================================================================
  86. //==========================[USEFUL FUNCTIONS]==================================
  87. //==============================================================================
  88. GetGroupID(gropname[])//very useful for getting the groupid for the functions below and in cmds.
  89. {
  90. foreach(new x : Groups)
  91. {
  92. if(!strcmp(gropname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return x;
  93. }
  94. return -1;
  95. }
  96.  
  97. GroupLoopCheckName(playerid, grpname[]) //I rarely use this.
  98. {
  99. for(new i=0; i < (MAX_GROUPP-1); ++i)
  100. {
  101. if(!strcmp(grpname, GroupInfo[pInfo[playerid][grouppid][i]][gName], true))
  102. {
  103. return i; //returns the group slotid of player, [grouppid][slotid]
  104. }
  105. }
  106. return 11; //11 = invalid as the max loop is 10
  107. }
  108.  
  109. GroupLoopCheck(playerid, groupid)//a must to use.
  110. {
  111. for(new i=0; i < (MAX_GROUPP-1); ++i)
  112. {
  113. if(pInfo[playerid][grouppid][i] == GroupInfo[groupid][gID])
  114. {
  115. return i; //returns the group slotid of player, [grouppid][slotid]
  116. }
  117. }
  118. return 11;//11 = invalid
  119. }
  120.  
  121. ReturnGroupName(playerid, groupslot) //1-10
  122. {
  123. new name[128];
  124. if(pInfo[playerid][grouppid][groupslot] > -1)
  125. {
  126. name = GroupInfo[pInfo[playerid][grouppid][groupslot]][gName];
  127. return name;
  128. }
  129. return 0;
  130. }
  131.  
  132. forward CheckPlayerGroup(playerid, groupid);//groupid = group array in foreach iterator
  133. public CheckPlayerGroup(playerid, groupid)
  134. {
  135. new i = GroupLoopCheck(playerid, groupid);
  136. if(i == 11)
  137. {
  138. return 0;
  139. }
  140. else
  141. {
  142. return 1;
  143. }
  144. }
  145.  
  146. forward CheckPlayerGroupPermission(playerid, groupid, permission);//should be used for checking rank's permission
  147. public CheckPlayerGroupPermission(playerid, groupid, permission)//returns 1 if everything matches
  148. {
  149. new i = GroupLoopCheck(playerid, groupid);
  150. if(i == 11)
  151. {
  152. return 0;
  153. }
  154. else
  155. {
  156. foreach(new r : Ranks)
  157. {
  158. if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])
  159. {
  160. if(RankInfo[r][rPermission][permission] == 1) //if he has the permission
  161. {
  162. return 1;
  163. }
  164. }
  165. }
  166. }
  167. return 0;
  168. }
  169.  
  170. forward CheckPlayerGroupRankLevel(playerid,groupid,level);//any usage?
  171. public CheckPlayerGroupRankLevel(playerid,groupid,level)
  172. {
  173. new i = GroupLoopCheck(playerid, groupid);
  174. if(i == 11)
  175. {
  176. return 0;
  177. }
  178. else
  179. {
  180. foreach(new r : Ranks)
  181. {
  182. if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])//RankInfo[r][rgID] == pInfo[playerid][grouppid][i] .... you can remove this.. its just an extra check.
  183. {
  184. if(RankInfo[r][rLevel] == level) //level
  185. {
  186. return 1;
  187. }
  188. }
  189. }
  190. }
  191. return 0;
  192. }
  193.  
  194. forward ReturnGroupLevel(playerid, groupid); //same as above but returns level
  195. public ReturnGroupLevel(playerid, groupid)
  196. {
  197. new count = 0;
  198. new i = GroupLoopCheck(playerid, groupid);
  199. if(i == 11)
  200. {
  201. return 0;
  202. }
  203. else
  204. {
  205. foreach(new r : Ranks)
  206. {
  207. if(RankInfo[r][rID] == pInfo[playerid][prID][i] && RankInfo[r][rgID] == pInfo[playerid][grouppid][i])//RankInfo[r][rgID] == pInfo[playerid][grouppid][i] .... you can remove this.. its just an extra check.
  208. {
  209. count = RankInfo[r][rLevel];
  210. break;
  211. }
  212. }
  213. }
  214. return count;
  215. }
  216. //==============================================================================
  217.  
  218. forward LoadPlayerGroup(playerid);
  219. public LoadPlayerGroup(playerid)
  220. {
  221. switch(orm_errno(pInfo[playerid][ORM_ID3]))
  222. {
  223. case ERROR_OK:
  224. {
  225. //stuff
  226. }
  227. case ERROR_NO_DATA:
  228. {
  229. orm_insert(pInfo[playerid][ORM_ID3], "CreatePlayerData", "d", playerid);
  230. }
  231. }
  232. orm_setkey(pInfo[playerid][ORM_ID3], "pID");
  233. return 1;
  234. }
  235.  
  236. forward CreatePlayerData(playerid);
  237. public CreatePlayerData(playerid)
  238. {
  239. orm_update(pInfo[playerid][ORM_ID3]);
  240. pInfo[playerid][grouppid][0] = -1;
  241. pInfo[playerid][prID][0] = -1;
  242. pInfo[playerid][grouppid][1] = -1;
  243. pInfo[playerid][prID][1] = -1;
  244. pInfo[playerid][grouppid][2] = -1;
  245. pInfo[playerid][prID][2] = -1;
  246. pInfo[playerid][grouppid][3] = -1;
  247. pInfo[playerid][prID][3] = -1;
  248. pInfo[playerid][grouppid][4] = -1;
  249. pInfo[playerid][prID][4] = -1;
  250. pInfo[playerid][grouppid][5] = -1;
  251. pInfo[playerid][prID][5] = -1;
  252. pInfo[playerid][grouppid][6] = -1;
  253. pInfo[playerid][prID][6] = -1;
  254. pInfo[playerid][grouppid][7] = -1;
  255. pInfo[playerid][prID][7] = -1;
  256. pInfo[playerid][grouppid][8] = -1;
  257. pInfo[playerid][prID][8] = -1;
  258. pInfo[playerid][grouppid][9] = -1;
  259. pInfo[playerid][prID][9] = -1;
  260. pInfo[playerid][groupcontribution] = 0;
  261. pInfo[playerid][gWarKills] = 0;
  262. pInfo[playerid][pGroups] = 0;
  263. orm_save(pInfo[playerid][ORM_ID3]);
  264. return 1;
  265. }
  266.  
  267. stock SavePlayerGStats(playerid)
  268. {
  269. if(pInfo[playerid][pID] != 0)
  270. {
  271. orm_update(pInfo[playerid][ORM_ID3]);
  272. }
  273. return 1;
  274. }
  275.  
  276. forward ShowRankEditingMenu(playerid, rank);
  277. public ShowRankEditingMenu(playerid, rank)
  278. {
  279. new dialogstr[556], string1[56], string2[56];
  280. format(string1,sizeof(string1),"Rank Name\t%s\n",RankInfo[rank][rName]);
  281. format(string2,sizeof(string2),"Rank Level\t%d\n",RankInfo[rank][rLevel]);
  282. strcat(dialogstr,string1);
  283. strcat(dialogstr,string2);
  284. if(RankInfo[rank][rPermission][0] == 1)
  285. {
  286. strcat(dialogstr,"Use Group Chat?\t{00FF00}YES\n");
  287. }
  288. else
  289. {
  290. strcat(dialogstr,"Use Group Chat?\t{FF0000}NO\n");
  291. }
  292.  
  293. if(RankInfo[rank][rPermission][1] == 1)
  294. {
  295. strcat(dialogstr,"Invite Members to the Group?\t{00FF00}YES\n");
  296. }
  297. else
  298. {
  299. strcat(dialogstr,"Invite Members to the Group?\t{FF0000}NO\n");
  300. }
  301.  
  302. if(RankInfo[rank][rPermission][2] == 1)
  303. {
  304. strcat(dialogstr,"Kick Members from the Group?\t{00FF00}YES\n");
  305. }
  306. else
  307. {
  308. strcat(dialogstr,"Kick Members from the Group?\t{FF0000}NO\n");
  309. }
  310.  
  311. if(RankInfo[rank][rPermission][3] == 1)
  312. {
  313. strcat(dialogstr,"Change members rank?\t{00FF00}YES\n");
  314. }
  315. else
  316. {
  317. strcat(dialogstr,"Change members rank?\t{FF0000}NO\n");
  318. }
  319.  
  320. if(RankInfo[rank][rPermission][4] == 1)
  321. {
  322. strcat(dialogstr,"Edit Group rank?\t{00FF00}YES\n");
  323. }
  324. else
  325. {
  326. strcat(dialogstr,"Edit Group rank?\t{FF0000}NO\n");
  327. }
  328.  
  329. ShowDialog(playerid,Show:GroupEditRank,DIALOG_STYLE_TABLIST,"Edit Rank Permissions",dialogstr,"Change","Close");
  330. return 1;
  331. }
  332.  
  333. // =============================================================================
  334. public OnFilterScriptInit()
  335. {
  336. print("_________________________________________________________________________");
  337. print("> Group System by Heller");
  338. print("> Script Name : Group System");
  339. print("> Script Version : BETA");
  340. print("> Script Coder : Heller");
  341. print("> Last Update : 7/31/2017");
  342. print("> mySQL Version : R39 - ORM queries");
  343. print("_________________________________________________________________________");
  344.  
  345. mysql_log();
  346.  
  347. SQL = mysql_connect(mysql_host, mysql_user, mysql_data, mysql_pass);
  348.  
  349. //load groups & ranks
  350. GroupsInformation();
  351. RanksInformation();
  352. return 1;
  353. }
  354.  
  355. public OnFilterScriptExit()
  356. {
  357. foreach(new b : Groups)
  358. {
  359. if(GroupInfo[b][gID] != 0) {
  360. orm_update(GroupInfo[b][ORM_ID]);
  361. }
  362. orm_destroy(GroupInfo[b][ORM_ID]);
  363.  
  364. for(new groupsDATA:e; e < groupsDATA; ++e)
  365. GroupInfo[b][e] = 0;
  366. }
  367. foreach(new i : Ranks)
  368. {
  369. if(RankInfo[i][rID] != 0) {
  370. orm_update(RankInfo[i][ORM_ID2]);
  371. }
  372. orm_destroy(RankInfo[i][ORM_ID2]);
  373.  
  374. for(new ranksDATA:e; e < ranksDATA; ++e)
  375. RankInfo[i][e] = 0;
  376. }
  377.  
  378. foreach(new players : Player)
  379. {
  380. if(pInfo[players][pID] != 0)
  381. {
  382. orm_update(pInfo[players][ORM_ID3]);
  383. }
  384. orm_destroy(pInfo[players][ORM_ID3]);
  385.  
  386. for(new playerDATA:e; e < playerDATA; ++e)
  387. pInfo[players][e] = 0;
  388. }
  389. return 1;
  390. }
  391.  
  392. public OnPlayerConnect(playerid)
  393. {
  394. groupvariables[playerid][0] = -1;
  395. groupvariables[playerid][1] = 0;
  396. GetPlayerName(playerid, pInfo[playerid][pName], MAX_PLAYER_NAME);
  397. new ORM:ormid = pInfo[playerid][ORM_ID3] = orm_create("players2", SQL);
  398.  
  399. orm_addvar_int(ormid, pInfo[playerid][pID], "pID");
  400. orm_addvar_string(ormid, pInfo[playerid][pName], 32, "pName");
  401. orm_addvar_int(ormid, pInfo[playerid][grouppid][0], "grouppid1");
  402. orm_addvar_int(ormid, pInfo[playerid][grouppid][1], "grouppid2");
  403. orm_addvar_int(ormid, pInfo[playerid][grouppid][2], "grouppid3");
  404. orm_addvar_int(ormid, pInfo[playerid][grouppid][3], "grouppid4");
  405. orm_addvar_int(ormid, pInfo[playerid][grouppid][4], "grouppid5");
  406. orm_addvar_int(ormid, pInfo[playerid][grouppid][5], "grouppid6");
  407. orm_addvar_int(ormid, pInfo[playerid][grouppid][6], "grouppid7");
  408. orm_addvar_int(ormid, pInfo[playerid][grouppid][7], "grouppid8");
  409. orm_addvar_int(ormid, pInfo[playerid][grouppid][8], "grouppid9");
  410. orm_addvar_int(ormid, pInfo[playerid][grouppid][9], "grouppid10");
  411. orm_addvar_int(ormid, pInfo[playerid][prID][0], "prID1");
  412. orm_addvar_int(ormid, pInfo[playerid][prID][1], "prID2");
  413. orm_addvar_int(ormid, pInfo[playerid][prID][2], "prID3");
  414. orm_addvar_int(ormid, pInfo[playerid][prID][3], "prID4");
  415. orm_addvar_int(ormid, pInfo[playerid][prID][4], "prID5");
  416. orm_addvar_int(ormid, pInfo[playerid][prID][5], "prID6");
  417. orm_addvar_int(ormid, pInfo[playerid][prID][6], "prID7");
  418. orm_addvar_int(ormid, pInfo[playerid][prID][7], "prID8");
  419. orm_addvar_int(ormid, pInfo[playerid][prID][8], "prID9");
  420. orm_addvar_int(ormid, pInfo[playerid][prID][9], "prID10");
  421. orm_addvar_int(ormid, pInfo[playerid][groupcontribution], "groupcontribution");
  422. orm_addvar_int(ormid, pInfo[playerid][gWarKills], "gWarKills");
  423. orm_addvar_int(ormid, pInfo[playerid][pGroups], "pGroups");
  424.  
  425. orm_setkey(ormid, "pName");
  426. orm_select(ormid, "LoadPlayerGroup", "d", playerid);
  427. return 1;
  428. }
  429.  
  430. public OnPlayerDisconnect(playerid,reason)
  431. {
  432. groupvariables[playerid][0] = -1;
  433. groupvariables[playerid][1] = 0;
  434. RankSelected[playerid] = -1;
  435. TempGroupID[playerid] = -1;
  436. if(pInfo[playerid][pID] != 0)
  437. {
  438. orm_update(pInfo[playerid][ORM_ID3]);
  439. }
  440. orm_destroy(pInfo[playerid][ORM_ID3]);
  441.  
  442. for(new playerDATA:e; e < playerDATA; ++e)
  443. pInfo[playerid][e] = 0;
  444. return 1;
  445. }
  446.  
  447. stock SendGroupMessage(color, groupID, string[])
  448. {
  449. foreach(new i : Player)
  450. {
  451. if(pInfo[i][grouppid][GroupLoopCheck(i, groupID)] == groupID)
  452. {
  453. SendClientMessage(i, color, string);
  454. }
  455. }
  456. return 1;
  457. }
  458.  
  459. forward RanksInformation();
  460. public RanksInformation()
  461. {
  462. for(new r=0; r < cache_num_rows(); ++r)
  463. {
  464. new ORM:ormid = RankInfo[r][ORM_ID2] = orm_create("ranks2", SQL);
  465.  
  466. orm_addvar_int(ormid, RankInfo[r][rID], "rID"); //this is the key
  467. orm_setkey(ormid, "rID"); //here we declare it as the key
  468. orm_addvar_string(ormid, RankInfo[r][rName],128, "rName");
  469. orm_addvar_int(ormid, RankInfo[r][rgID], "rgID");
  470. orm_addvar_int(ormid, RankInfo[r][rLevel], "rLevel");
  471. orm_addvar_int(ormid, RankInfo[r][rPermission][0], "rPermission1");
  472. orm_addvar_int(ormid, RankInfo[r][rPermission][1], "rPermission2");
  473. orm_addvar_int(ormid, RankInfo[r][rPermission][2], "rPermission3");
  474. orm_addvar_int(ormid, RankInfo[r][rPermission][3], "rPermission4");
  475. orm_addvar_int(ormid, RankInfo[r][rPermission][4], "rPermission5");
  476. orm_apply_cache(ormid, r);
  477. orm_select(ormid, "LoadGroupRank", "d", r);
  478. }
  479. return 1;
  480. }
  481.  
  482. forward LoadGroupRank(rid);
  483. public LoadGroupRank(rid)
  484. {
  485. switch(orm_errno(RankInfo[rid][ORM_ID2]))
  486. {
  487. case ERROR_OK:
  488. {
  489. Iter_Add(Ranks, rid);//active ranks
  490. }
  491. case ERROR_NO_DATA:
  492. {
  493. }
  494. }
  495. return 1;
  496. }
  497.  
  498. forward GroupsInformation();
  499. public GroupsInformation()
  500. {
  501. for(new r=0; r < cache_num_rows(); ++r)
  502. {
  503. new ORM:ormid = GroupInfo[r][ORM_ID] = orm_create("groups2", SQL);
  504.  
  505. orm_addvar_int(ormid, GroupInfo[r][gID], "gID"); //this is the key
  506. orm_setkey(ormid, "gID"); //here we declare it as the key
  507. orm_addvar_string(ormid, GroupInfo[r][gName],128, "gName");
  508. orm_addvar_string(ormid, GroupInfo[r][gLeaderName],32, "gLeaderName");
  509. orm_addvar_int(ormid, GroupInfo[r][gchat], "gchat");
  510. orm_addvar_int(ormid, GroupInfo[r][gCredits], "gCredits");
  511. orm_addvar_int(ormid, GroupInfo[r][gResources], "gResources");
  512. orm_addvar_int(ormid, GroupInfo[r][gWarWins], "gWarWins");
  513. orm_addvar_int(ormid, GroupInfo[r][gWarLosses], "gWarLosses");
  514. orm_addvar_int(ormid, GroupInfo[r][gDraws], "gDraws");
  515. orm_addvar_int(ormid, GroupInfo[r][gScore], "gScore");
  516. orm_apply_cache(ormid, r);
  517. orm_select(ormid, "LoadGroup", "d", r);
  518. }
  519. return 1;
  520. }
  521.  
  522. forward LoadGroup(gid);
  523. public LoadGroup(gid)
  524. {
  525. switch(orm_errno(GroupInfo[gid][ORM_ID]))
  526. {
  527. case ERROR_OK:
  528. {
  529. Iter_Add(Groups, gid);//active groups
  530. }
  531. case ERROR_NO_DATA:
  532. {
  533. }
  534. }
  535. return 1;
  536. }
  537.  
  538. forward MYSQL_SaveGroups(b);
  539. public MYSQL_SaveGroups(b)
  540. {
  541. if(GroupInfo[b][gID] != 0) {
  542. orm_update(GroupInfo[b][ORM_ID]);
  543. }
  544. return 1;
  545. }
  546.  
  547. forward GroupCreated(id, playerid, str[], playeridz);
  548. public GroupCreated(id, playerid, str[], playeridz)
  549. {
  550. orm_update(GroupInfo[id][ORM_ID]);
  551. GroupInfo[id][gchat] = 0;
  552. format(GroupInfo[id][gName],128,str);
  553. format(GroupInfo[id][gLeaderName],32,GetPlayerNamee(playerid));
  554. orm_save(GroupInfo[id][ORM_ID]);
  555. pInfo[playeridz][grouppid][pInfo[playeridz][pGroups]-1] = GroupInfo[id][gID];
  556. printf("New Group is created: [%d]", id);
  557. }
  558.  
  559. forward RankCreated(id, gid, name[], levl, playeridz);
  560. public RankCreated(id, gid, name[], levl, playeridz)
  561. {
  562. orm_update(RankInfo[id][ORM_ID2]);
  563. RankInfo[id][rgID] = GroupInfo[gid][gID];
  564. RankInfo[id][rLevel] = levl;
  565. format(RankInfo[id][rName],32,name);
  566. RankInfo[id][rPermission][0] = 1;
  567. RankInfo[id][rPermission][1] = 1;
  568. RankInfo[id][rPermission][2] = 1;
  569. RankInfo[id][rPermission][3] = 1;
  570. RankInfo[id][rPermission][4] = 1;
  571. orm_save(RankInfo[id][ORM_ID2]);
  572. pInfo[playeridz][prID][pInfo[playeridz][pGroups]-1] = RankInfo[id][rID];
  573. printf("New Rank is created for Group id:%d: [%d]",gid, id );
  574. }
  575.  
  576. forward RankCreated2(id, gid, name[], levl, playeridz);
  577. public RankCreated2(id, gid, name[], levl, playeridz)
  578. {
  579. orm_update(RankInfo[id][ORM_ID2]);
  580. RankInfo[id][rgID] = GroupInfo[gid][gID];
  581. RankInfo[id][rLevel] = levl;
  582. format(RankInfo[id][rName],32,name);
  583. RankInfo[id][rPermission][0] = 1;
  584. RankInfo[id][rPermission][1] = 1;
  585. RankInfo[id][rPermission][2] = 1;
  586. RankInfo[id][rPermission][3] = 1;
  587. RankInfo[id][rPermission][4] = 1;
  588. orm_save(RankInfo[id][ORM_ID2]);
  589. printf("New Rank is created for Group id:%d: [%d]",gid, id );
  590. }
  591.  
  592. stock GetPlayerNamee(playerid)
  593. {
  594. new name[MAX_PLAYER_NAME];
  595. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  596. return name;
  597. }
  598.  
  599.  
  600. //===========================[Commands]=========================================
  601. CMD:grouphelp(playerid,params[])
  602. {
  603. SCM(playerid,COLOR_GREY,"Group Commands");
  604. SCM(playerid,COLOR_GREY,"/groups /groupinfo(ID) /creategroup /groupinvite /g /groupkick /groupranks");
  605. SCM(playerid,COLOR_GREY,"/GroupEditRank /GroupSetRank /gChatLock");
  606. return 1;
  607. }
  608.  
  609. CMD:groups(playerid,params[])
  610. {
  611. if(Iter_Count(Groups) > 0)
  612. {
  613. foreach(new i : Groups)
  614. {
  615. new string[56];
  616. format(string,sizeof(string),"Groups:[%d]%s",i,GroupInfo[i][gName]);
  617. SCM(playerid,COLOR_GREEN,string);
  618. }
  619. }
  620. else
  621. {
  622. SCM(playerid,COLOR_RED,"ERROR: No groups were found.");
  623. }
  624. return 1;
  625. }
  626.  
  627. CMD:groupinfoid(playerid, params[])
  628. {
  629. new id, string[250];
  630. if(sscanf(params, "i", id)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupInfoID [Group ID]");
  631. else if(!Iter_Contains(Groups, id)) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
  632. else
  633. {
  634. format(string,sizeof(string),"Group[%d]:%s\nLeader:%s\nGroup Score:%d\nWar Wins:%d\nWar Losses:%d\nDraws:%d\nCredits:%d\nResources:%d\n",
  635. GroupInfo[id][gID],
  636. GroupInfo[id][gName],
  637. GroupInfo[id][gLeaderName],
  638. GroupInfo[id][gScore],
  639. GroupInfo[id][gWarWins],
  640. GroupInfo[id][gWarLosses],
  641. GroupInfo[id][gDraws],
  642. GroupInfo[id][gCredits],
  643. GroupInfo[id][gResources]);
  644. }
  645. return ShowDialog(playerid, Show:GroupInfoDialog, DIALOG_STYLE_MSGBOX, "{808080}Group Info", string, "Close", "");
  646. }
  647.  
  648. CMD:groupinfo(playerid, params[])
  649. {
  650. new str[128], string[250];
  651. if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupInfo [Group Name]");
  652. else if(IsGroupNameTaken(str) == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]: Group Does not exist");
  653. else
  654. {
  655. new i = GetGroupID(str);
  656. format(string,sizeof(string),"Group[%d]:%s\nLeader:%s\nGroup Score:%d\nWar Wins:%d\nWar Losses:%d\nDraws:%d\nCredits:%d\nResources:%d\n",
  657. GroupInfo[i][gID],
  658. GroupInfo[i][gName],
  659. GroupInfo[i][gLeaderName],
  660. GroupInfo[i][gScore],
  661. GroupInfo[i][gWarWins],
  662. GroupInfo[i][gWarLosses],
  663. GroupInfo[i][gDraws],
  664. GroupInfo[i][gCredits],
  665. GroupInfo[i][gResources]);
  666. }
  667. return ShowDialog(playerid, Show:GroupInfoDialog, DIALOG_STYLE_MSGBOX, "{808080}Group Info", string, "Close", "");
  668. }
  669.  
  670. CMD:creategroup(playerid, params[])
  671. {
  672. new player,str[128];
  673. if(!IsPlayerAdmin(playerid)) return 0;
  674. if(sscanf(params, "us[128]", player, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /creategroup [Player ID/Player Name] [Group Name]");
  675. if(!IsPlayerConnected(player)) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Player hasn't connected to server yet.");
  676. if(pInfo[player][pGroups] == 10) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Player's Max Group Limit Reached.");
  677. if(IsGroupNameTaken(str) == 1) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Group Name is already taken.");
  678.  
  679. pInfo[playerid][pGroups] += 1;
  680. new i = Iter_Free(Groups);
  681. Iter_Add(Groups, i);
  682.  
  683. new ORM:ormid1 = GroupInfo[i][ORM_ID] = orm_create("groups2", SQL);
  684. orm_addvar_int(ormid1, GroupInfo[i][gID], "gID"); //this is the key
  685. orm_setkey(ormid1, "gID"); //here we declare it as the key
  686. orm_addvar_string(ormid1, GroupInfo[i][gName],128, "gName");
  687. orm_addvar_string(ormid1, GroupInfo[i][gLeaderName],32, "gLeaderName");
  688. orm_addvar_int(ormid1, GroupInfo[i][gchat], "gchat");
  689. orm_addvar_int(ormid1, GroupInfo[i][gCredits], "gCredits");
  690. orm_addvar_int(ormid1, GroupInfo[i][gResources], "gResources");
  691. orm_addvar_int(ormid1, GroupInfo[i][gWarWins], "gWarWins");
  692. orm_addvar_int(ormid1, GroupInfo[i][gWarLosses], "gWarLosses");
  693. orm_addvar_int(ormid1, GroupInfo[i][gDraws], "gDraws");
  694. orm_addvar_int(ormid1, GroupInfo[i][gScore], "gScore");
  695. orm_apply_cache(ormid1, i);
  696. orm_insert(GroupInfo[i][ORM_ID], "GroupCreated", "ddsi", i, player, str, player);
  697. new string[158];
  698. format(string,sizeof(string),"[SUCCESS]: '%s' named group has been created for '%s'.",str,GetPlayerNamee(playerid));
  699. SendClientMessage(playerid,COLOR_GREEN,string);
  700.  
  701. new o = Iter_Free(Ranks);
  702. Iter_Add(Ranks, o);
  703. new ORM:ormid = RankInfo[o][ORM_ID2] = orm_create("ranks2", SQL);
  704. orm_addvar_int(ormid, RankInfo[o][rID], "rID"); //this is the key
  705. orm_setkey(ormid, "rID"); //here we declare it as the key
  706. orm_addvar_string(ormid, RankInfo[o][rName],128, "rName");
  707. orm_addvar_int(ormid, RankInfo[o][rgID], "rgID");
  708. orm_addvar_int(ormid, RankInfo[o][rLevel], "rLevel");
  709. orm_addvar_int(ormid, RankInfo[o][rPermission][0], "rPermission1");
  710. orm_addvar_int(ormid, RankInfo[o][rPermission][1], "rPermission2");
  711. orm_addvar_int(ormid, RankInfo[o][rPermission][2], "rPermission3");
  712. orm_addvar_int(ormid, RankInfo[o][rPermission][3], "rPermission4");
  713. orm_addvar_int(ormid, RankInfo[o][rPermission][4], "rPermission5");
  714. orm_apply_cache(ormid, o);
  715. orm_insert(RankInfo[o][ORM_ID2], "RankCreated", "ddsdi", o, i, "Leader", 100, player);
  716. return 1;
  717. }
  718.  
  719. CMD:groupinvite(playerid, params[])
  720. {
  721. new grpname[128],player, str[158];
  722. if(sscanf(params, "s[128]u",grpname,player)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /groupinvite [Group Name] [Player ID]");
  723. {
  724. new i = GetGroupID(grpname);
  725. if(i != -1)
  726. {
  727. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  728. else if(CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is already in your group.");
  729. else if(pInfo[player][pGroups] == 10) return SCM(playerid,COLOR_RED,"Player max group limit reached.");
  730. else if(!CheckPlayerGroupPermission(playerid, i, 1)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  731. else
  732. {
  733. groupvariables[player][0] = playerid;
  734. groupvariables[player][1] = i;
  735. format(str,sizeof(str),"'%s' named group member is inviting you to '%s' named group, what is your answer?",GetPlayerNamee(playerid),GroupInfo[i][gName]);
  736. ShowDialog(player, Show:GInviteDialog, DIALOG_STYLE_MSGBOX, "{808080}Group System", str, "Accept", "Decline");
  737. }
  738. }
  739. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  740. }
  741. return 1;
  742. }
  743.  
  744. CMD:g(playerid,params[])
  745. {
  746. new grpname[128],str[128];
  747. if(sscanf(params, "s[128]s[128]",grpname,str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /g [Group Name] [Chat]");
  748. {
  749. new i = GetGroupID(grpname);
  750. if(i != -1)
  751. {
  752. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  753. else if(!CheckPlayerGroupPermission(playerid, i, 0)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  754. else
  755. {
  756. new string[128];
  757. format(string,sizeof(string),"[%s][%s(%d)]:{FFFFFF}%s.",GroupInfo[i][gName],GetPlayerNamee(playerid),playerid,str);
  758. SendGroupMessage(COLOR_GREEN,i,string);
  759. }
  760. }
  761. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  762. }
  763. return 1;
  764. }
  765.  
  766. CMD:groupkick(playerid, params[])
  767. {
  768. new grpname[128],player, str[158];
  769. if(sscanf(params, "s[128]u",grpname,player)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /groupkick [Group Name] [Player ID]");
  770. {
  771. new i = GetGroupID(grpname);
  772. if(i != -1)
  773. {
  774. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  775. else if(!CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is not in your group.");
  776. else if(!CheckPlayerGroupPermission(playerid, i, 2)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  777. else if(ReturnGroupLevel(playerid, i) < ReturnGroupLevel(player, i)) return SCM(playerid,COLOR_RED,"You cannot kick your seniors.");
  778. else
  779. {
  780. format(str,sizeof(str),"[%s]:%s(%d) has been kicked from the group.",grpname,GetPlayerNamee(player),player);
  781. SendGroupMessage(COLOR_RED,pInfo[playerid][grouppid][i],str);
  782. pInfo[player][grouppid][GroupLoopCheck(playerid, i)] = -1;
  783. pInfo[player][prID][GroupLoopCheck(playerid, i)] = -1;
  784. }
  785. }
  786. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  787. }
  788. return 1;
  789. }
  790.  
  791. stock Name(playerid)
  792. {
  793. new name[MAX_PLAYER_NAME];
  794. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  795. return name;
  796. }
  797.  
  798. stock GetID(const name[])
  799. {
  800. foreach(new i : Player)
  801. {
  802. if(!strcmp(name, Name(i)))
  803. return i;
  804. }
  805. return -1;
  806. }
  807.  
  808. IsGroupNameTaken(grpname[])
  809. {
  810. foreach(new x : Groups)
  811. {
  812. if(!strcmp(grpname, GroupInfo[x][gName], true) && strlen(GroupInfo[x][gName]) != 0) return 1;
  813. }
  814. return 0;
  815. }
  816.  
  817. CMD:groupranks(playerid, params[])
  818. {
  819. new grpname[128];
  820. if(sscanf(params, "s[128]",grpname)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /groupranks [Group Name]");
  821. {
  822. foreach(new l : Groups)
  823. {
  824. if(!strcmp(grpname, GroupInfo[l][gName], true))
  825. {
  826. new i = pInfo[playerid][grouppid][i];
  827. if(i != -1)
  828. {
  829. new query[1256];
  830. mysql_format(SQL, query, sizeof(query), "SELECT * FROM `ranks2` WHERE `rgID` = %d ORDER BY `rLevel` DESC", GroupInfo[i][gID]);
  831. mysql_query(SQL, query, true);
  832. format(query, sizeof(query), "{FFFFFF}");
  833. new count = cache_num_rows();
  834. if(count > 0)
  835. {
  836. for(new r = 0; r < count; r++)
  837. {
  838. new Rank[32], Level[2];
  839. cache_get_field_content(r, "rName", Rank);
  840. cache_get_field_content(r, "rLevel", Level);
  841. format(query, sizeof(query), "(%d)%s(Level:%s)\n",(r+1),Rank,Level);
  842. }
  843. ShowDialog(playerid, Show:groupDialog, DIALOG_STYLE_TABLIST, "Group Ranks", query, "Close", "");
  844. }
  845. }
  846. break;
  847. }
  848. }
  849. }
  850. return 1;
  851. }
  852.  
  853. CMD:groupcreaterank(playerid,params[])
  854. {
  855. new grpname[128],str[32], level;
  856. if(sscanf(params, "s[128]s[32]i",grpname, str, level)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupCreateRank [Group Name] [New Rank Name] [Level]");
  857. else if(level < 100 && level > 0)
  858. {
  859. new i = GetGroupID(grpname);
  860. if(i != -1)
  861. {
  862. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  863. else if(!CheckPlayerGroupPermission(playerid, i, 4)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  864. else if(ReturnGroupLevel(playerid, i) < level) return SCM(playerid,COLOR_RED,"Rank must be of lower level to that of yours.");
  865. else
  866. {
  867. new o = Iter_Free(Ranks);
  868. Iter_Add(Ranks, o);
  869. new ORM:ormid = RankInfo[o][ORM_ID2] = orm_create("ranks2", SQL);
  870. orm_addvar_int(ormid, RankInfo[o][rID], "rID"); //this is the key
  871. orm_setkey(ormid, "rID"); //here we declare it as the key
  872. orm_addvar_string(ormid, RankInfo[o][rName],128, "rName");
  873. orm_addvar_int(ormid, RankInfo[o][rgID], "rgID");
  874. orm_addvar_int(ormid, RankInfo[o][rLevel], "rLevel");
  875. orm_addvar_int(ormid, RankInfo[o][rPermission][0], "rPermission1");
  876. orm_addvar_int(ormid, RankInfo[o][rPermission][1], "rPermission2");
  877. orm_addvar_int(ormid, RankInfo[o][rPermission][2], "rPermission3");
  878. orm_addvar_int(ormid, RankInfo[o][rPermission][3], "rPermission4");
  879. orm_addvar_int(ormid, RankInfo[o][rPermission][4], "rPermission5");
  880. orm_apply_cache(ormid, o);
  881. orm_insert(RankInfo[o][ORM_ID2], "RankCreated2", "ddsd", o, i, str, level);
  882.  
  883. new string[158];
  884. format(string,sizeof(string),"[%s]: Successfully created the rank %s(Level:%d).",grpname,str,level);
  885. SendGroupMessage(COLOR_GREEN,pInfo[playerid][grouppid][i],string);
  886. }
  887. }
  888. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  889. }
  890. else return SCM(playerid,COLOR_RED,"Level limit is between 0 to 100.");
  891. return 1;
  892. }
  893.  
  894. CMD:groupeditrank(playerid,params[])
  895. {
  896. new grpname[128],str[32];
  897. if(sscanf(params, "s[128]s[32]",grpname, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupEditRank [Group Name] [Rank Name]");
  898. else
  899. {
  900. new i = GetGroupID(grpname);
  901. if(i != -1)
  902. {
  903. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  904. else if(!CheckPlayerGroupPermission(playerid, i, 4)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  905. else
  906. {
  907. foreach(new rn : Ranks)
  908. {
  909. if(RankInfo[rn][rID] == pInfo[playerid][prID][GroupLoopCheck(playerid,i)] && RankInfo[rn][rgID] == i && !strcmp(RankInfo[rn][rName], str,true))
  910. {
  911. if(ReturnGroupLevel(playerid, i) < RankInfo[rn][rLevel]) return SCM(playerid,COLOR_RED,"Rank must be of lower level to that of yours.");
  912. else
  913. {
  914. RankSelected[playerid] = rn;
  915. TempGroupID[playerid] = i;
  916. ShowRankEditingMenu(playerid, rn);
  917. break;
  918. }
  919. }
  920. else if(i == Iter_Last(Ranks))
  921. {
  922. SCM(playerid,COLOR_RED,"Invalid Rank.");
  923. }
  924. }
  925. }
  926. }
  927. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  928. }
  929. return 1;
  930. }
  931.  
  932. CMD:groupsetrank(playerid,params[])
  933. {
  934. new grpname[128],str[32], player;
  935. if(sscanf(params, "us[128]s[32]",player, grpname, str)) return SendClientMessage(playerid,COLOR_GREY,"[USAGE]: /GroupSetRank [playerid] [Group Name] [Rank Name]");
  936. else
  937. {
  938. new i = GetGroupID(grpname);
  939. if(i != -1)
  940. {
  941. if(!CheckPlayerGroup(playerid, i)) return SCM(playerid,COLOR_RED,"You are not the member of that group.");
  942. else if(!CheckPlayerGroup(player, i)) return SCM(playerid,COLOR_RED,"Player is not in your group.");
  943. else if(!CheckPlayerGroupPermission(playerid, i, 3)) return SCM(playerid,COLOR_RED,"You Do not have the permission to use this command.");
  944. else if(ReturnGroupLevel(playerid, i) < ReturnGroupLevel(player, i)) return SCM(playerid,COLOR_RED,"You cannot boss your seniors.");
  945. else
  946. {
  947. foreach(new rn : Ranks)
  948. {
  949. if(RankInfo[rn][rID] == pInfo[playerid][prID][GroupLoopCheck(playerid,i)] && RankInfo[rn][rgID] == i)
  950. {
  951. pInfo[player][prID][GroupLoopCheck(playerid, i)] = RankInfo[rn][rID];
  952. new string[158];
  953. format(string,sizeof(string),"[%s]:Rank of %s(%d) has been changed to %s.",grpname,GetPlayerNamee(player),player,str);
  954. SendGroupMessage(COLOR_GREEN,pInfo[playerid][grouppid][i],string);
  955. break;
  956. }
  957. else if(i == Iter_Last(Ranks))
  958. {
  959. SCM(playerid,COLOR_RED,"Invalid Rank.");
  960. }
  961. }
  962. }
  963. }
  964. else return SCM(playerid,COLOR_RED,"Group Does not exists.");
  965. }
  966. return 1;
  967. }
  968. CMD:gchatlock(playerid,params[])
  969. {
  970. new str[128],id=pInfo[playerid][grouppid];
  971. if(strcmp(GroupInfo[id][gLeaderName], GetPlayerNamee(playerid)) != 0) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: You are not a leader of any group.");
  972. if(GroupInfo[id][gchat] == 0)
  973. {
  974. GroupInfo[id][gchat] = 1;
  975. format(str,sizeof(str),"[GROUP-ATTENTION(%s)]: %s named group leader has locked the group chat.",GroupInfo[id][gName],GetPlayerNamee(playerid));
  976. SendGroupMessage(0x8080FFFF, id, str);
  977. return 1;
  978. }
  979. if(GroupInfo[id][gchat] == 1)
  980. {
  981. GroupInfo[id][gchat] = 0;
  982. format(str,sizeof(str),"[GROUP-ATTENTION(%s)]: %s named group leader has unlocked the group chat.",GroupInfo[id][gName],GetPlayerNamee(playerid));
  983. SendGroupMessage(0x8080FFFF, id, str);
  984. return 1;
  985. }
  986. return 1;
  987. }
  988. //=========================================================================[END]
  989.  
  990. Dialog:GInviteDialog(playerid, dialogid, response, listitem, inputtext[])
  991. {
  992. new str[128];
  993. if(!response)
  994. {
  995. format(str,sizeof(str),"[SYSTEM]: '%s' has declined your invite.",GetPlayerNamee(playerid));
  996. SendClientMessage(groupvariables[playerid][0],COLOR_RED,str);
  997. SendClientMessage(playerid,COLOR_RED,"[SERVER]: You have declined the invite.");
  998. groupvariables[playerid][0] = -1;
  999. groupvariables[playerid][1] = 0;
  1000. }
  1001. if(response)
  1002. {
  1003. format(str,sizeof(str),"[SYSTEM]: '%s' has accepted your invite.",GetPlayerNamee(playerid));
  1004. SendClientMessage(groupvariables[playerid][0],COLOR_GREEN,str);
  1005. SendClientMessage(playerid,COLOR_RED,"[SERVER]: You have accepted the invite.");
  1006. pInfo[playerid][grouppid][pInfo[playerid][pGroups]-1] = groupvariables[playerid][1];
  1007. groupvariables[playerid][0] = -1;
  1008. groupvariables[playerid][1] = 0;
  1009. }
  1010. return 1;
  1011. }
  1012.  
  1013. Dialog:GroupEditRank(playerid, dialogid, response, listitem, inputtext[])
  1014. {
  1015. if(!response)
  1016. {
  1017. return 0;
  1018. }
  1019. else if(response)
  1020. {
  1021. switch(listitem)
  1022. {
  1023. case 0:
  1024. {
  1025. ShowDialog(playerid,Show:RankNameChange,DIALOG_STYLE_INPUT,"Change Rank Name","Are you Sure about changing rank name?","Change","No");
  1026. }
  1027. case 1:
  1028. {
  1029. ShowDialog(playerid,Show:RankLevelChange,DIALOG_STYLE_INPUT,"Change Rank Level","Are you Sure about changing rank level?","Change","No");
  1030. }
  1031. case 2:
  1032. {
  1033. if(RankInfo[RankSelected[playerid]][rPermission][0] == 1)
  1034. {
  1035. RankInfo[RankSelected[playerid]][rPermission][0] = 0;
  1036. }
  1037. else
  1038. {
  1039. RankInfo[RankSelected[playerid]][rPermission][0] = 1;
  1040. }
  1041. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1042. }
  1043. case 3:
  1044. {
  1045. if(RankInfo[RankSelected[playerid]][rPermission][1] == 1)
  1046. {
  1047. RankInfo[RankSelected[playerid]][rPermission][1] = 0;
  1048. }
  1049. else
  1050. {
  1051. RankInfo[RankSelected[playerid]][rPermission][1] = 1;
  1052. }
  1053. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1054. }
  1055. case 4:
  1056. {
  1057. if(RankInfo[RankSelected[playerid]][rPermission][2] == 1)
  1058. {
  1059. RankInfo[RankSelected[playerid]][rPermission][2] = 0;
  1060. }
  1061. else
  1062. {
  1063. RankInfo[RankSelected[playerid]][rPermission][2] = 1;
  1064. }
  1065. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1066. }
  1067. case 5:
  1068. {
  1069. if(RankInfo[RankSelected[playerid]][rPermission][3] == 1)
  1070. {
  1071. RankInfo[RankSelected[playerid]][rPermission][3] = 0;
  1072. }
  1073. else
  1074. {
  1075. RankInfo[RankSelected[playerid]][rPermission][3] = 1;
  1076. }
  1077. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1078. }
  1079. case 6:
  1080. {
  1081. if(RankInfo[RankSelected[playerid]][rPermission][4] == 1)
  1082. {
  1083. RankInfo[RankSelected[playerid]][rPermission][4] = 0;
  1084. }
  1085. else
  1086. {
  1087. RankInfo[RankSelected[playerid]][rPermission][4] = 1;
  1088. }
  1089. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1090. }
  1091. }
  1092. }
  1093. return 1;
  1094. }
  1095.  
  1096. Dialog:RankNameChange(playerid, dialogid, response, listitem, inputtext[])
  1097. {
  1098. if(!response)
  1099. {
  1100. return ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1101. }
  1102. else if(response)
  1103. {
  1104. strcat(RankInfo[RankSelected[playerid]][rName],inputtext);
  1105. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1106. }
  1107. return 1;
  1108. }
  1109.  
  1110. Dialog:RankLevelChange(playerid, dialogid, response, listitem, inputtext[])
  1111. {
  1112. if(!response)
  1113. {
  1114. return ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1115. }
  1116. else if(response)
  1117. {
  1118. new level = strval(inputtext);
  1119. if(level > 100 || level < 1)
  1120. {
  1121. ShowDialog(playerid,Show:RankLevelChange,DIALOG_STYLE_INPUT,"Change Rank Level","Rank level should be between 1 to 100.","Change","No");
  1122. }
  1123. else
  1124. {
  1125. RankInfo[RankSelected[playerid]][rLevel] = level;
  1126. ShowRankEditingMenu(playerid, RankSelected[playerid]);
  1127. }
  1128. }
  1129. return 1;
  1130. }
Add Comment
Please, Sign In to add comment