Advertisement
Emistry

[RO] Top WOE PVP - Reset Option

Nov 25th, 2016
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. // https://rathena.org/board/topic/108331-help-i-want-to-put-a-reset-choose-for-gm/
  2.  
  3.  
  4. prontera,131,207,5 script WoE Rank#PvP 421,{
  5. mes "[ ^FF0000Top 10 WoE Killers^000000 ]";
  6. if ( .@size = getarraysize( $topwoe1pvp_name$ ) ) {
  7. for ( .@i = 0; .@i < .@size; .@i++ )
  8. mes ""+( .@i +1 )+": ^0000FF"+ $topwoe1pvp_name$[.@i] +"^000000 - ^FF0000"+ $topwoe1pvp_points[.@i] +"^000000 Kill.";
  9. }
  10. if ( getgmlevel() >= 99 ) {
  11. next;
  12. if ( select( "Reset","Cancel" ) == 1 ) {
  13. donpcevent strnpcinfo(3)+"::OnReset";
  14. }
  15. }
  16. else
  17. mes "<empty>";
  18. close;
  19.  
  20. OnReset:
  21. deletearray $topwoe1pvp_name$;
  22. deletearray $topwoe1pvp_points$;
  23. query_sql( "DELETE FROM `char_reg_num` WHERE `key` LIKE '%topwoe1%' AND `char_id` IN ( SELECT `char_id` FROM `char` WHERE `login` = 0 ) " );
  24. addrid(0);
  25. topwoe1pvp_points = 0;
  26. end;
  27.  
  28. OnPCKillEvent:
  29. if ( !getmapflag( strcharinfo(3), mf_gvg_castle ) ) end;
  30. topwoe1pvp_points++;
  31. .@i = 0;
  32. while ( .@i < .ladderlength ) {
  33. if ( topwoe1pvp_points > $topwoe1pvp_points[.@i] ) { // if found
  34. if ( $topwoe1pvp_name$[.@i] == strcharinfo(0) ) { // update your own points
  35. $topwoe1pvp_points[.@i] = topwoe1pvp_points;
  36. break;
  37. }
  38. else if ( .@i == .ladderlength - 1 ) { // last position of the ladder, just overwrite the value
  39. $topwoe1pvp_points[.@i] = topwoe1pvp_points;
  40. $topwoe1pvp_name$[.@i] = strcharinfo(0);
  41. break;
  42. }
  43. // if more points, but somehow its not your own name
  44. .@j = .@i +1 ; // save the index
  45. while ( $topwoe1pvp_name$[.@j] != strcharinfo(0) && .@j < .ladderlength ) .@j++;
  46. if ( .@j < .ladderlength ) // found your name
  47. .@moveamount = .@j - .@i; // save amount to move
  48. else // if not found ...
  49. .@moveamount = .ladderlength - 1 - .@i; // means move the whole ladder from the last index
  50. copyarray $topwoe1pvp_points[.@i +1], $topwoe1pvp_points[.@i], .@moveamount;
  51. copyarray $topwoe1pvp_name$[.@i +1], $topwoe1pvp_name$[.@i], .@moveamount;
  52. $topwoe1pvp_points[.@i] = topwoe1pvp_points;
  53. $topwoe1pvp_name$[.@i] = strcharinfo(0);
  54. break;
  55. }
  56. .@i++;
  57. }
  58. end;
  59. OnInit:
  60. .ladderlength = 10;
  61. end;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement