Guest User

Untitled

a guest
Jul 12th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.56 KB | None | 0 0
  1. /* Functions
  2. *
  3. * doClearParty( Account);
  4. * ** Clears the party strings, incase of errors
  5. *
  6. * doPurgeParty( [Party]);
  7. * ** Clears all members of a party
  8. * ** If party is left blank,
  9. * ** It clears all parties, and all members from it
  10. *
  11. * doCreateParty( Account);
  12. * ** Creates a party. With the leader Account
  13. *
  14. * doJoinParty( Party, Account);
  15. * ** Joins Account to Party.
  16. * ** If Party is not a 'Raid'
  17. * ** Party limit is 6. Else, its 20
  18. *
  19. * doLeaveParty( Party, Account);
  20. * ** Removes Account from Party
  21. * ** If the player was the last player in the party
  22. * ** The Party will automatically be purged.
  23. * ** If the player was the leader of the party
  24. * ** The leader will be passed.
  25. * ** It will pass to the person on the top of the list
  26. * ** Or if the leader was on the top, the second from.
  27. *
  28. * doPassLeader( Party, curLeader, nxtLeader);
  29. * ** Pass leader from curLeader to nxtLeader in Party.
  30. * ** curLeader must match the current leader.
  31. * ** nxtLeader must be in the party, and exist.
  32. */
  33.  
  34. function onCreated()
  35. {
  36. // doClearParty( "Admin-Playerworld71");
  37. //doPurgeParty( "");
  38. // findPlayer("Hotrian").clientr.party = "";
  39. // doCreateParty( "Hotrian");
  40. // doJoinParty( 1, "AznLaoGuy");
  41. // doJoinParty( 1, "Admin-Playerworld71");
  42. // doJoinParty( 1, "monolord");
  43. // doJoinParty( 1, "slaytoda");
  44. // doJoinParty( 3, "Drastic Vendetta");
  45. //doLeaveParty( 1, "MysticalDragon", "kicked");
  46. //doPassLeader( 1, "Hotrian", "Admin-Playerworld71");
  47.  
  48. this._StaySilent = false;
  49.  
  50. }
  51.  
  52. public function doPassLeader( pty, ldr, pl)
  53. {
  54. if ( this.("Parties_"@temp.pty@"_Leader") == temp.ldr )
  55. {
  56. temp.ind = "NOTHERE";
  57. for (temp.pt : this.("Parties_"@temp.pty)[1])
  58. {
  59. if ( temp.pt[0] == temp.pl )
  60. {
  61. temp.ind = this.("Parties_"@temp.pty)[1].index(@temp.pt);
  62.  
  63. break;
  64. }
  65. }
  66. if (temp.ind == "NOTHERE")
  67. {
  68. if ( !this._StaySilent) printf("[ %s ]: %s Was not in %s", name, temp.pl, temp.pty);
  69. return false;
  70. }
  71.  
  72. this.("Parties_"@temp.pty@"_Leader") = temp.pl;
  73. }
  74.  
  75. }
  76.  
  77. public function doJoinParty( pty, pl)
  78. {
  79.  
  80. p = findPlayer(@temp.pl);
  81. if (p.clientr.party[0] != NULL && p.clientr.party[0] != 0 && p.clientr.party[0] != "")
  82. { /* The player is in a party already! */
  83. if ( !this._StaySilent) printf("[ %s ]: %s is already in a party, %s.", name, temp.pl, p.clientr.party[0]);
  84. return false;
  85. }
  86.  
  87. if (temp.pty == NULL || p == NULL || temp.pl == NULL)
  88. { /* The player is offline */
  89. if (p == NULL)
  90. {
  91. if ( !this._StaySilent) printf("[ %s ]: %s is not online.", name, temp.pl, temp.pty);
  92. } else printf("[ %s ]: %s didnt specify a party to join.", name, temp.pl, temp.pty);
  93. return false;
  94. }
  95.  
  96. if ( this.("Parties_"@temp.pty@"_Leader") == NULL )
  97. {
  98. if ( !this._StaySilent) printf("[ %s ]: %s Tried to join %s But no one was in that party.", name, temp.pl, temp.pty);
  99. return false;
  100. }
  101.  
  102. if ( this.("Parties_"@temp.pty)[0] == "Party") temp.ptylimit = 6;
  103. else if ( this.("Parties_"@temp.pty)[0] == "Raid") temp.ptylimit = 20;
  104. if (this.("Parties_"@temp.pty)[1].size() < temp.ptylimit)
  105. {
  106. temp.array = { temp.pl, p.client.profile_health, p.client.profile_magic, p.headimg, p.attr[1], p.nick};
  107. this.("Parties_"@temp.pty)[1].add( @temp.array);
  108. if ( !this._StaySilent) printf("[ %s ]: %s Joined %s", name, temp.pl, temp.pty);
  109. p.clientr.party = { temp.pty, this.("Parties_"@temp.pty)};
  110. p.clientr.partyleader = this.("Parties_"@temp.pty@"_Leader");
  111. }
  112.  
  113. if (!contains( p.joinedclasses, "h_party")) { p.join("h_party"); echo(p SPC "didn't join h_party; Joined him."); }
  114.  
  115. p.addweapon( "-System/Party");
  116. }
  117.  
  118. public function doLeaveParty( pty, pl)
  119. {
  120.  
  121. p = findPlayer(@temp.pl);
  122. if (temp.pty == NULL || p == NULL || temp.pl == NULL)
  123. {
  124.  
  125. if (p == NULL) {
  126. if ( !this._StaySilent) printf("[ %s ]: %s is not online.", name, temp.pl, temp.pty);
  127. } else if ( !this._StaySilent) printf("[ %s ]: %s didnt specify a party to leave.", name, temp.pl, temp.pty);
  128. return false;
  129. }
  130.  
  131.  
  132. temp.ind = "NOTHERE";
  133. for (temp.pt : this.("Parties_"@temp.pty)[1])
  134. {
  135. if ( temp.pt[0] == temp.pl )
  136. {
  137. temp.ind = this.("Parties_"@temp.pty)[1].index(@temp.pt);
  138.  
  139. break;
  140. }
  141. }
  142. if (temp.ind == "NOTHERE")
  143. {
  144. if ( !this._StaySilent) printf("[ %s ]: %s Was not in %s", name, temp.pl, temp.pty);
  145. return false;
  146. }
  147. if ( !this._StaySilent) printf("[ %s ]: %s Left %s", name, temp.pl, temp.pty);
  148. p.clientr.party = NULL;
  149. p.clientr.partyleader = NULL;
  150.  
  151. if (this.("Parties_"@temp.pty)[1].size() > 1)
  152. {
  153. this.("Parties_"@temp.pty)[1].delete(temp.ind);
  154. } else {
  155. if ( !this._StaySilent) printf( "[ %s ]: (S)he was the last member, So the party was deleted.", name);
  156. this.("Parties_"@temp.pty) = new[0];
  157. this.("Parties_"@temp.pty@"_Leader") = NULL;
  158. return true;
  159. }
  160. if (this.("Parties_"@temp.pty@"_Leader") == temp.pl)
  161. {
  162.  
  163. if ( !this._StaySilent) printf("[ %s ]: %s Was the leader of %s", name, temp.pl, temp.pty);
  164. this.("Parties_"@temp.pty@"_Leader") = this.("Parties_"@temp.pty)[1][0][0];
  165.  
  166. if ( !this._StaySilent) printf("[ %s ]: Leader passed to %s", name, this.("Parties_"@temp.pty@"_Leader"));
  167.  
  168. }
  169.  
  170. }
  171.  
  172. public function doKickfromParty( pty, pl, placct)
  173. {
  174. if (this.("Parties_"@temp.pty@"_Leader") != temp.placct)
  175. {
  176.  
  177. if ( !this._StaySilent) printf("[ %s ]: %s Tried to kick %s from %s but was not the leader.", name, temp.placct, temp.pl, temp.pty);
  178. return false;
  179. }
  180.  
  181. p = findPlayer(@temp.pl);
  182. if (temp.pty == NULL || p == NULL || temp.pl == NULL)
  183. {
  184. if (p == NULL)
  185. if ( !this._StaySilent) printf("[ %s ]: %s is not online.", name, temp.pl, temp.pty);
  186. return false;
  187. }
  188.  
  189.  
  190. temp.ind = "NOTHERE";
  191. for (temp.pt : this.("Parties_"@temp.pty)[1])
  192. {
  193. if ( temp.pt[0] == temp.pl )
  194. {
  195. temp.ind = this.("Parties_"@temp.pty)[1].index(@temp.pt);
  196.  
  197. break;
  198. }
  199. }
  200. if (temp.ind == "NOTHERE")
  201. {
  202. if ( !this._StaySilent) printf("[ %s ]: %s Was not in %s to be kicked from.", name, temp.pl, temp.pty);
  203. return false;
  204. }
  205.  
  206. if ( !this._StaySilent) printf("[ %s ]: %s was kicked from %s", name, temp.pl, temp.pty);
  207. p.clientr.party = NULL;
  208. p.clientr.partyleader = NULL;
  209.  
  210. if (this.("Parties_"@temp.pty)[1].size() > 1)
  211. {
  212. this.("Parties_"@temp.pty)[1].delete(temp.ind);
  213. } else {
  214. if ( !this._StaySilent) printf( "[ %s ]: (S)he was the last member, So the party was deleted.", name);
  215. this.("Parties_"@temp.pty) = new[0];
  216. this.("Parties_"@temp.pty@"_Leader") = NULL;
  217. return true;
  218. }
  219.  
  220. if (this.("Parties_"@temp.pty@"_Leader") == temp.placct)
  221. {
  222.  
  223. if ( !this._StaySilent) printf("[ %s ]: %s Was the leader of %s", name, temp.pl, temp.pty);
  224. this.("Parties_"@temp.pty@"_Leader") = this.("Parties_"@temp.pty)[1][0][0];
  225.  
  226. if ( !this._StaySilent) printf("[ %s ]: Leader passed to %s", name, this.("Parties_"@temp.pty@"_Leader"));
  227.  
  228. }
  229.  
  230.  
  231. }
  232.  
  233. public function doCreateParty( pl)
  234. {
  235. p = findPlayer(@temp.pl);
  236. if (p.clientr.party[0] != NULL && p.clientr.party[0] != 0 && p.clientr.party[0] != "")
  237. { /* The player is in a a party already! */
  238. if ( !this._StaySilent) printf("[ %s ]: %s is already in a party, %s.", name, temp.pl, p.clientr.party[0]);
  239. return false;
  240. }
  241. thiso._NextParty ++;
  242.  
  243. if ( p == NULL || temp.pl == NULL ) return false;
  244. this.("Parties_"@thiso._NextParty@"_Leader") = pl;
  245. this.("Parties_"@thiso._NextParty) = { "Party", {{ temp.pl, p.client.profile_health, p.client.profile_magic, p.headimg, p.attr[1], p.nick}}};
  246. p.clientr.party = { thiso._NextParty, this.("Parties_"@thiso._NextParty)};
  247. p.clientr.partyleader = this.("Parties_"@thiso._NextParty@"_Leader");
  248. if ( !this._StaySilent) printf("[ %s ]: Created: %s, Leader: %s", name, thiso._NextParty, temp.pl);
  249. if (!contains( p.joinedclasses, "h_party")) { p.join("h_party"); echo(p SPC "didn't join h_party; Joined him."); }
  250.  
  251. p.addweapon( "-System/Party");
  252. // p.clientr.party = {"a", { "a", { "a", "b", "a", "b", }}}
  253.  
  254. }
  255.  
  256. public function doUpdateStats( pty, pl, hp, mp, head, hat, nick)
  257. {
  258. thiso.inparty = false;
  259. for (temp.pt : this.("Parties_"@temp.pty)[1])
  260. {
  261. if ( temp.pt[0] == temp.pl )
  262. {
  263. thiso.inparty = true;
  264. temp.ind = this.("Parties_"@temp.pty)[1].index(@temp.pt);
  265. this.("Parties_"@temp.pty)[1][temp.ind][1] = temp.hp;
  266. this.("Parties_"@temp.pty)[1][temp.ind][2] = temp.mp;
  267. this.("Parties_"@temp.pty)[1][temp.ind][3] = temp.head;
  268. this.("Parties_"@temp.pty)[1][temp.ind][4] = temp.hat;
  269. this.("Parties_"@temp.pty)[1][temp.ind][5] = temp.nick;
  270. break;
  271. }
  272.  
  273. }
  274. if (thiso.inparty == false)
  275. {
  276. findPlayer(@temp.pl).clientr.party = NULL;
  277. findPlayer(@temp.pl).clientr.partyleader = NULL;
  278. return false;
  279. }
  280. findPlayer(@temp.pl).clientr.party = { temp.pty, this.("Parties_"@temp.pty)};
  281. findPlayer(@temp.pl).clientr.partyleader = this.("Parties_"@temp.pty@"_Leader");
  282. //printf("[ %s ]: %s sent new data: %s, %s, %s, %s, %s", name, temp.pl, temp.pty, temp.hp, temp.mp, temp.head, temp.hat);
  283.  
  284. }
  285.  
  286. public function doPurgeParty( pty)
  287. {
  288.  
  289. if (temp.pty != NULL && temp.pty != "All")
  290. {
  291. for (temp.pl : this.("Parties_"@temp.pty))
  292. {
  293. findPlayer(@temp.pl).clientr.party = NULL;
  294. }
  295. this.("Parties_"@temp.pty) = "";
  296.  
  297. }else
  298. {
  299. for (pl :allplayers) findplayer( @pl).clientr.party = NULL;
  300. thiso._NextParty = 0;
  301. for (temp.ptyy : getstringkeys("this.Parties_"))
  302. {
  303.  
  304. for (temp.pl : this.("Parties_"@temp.ptyy)[1])
  305. {
  306. printf( "[ %s ]: %s was in %s." , name, temp.pl[0], temp.ptyy);
  307. findPlayer(@temp.pl[0]).clientr.party = NULL;
  308. }
  309. this.("Parties_"@temp.ptyy) = "";
  310. this.("Parties_"@temp.ptyy@"_Leader") = "";
  311. }
  312. }
  313. temp.ptyn = (temp.pty == NULL || temp.pty == "All") ? "All Parties" : temp.pty;
  314. printf("[ %s ]: Purged: %s", name, temp.ptyn);
  315. }
  316.  
  317. public function doClearParty( acct)
  318. {
  319. if (temp.acct != NULL && temp.acct != "All")
  320. {
  321. findPlayer(@temp.acct).clientr.party = NULL;
  322.  
  323. }else
  324. {
  325. for (temp.pl : allplayers)
  326. {
  327. printf( "[ %s ]: %s was in a party." , name, temp.pl);
  328. findPlayer(@temp.acct).clientr.party = NULL;
  329. }
  330. }
  331. temp.ptyn = (temp.acct == NULL || temp.acct == "All") ? "All Players" : temp.acct;
  332. printf("[ %s ]: Purged: %s", name, temp.ptyn);
  333. }
Add Comment
Please, Sign In to add comment