Advertisement
Saihen

forkubix

Feb 13th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1. // -------------- PVP RATING (SQL ONLY)! ----------------- //
  2. // ---- by Kubix.
  3.  
  4. /*
  5. tables:
  6.  
  7. CREATE TABLE `pk_rating` (
  8. `id` INT(11) NOT NULL AUTO_INCREMENT,
  9. `char_id` varchar(30) NOT NULL,
  10. `kill_count` int(11) NOT NULL,
  11. `die_count` int(11) NOT NULL,
  12. `score` int(11) NOT NULL,
  13. `league` varchar(30) NOT NULL,
  14. PRIMARY KEY (`id`)
  15. );
  16.  
  17. */
  18.  
  19. - script PvP_FunctionS -1,{
  20.  
  21. OnPCKillEvent:
  22. getmapxy .@charmap$,.@x,.@y,0;
  23. if(strcharinfo(3) == "invek") end;
  24. for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){
  25. if(.@charmap$ == $Rating_Location$[.@i]){
  26. callfunc "Announcing"; // announce function
  27. callfunc "PKGetRating"; // rating function
  28. end;
  29. }
  30. }
  31. end;
  32.  
  33. OnMKReset: set @MultiKIll, 0;
  34. end;
  35. }
  36.  
  37.  
  38. - script PvP_FunctionSS -1,{
  39. OnPCDieEvent:
  40. if(strcharinfo(3) == "invek") end;
  41. if((killerrid == getcharid(0)) || (killerrid < 150000)) end;
  42. getmapxy .@charmap$,.@x,.@y,0;
  43. for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){
  44. if(.@charmap$ == $Rating_Location$[.@i]){
  45. if((killerrid == getcharid(0)) || (killerrid < 150000)) end;
  46. sleep2 500;
  47. deltimer "PvP_FunctionS::OnMKReset";
  48. if(@MultiKill > 0)set @MultiKill, 0;
  49. if(@KillingSpree > 0)set @KillingSpree, 0;
  50. if(@PKKills >0)set @PKKills, 0;
  51. callfunc "PKTakeRating"; //
  52. end;
  53. }
  54. }
  55. end;
  56. }
  57.  
  58. - script PvP_LogoutEvent -1,{
  59. OnPCLogoutEvent:
  60. if(strcharinfo(3) == "invek") end;
  61. getmapxy .@charmap$,.@x,.@y,0;
  62. for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){
  63. if(.@charmap$ == $Rating_Location$[.@i]){
  64. if(@MultiKill > 0)set @MultiKill, 0;
  65. if(@KillingSpree > 0)set @KillingSpree, 0;
  66. if(@PKKills >0)set @PKKills, 0;
  67. deltimer "PvP_FunctionS::OnMKReset";
  68. end;
  69. }
  70. }
  71. end;
  72. }
  73.  
  74. function script PKGetRating {
  75. set PKRatingF, 0;
  76. set @PKKills, @PKKills + 1;
  77. set PKRatingF, PKRatingF + 2 * (rand(2,3) + @PCKills);
  78. set MPKAcc, MPKAcc + 2 * (rand(2,3) + @PCKills); // rating
  79. set PCKills, PCKills + 1; // kills
  80. callfunc "PKLeagues";
  81. dispbottom "[PK Manager]: +[ "+PKRatingF+" ] rating.";
  82. query_sql "UPDATE `pk_rating` SET `kill_count` = '"+PCKills+"', `score` = '"+MPKAcc+"' WHERE `char_id` = '"+strcharinfo(0)+"'";
  83. end;
  84. }
  85.  
  86. function script PKTakeRating {
  87. set PKRatingF, 0; //
  88. set @PKDies, @PKDies + 1; //
  89. set PKRatingF, PKRatingF - 2 * (rand(2,3) + @PCDies);
  90. set MPKAcc, MPKAcc - 2 * (rand(2,3) + @PCDies); // rating
  91. set PCDies, PCDies + 1; // deaths
  92. callfunc "PKLeagues";
  93. dispbottom "[PK Manager]: [ "+PKRatingF+" ] rating.";
  94. query_sql "UPDATE `pk_rating` SET `die_count` = '"+PCDies+"', `score` = '"+MPKAcc+"' WHERE `char_id` = '"+strcharinfo(0)+"'";
  95. end;
  96. }
  97. // PK Top
  98. invek,153,161,4 script PvP Rating 4_EP16_LOUVIERE,{
  99. mes "[PK Manager]";
  100. mes "Can I help you??";
  101. mes "I can show players with rating more than 0";
  102. mes "Your Rating : " + MPKAcc;
  103. for(@i = 0; @i < getarraysize($LeagueName$); @i ++){
  104. if($LeagueName$[@i] != "") {
  105. if(MPKAcc > $MinRating[@i] && MPKAcc < $MaxRating[@i]) cutin $CutinName$[@i], 2;
  106. }
  107. }
  108. next;
  109. if(select("> PK TOP:> Cancel") == 2) {
  110. close2;
  111. cutin "", 255;
  112. end;
  113. }
  114. query_sql "SELECT `char_id`,`kill_count`,`die_count`,`score`,`league` FROM `pk_rating` ORDER BY `score` DESC LIMIT 10", .@cname$, .@kcount, .@dcount, .@rscore, .@leaguel$;
  115. mes "Name/Kills/Deaths/Score/Division";
  116. for(set .i, 0; .i < 10; set .i, .i + 1) {
  117. if(.@cname$[.i] != "" && .@rscore[.i] > 0) {
  118. mes "" + (.i+1) + ".^FF0000" + .@cname$[.i] + "^000000/" + .@kcount[.i] + "/" + .@dcount[.i] + "/^6699DD" + .@rscore[.i] + "^000000/^0000FF" + .@leaguel$[.i] + "^000000.";
  119. } else {
  120. mes (.i+1)+".Empty";
  121. }
  122. }
  123. close2;
  124. cutin "", 255;
  125. end;
  126.  
  127.  
  128. OnInit:
  129. // === Settings
  130. set $FirstBlood, 1;
  131. set $Sound, 1;
  132. set $Announce, 1;
  133. setarray $KS_Ann$[0],"IS ON A KILLING SPREE!!!","IS ON A RAMPAGE!!!","IS UNSTOPPABLE!!!","IS DOMINATING!!!","IS G-G-G-GODLIKE!!!","IS LEGENDARY!!!";
  134. setarray $MK_Ann$[0],"HAS SCORED A DOUBLE KILL!!!","HAS SCORED A TRIPLE KILL!!!","HAS SCORED A QUADRA KILL!!!","HAS SCORED A PENTA KILL!!!!";
  135. setarray $Rating_Location$[0], "pvp_n_5-5"; // add your locations
  136. setarray $LeagueName$[0], "Bronze","Silver","Gold","Platinum","Diamond"; // add you divisions
  137. setarray $MinRating[0], 0, 1300, 1600, 1900, 2200; // min. rating for division
  138. setarray $MaxRating[0], 1299, 1599, 1899, 2199, 100000; // max. rating for division
  139. setarray $CutinName$[0], "1-1","2-1","3-1","4-1","5-1"; // cutin names for divisions
  140. // === end of settings
  141.  
  142. while(1) {
  143. query_sql "SELECT `char_id`,`score` FROM `pk_rating` ORDER BY `score` DESC LIMIT 1", .@char_id$, .@score;
  144. if(.@char_id$ == "" || .@score <= 0) waitingroom "[ PvP Rating ]", 0;
  145. else waitingroom "[PK]: Best: " + .@char_id$ + " ["+.@score+"] ", 0;
  146. sleep 60000;
  147. delwaitingroom;
  148. }
  149. }
  150.  
  151. function script Announcing {
  152. if(!$FirstBlood){
  153. set $FirstBlood,1;
  154. if($Announce) announce strcharinfo(0) + " HAS DRAW A FIRST BLOOD!",bc_map|bc_red;
  155. if($Sound){
  156. soundeffectall "firstblood.wav",strcharinfo(3);
  157. }
  158. }
  159. set @KillingSpree, @KillingSpree +1;
  160. set @MultiKill, @MultiKill +1;
  161. deltimer "PvP_FunctionS::OnMKReset";
  162. addtimer 10000, "PvP_FunctionS::OnMKReset";
  163. if($Announce){
  164. switch(@KillingSpree){
  165. case 0: case 1: case 2: break;
  166. case 3: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break;
  167. case 4: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break;
  168. case 5: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break;
  169. case 6: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break;
  170. case 7: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break;
  171. }
  172. }
  173. if(@KillingSpree >= 3 && @KillingSpree <= 7){
  174. if($Sound) soundeffectall "killingspree"+@KillingSpree+".wav", 0, strcharinfo(3);
  175. }
  176. if($Announce){
  177. switch(@MultiKill){
  178. case 0: case 1: break;
  179. case 2: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break;
  180. case 3: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break;
  181. case 4: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break;
  182. case 5: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break;
  183. }
  184. }
  185. sleep2 1500;
  186. if(@MultiKill >= 2 && @MultiKill <= 5) {
  187. if($Sound) soundeffectall "multikill"+@MultiKill+".wav", 0, strcharinfo(3);
  188. }
  189.  
  190. if(@KillingSpree < 3){
  191. if($Announce) mapannounce strcharinfo(3),strcharinfo(0)+" HAS SLAIN A "+rid2name(killedrid),bc_all;
  192. }
  193. if($Sound){
  194. soundeffectall "slain.wav",0,strcharinfo(3);
  195. }
  196.  
  197. if(@KillingSpree >= 7){
  198. if($Announce) mapannounce strcharinfo(3),strcharinfo(0)+" IS LEGENDARY!!!",bc_all;
  199. if($Sound){
  200. soundeffectall "legendary.wav",0,strcharinfo(3);
  201. }
  202. }
  203.  
  204. if(@MultiKill > 5) set @MultiKill, 0;
  205. return;
  206. }
  207.  
  208. // leagues
  209. function script PKLeagues {
  210. query_sql "SELECT `league` FROM `pk_rating` WHERE `char_id` = '"+strcharinfo(0)+"'", .@league$;
  211. for(@i = 0; @i < getarraysize($LeagueName$); @i ++){
  212. if($LeagueName$[@i] != "") {
  213. if(MPKAcc > $MinRating[@i] && MPKAcc < $MaxRating[@i] && .@league$ != $LeagueName$[@i]){
  214. if(.@league$ == "Diamond") return;
  215. query_sql "UPDATE `pk_rating` SET `league` = '"+$LeagueName$[@i]+"' WHERE `char_id` = '"+strcharinfo(0)+"'";
  216. dispbottom "[PvP Info] : Your new Division : " + $LeagueName$[@i] + " Division.";
  217. cutin "1", 4;
  218. sleep2 2000;
  219. cutin $CutinName$[@i], 4;
  220. sleep2 3000;
  221. cutin "", 255;
  222. }
  223. }
  224. }
  225. return;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement