SHARE
TWEET

PVP Rating

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