// https://rathena.org/board/topic/108331-help-i-want-to-put-a-reset-choose-for-gm/ prontera,131,207,5 script WoE Rank#PvP 421,{ mes "[ ^FF0000Top 10 WoE Killers^000000 ]"; if ( .@size = getarraysize( $topwoe1pvp_name$ ) ) { for ( .@i = 0; .@i < .@size; .@i++ ) mes ""+( .@i +1 )+": ^0000FF"+ $topwoe1pvp_name$[.@i] +"^000000 - ^FF0000"+ $topwoe1pvp_points[.@i] +"^000000 Kill."; } if ( getgmlevel() >= 99 ) { next; if ( select( "Reset","Cancel" ) == 1 ) { donpcevent strnpcinfo(3)+"::OnReset"; } } else mes ""; close; OnReset: deletearray $topwoe1pvp_name$; deletearray $topwoe1pvp_points$; query_sql( "DELETE FROM `char_reg_num` WHERE `key` LIKE '%topwoe1%' AND `char_id` IN ( SELECT `char_id` FROM `char` WHERE `login` = 0 ) " ); addrid(0); topwoe1pvp_points = 0; end; OnPCKillEvent: if ( !getmapflag( strcharinfo(3), mf_gvg_castle ) ) end; topwoe1pvp_points++; .@i = 0; while ( .@i < .ladderlength ) { if ( topwoe1pvp_points > $topwoe1pvp_points[.@i] ) { // if found if ( $topwoe1pvp_name$[.@i] == strcharinfo(0) ) { // update your own points $topwoe1pvp_points[.@i] = topwoe1pvp_points; break; } else if ( .@i == .ladderlength - 1 ) { // last position of the ladder, just overwrite the value $topwoe1pvp_points[.@i] = topwoe1pvp_points; $topwoe1pvp_name$[.@i] = strcharinfo(0); break; } // if more points, but somehow its not your own name .@j = .@i +1 ; // save the index while ( $topwoe1pvp_name$[.@j] != strcharinfo(0) && .@j < .ladderlength ) .@j++; if ( .@j < .ladderlength ) // found your name .@moveamount = .@j - .@i; // save amount to move else // if not found ... .@moveamount = .ladderlength - 1 - .@i; // means move the whole ladder from the last index copyarray $topwoe1pvp_points[.@i +1], $topwoe1pvp_points[.@i], .@moveamount; copyarray $topwoe1pvp_name$[.@i +1], $topwoe1pvp_name$[.@i], .@moveamount; $topwoe1pvp_points[.@i] = topwoe1pvp_points; $topwoe1pvp_name$[.@i] = strcharinfo(0); break; } .@i++; } end; OnInit: .ladderlength = 10; end; }