- 0
Sign in to follow this
Followers
0
Pvp point system / rank system like in dota 2(mmr)
Asked by
Louis T Steinhil
-
Recently Browsing 0 members
No registered users viewing this page.

There's a post in rathena alike but it's not compatible in hercules, can anyone help?
// -------------- PVP RATING (SQL ONLY)! ----------------- // // ---- by Kubix. /* tables: CREATE TABLE `pk_rating` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `char_id` varchar(30) NOT NULL, `kill_count` int(11) NOT NULL, `die_count` int(11) NOT NULL, `score` int(11) NOT NULL, `league` varchar(30) NOT NULL, PRIMARY KEY (`id`) ); */ - script PvP_FunctionS -1,{ OnPCKillEvent: getmapxy .@charmap$,.@x,.@y,0; if(strcharinfo(3) == "prontera") end; for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){ if(.@charmap$ == $Rating_Location$[.@i]){ callfunc "Announcing"; // announce function callfunc "PKGetRating"; // rating function end; } } end; OnMKReset: set @MultiKIll, 0; end; } - script PvP_FunctionSS -1,{ OnPCDieEvent: if(strcharinfo(3) == "prontera") end; if((killerrid == getcharid(0)) || (killerrid < 150000)) end; getmapxy .@charmap$,.@x,.@y,0; for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){ if(.@charmap$ == $Rating_Location$[.@i]){ if((killerrid == getcharid(0)) || (killerrid < 150000)) end; sleep2 500; deltimer "PvP_FunctionS::OnMKReset"; if(@MultiKill > 0)set @MultiKill, 0; if(@KillingSpree > 0)set @KillingSpree, 0; if(@PKKills >0)set @PKKills, 0; callfunc "PKTakeRating"; // end; } } end; } - script PvP_LogoutEvent -1,{ OnPCLogoutEvent: if(strcharinfo(3) == "prontera") end; getmapxy .@charmap$,.@x,.@y,0; for(set .@i,0; .@i <=getarraysize($Rating_Location$); set .@i,.@i+1){ if(.@charmap$ == $Rating_Location$[.@i]){ if(@MultiKill > 0)set @MultiKill, 0; if(@KillingSpree > 0)set @KillingSpree, 0; if(@PKKills >0)set @PKKills, 0; deltimer "PvP_FunctionS::OnMKReset"; end; } } end; } function script PKGetRating { set PKRatingF, 0; set @PKKills, @PKKills + 1; set PKRatingF, PKRatingF + 2 * (rand(2,3) + @PCKills); set MPKAcc, MPKAcc + 2 * (rand(2,3) + @PCKills); // rating set PCKills, PCKills + 1; // kills callfunc "PKLeagues"; dispbottom "[PK Manager]: +[ "+PKRatingF+" ] rating."; query_sql "UPDATE `pk_rating` SET `kill_count` = '"+PCKills+"', `score` = '"+MPKAcc+"' WHERE `char_id` = '"+strcharinfo(0)+"'"; end; } function script PKTakeRating { set PKRatingF, 0; // set @PKDies, @PKDies + 1; // set PKRatingF, PKRatingF - 2 * (rand(2,3) + @PCDies); set MPKAcc, MPKAcc - 2 * (rand(2,3) + @PCDies); // rating set PCDies, PCDies + 1; // deaths callfunc "PKLeagues"; dispbottom "[PK Manager]: [ "+PKRatingF+" ] rating."; query_sql "UPDATE `pk_rating` SET `die_count` = '"+PCDies+"', `score` = '"+MPKAcc+"' WHERE `char_id` = '"+strcharinfo(0)+"'"; end; } // PK Top prontera,130,191,6 script PvP Rating 857,{ mes "[PK Manager]"; mes "Can I help you??"; mes "I can show players with rating more than 0"; mes "Your Rating : " + MPKAcc; for(@i = 0; @i < getarraysize($LeagueName$); @i ++){ if($LeagueName$[@i] != "") { if(MPKAcc > $MinRating[@i] && MPKAcc < $MaxRating[@i]) cutin $CutinName$[@i], 2; } } next; if(select("> PK TOP:> Cancel") == 2) { close2; cutin "", 255; end; } 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$; mes "Name/Kills/Deaths/Score/Division"; for(set .i, 0; .i < 10; set .i, .i + 1) { if(.@cname$[.i] != "" && .@rscore[.i] > 0) { mes "" + (.i+1) + ".^FF0000" + .@cname$[.i] + "^000000/" + .@kcount[.i] + "/" + .@dcount[.i] + "/^6699DD" + .@rscore[.i] + "^000000/^0000FF" + .@leaguel$[.i] + "^000000."; } else { mes (.i+1)+".Empty"; } } close2; cutin "", 255; end; OnInit: // === Settings set $FirstBlood, 0; set $Sound, 0; set $Announce, 1; setarray $KS_Ann$[0],"IS ON A KILLING SPREE!!!","IS ON A RAMPAGE!!!","IS UNSTOPPABLE!!!","IS DOMINATING!!!","IS G-G-G-GODLIKE!!!","IS LEGENDARY!!!"; setarray $MK_Ann$[0],"HAS SCORED A DOUBLE KILL!!!","HAS SCORED A TRIPLE KILL!!!","HAS SCORED A QUADRA KILL!!!","HAS SCORED A PENTA KILL!!!!"; setarray $Rating_Location$[0], "pvp_n_5-5"; // add your locations setarray $LeagueName$[0], "Bronze","Silver","Gold","Platinum","Diamond"; // add you divisions setarray $MinRating[0], 0, 1300, 1600, 1900, 2200; // min. rating for division setarray $MaxRating[0], 1299, 1599, 1899, 2199, 100000; // max. rating for division setarray $CutinName$[0], "1-1","2-1","3-1","4-1","5-1"; // cutin names for divisions // === end of settings while(1) { query_sql "SELECT `char_id`,`score` FROM `pk_rating` ORDER BY `score` DESC LIMIT 1", .@char_id$, .@score; if(.@char_id$ == "" || .@score <= 0) waitingroom "[ PvP Rating ]", 0; else waitingroom "[PK]: Best: " + .@char_id$ + " ["+.@score+"] ", 0; sleep 60000; delwaitingroom; } } function script Announcing { if(!$FirstBlood){ set $FirstBlood,1; if($Announce) announce strcharinfo(0) + " HAS DRAW A FIRST BLOOD!",bc_map|bc_red; if($Sound){ soundeffectall "firstblood.wav",strcharinfo(3); } } set @KillingSpree, @KillingSpree +1; set @MultiKill, @MultiKill +1; deltimer "PvP_FunctionS::OnMKReset"; addtimer 10000, "PvP_FunctionS::OnMKReset"; if($Announce){ switch(@KillingSpree){ case 0: case 1: case 2: break; case 3: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break; case 4: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break; case 5: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break; case 6: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break; case 7: mapannounce strcharinfo(3),strcharinfo(0)+" " +$KS_Ann$[@KillingSpree -3],bc_all; break; } } if(@KillingSpree >= 3 && @KillingSpree <= 7){ if($Sound) soundeffectall "killingspree"+@KillingSpree+".wav", 0, strcharinfo(3); } if($Announce){ switch(@MultiKill){ case 0: case 1: break; case 2: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break; case 3: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break; case 4: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break; case 5: mapannounce strcharinfo(3),strcharinfo(0)+" " +$MK_Ann$[@MultiKill -2],bc_all; break; } } sleep2 1500; if(@MultiKill >= 2 && @MultiKill <= 5) { if($Sound) soundeffectall "multikill"+@MultiKill+".wav", 0, strcharinfo(3); } if(@KillingSpree < 3){ if($Announce) mapannounce strcharinfo(3),strcharinfo(0)+" HAS SLAIN A "+rid2name(killedrid),bc_all; } if($Sound){ soundeffectall "slain.wav",0,strcharinfo(3); } if(@KillingSpree >= 7){ if($Announce) mapannounce strcharinfo(3),strcharinfo(0)+" IS LEGENDARY!!!",bc_all; if($Sound){ soundeffectall "legendary.wav",0,strcharinfo(3); } } if(@MultiKill > 5) set @MultiKill, 0; return; } // leagues function script PKLeagues { query_sql "SELECT `league` FROM `pk_rating` WHERE `char_id` = '"+strcharinfo(0)+"'", .@league$; for(@i = 0; @i < getarraysize($LeagueName$); @i ++){ if($LeagueName$[@i] != "") { if(MPKAcc > $MinRating[@i] && MPKAcc < $MaxRating[@i] && .@league$ != $LeagueName$[@i]){ if(.@league$ == "Diamond") return; query_sql "UPDATE `pk_rating` SET `league` = '"+$LeagueName$[@i]+"' WHERE `char_id` = '"+strcharinfo(0)+"'"; dispbottom "[PvP Info] : Your new Division : " + $LeagueName$[@i] + " Division."; cutin "1", 4; sleep2 2000; cutin $CutinName$[@i], 4; sleep2 3000; cutin "", 255; } } } return; }https://rathena.org/board/topic/101681-sql-pvp-rating-php/
Share this post
Link to post
Share on other sites