Simple PvP Rating NPC for fun
Simple PvP Rating for fun
MySQL char table:
1 2 3 |
ALTER TABLE `char` ADD `pvp` INT( 10 ) NOT NULL DEFAULT '0', ADD `dies` INT( 10 ) NOT NULL DEFAULT '0' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
- script pvp_rate -1,{ OnPckillEvent: if(rid2name(killedrid) == strcharinfo(0)) end; set kills,kills+1; dispbottom "You killed "+rid2name(killedrid)+", you have "+kills+" kills"; //killed attachrid killedrid; if(rid2name(killerrid) == strcharinfo(0)) end; if(killerrid == null) end; set dies,dies+1; dispbottom "You killed by "+rid2name(killerrid)+", you have "+ dies +" deaths"; end; OnPCLoginEvent: OnPCLogOutEvent: query_sql("update `char` set `dies`='"+dies+"' where char_id='"+getcharid(0)+"'"); query_sql("update `char` set `pvp`='"+kills+"' where char_id='"+getcharid(0)+"'"); end; OnWhisperGlobal: if (@whispervar0$ == "stat") { dispbottom "Information: Kills"+kills+", Deaths"+dies+""; } if (@whispervar0$ == "top") { dispbottom "-----PvP Ladder----"; query_sql "SELECT `name`,`pvp`,`dies` FROM `char` ORDER BY `pvp` DESC LIMIT "+@whispervar1$+"", @name$, @kills, @dies; set $limit,@whispervar1$; dispbottom "Character || Kills || Deaths"; for(set @i,0; @i != $limit; set @i,@i+1) { dispbottom ""+(@i+1)+" | "+@name$[@i]+" | "+@kills[@i]+" | "+@dies[@i]+""; } } if (@whispervar0$ == "info") { dispbottom "To find out your stats write 'stat'"; dispbottom "To see the ladder write 'top#number', number - how many players display. For example: 'top#5' displays the Top 5 players"; } end; } |
QA:
Using NPC over private messages
At what nickname to write?
1 |
npc:pvp_rate |
What to write?
1 |
info |