Advertisement
johnlol

MVP Ladder

Aug 2nd, 2023
1,129
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 5.45 KB | Gaming | 0 0
  1. // https://rathena.org/board/topic/115277-mvp-ranking-with-rewards-help-please/
  2.  
  3. /*
  4. create table mvp_rank (
  5. char_id int(11) primary key,
  6. name varchar(23) default '',
  7. mvp_kills int(11) default 0,
  8. key (mvp_kills)
  9. ) engine = innodb;
  10.  
  11. create table mvp_rank_archive (
  12. weekindex int(11),
  13. rank tinyint(4) unsigned,
  14. char_id int(11) unsigned default 0,
  15. name varchar(23) default '',
  16. points int(11) unsigned not null,
  17. key (weekindex)
  18. ) engine = myisam;
  19.  
  20. create table mvp_rank_reward (
  21. char_id int(11),
  22. weekindex int(11),
  23. rank tinyint(4) unsigned,
  24. key (char_id)
  25. ) engine = innodb;
  26. */
  27.  
  28. prontera,143,170,5  script  MVP Ladder  100,{
  29.     mes "[^A0522DM^006400V^0000FFP^000000^000000^000000 Ladder]";
  30.     mes "Hello! "+(Sex?"Mr":"Ms")+", ^228B22"+strcharinfo(0)+"^000000";
  31.     mes "What are you doing here?";
  32.     next;
  33.     switch( select( "^FF4500Check Rankings^000000.", "^006400My Stats^000000.", "^4F4F4FPrevious Week Ranking^000000", "^D8BFD8Claim Rewards^000000" ) ) {
  34.     mes "[^A0522DM^006400V^0000FFP^000000^000000^000000 Ladder]";
  35.     case 1:
  36.         mes "Rankings :^FF0000->^000000";
  37.         .@query$  = "SELECT `name`, IF(@d=t.`mvp_kills`, @r, @r:=@i), @d:=t.`mvp_kills`, @i:=@i+1 ";
  38.         .@query$ += "FROM `mvp_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
  39.         .@query$ += "ORDER BY `mvp_kills` DESC LIMIT 10";
  40.         .@nb = query_sql(.@query$, .@name$, .@rank, .@kills, .@dummy);
  41.         if ( !.@nb ) {
  42.             mes "  ^C0C0C0No entry.^000000";
  43.             close;
  44.         }
  45.         for ( .@i = 0; .@i < .@nb; ++.@i )
  46.             mes .@rank[.@i] +". ^7B68EE"+ .@name$[.@i] +"^000000 ^FF0000->^000000 ^BDB76B"+ .@kills[.@i] +"^000000 points";
  47.         close;
  48.     case 2:
  49.         if ( !query_sql( "SELECT `mvp_kills`, 1+(SELECT COUNT(1) FROM `mvp_rank` t1 WHERE t1.`mvp_kills` > t2.`mvp_kills`) FROM `mvp_rank` t2 WHERE `char_id` = "+ getcharid(0), .@kills, .@rank ) ) {
  50.             mes "You haven't kill ^A0522DM^006400V^0000FFP^000000^000000^000000 this week";
  51.             close;
  52.         }
  53.         mes "You have killed ^BDB76B"+ .@kills +"^000000 ^A0522DM^006400V^0000FFP^000000^000000^000000s";
  54.         mes "Your current rank is No."+ .@rank;
  55.         close;
  56.     case 3:
  57.         mes "Previous week ranking :^FF0000->^000000";
  58.         .@nb = query_sql( "select rank, name, points from mvp_rank_archive where weekindex = "+( .this_week_index -1 )+" order by rank", .@rank, .@name$, .@count );
  59.         if ( !.@nb ) {
  60.             mes "  ^C0C0C0No entry.^000000";
  61.             close;
  62.         }
  63.         for ( .@i = 0; .@i < .@nb; ++.@i )
  64.             mes .@rank[.@i] +". ^7B68EE"+ .@name$[.@i] +"^000000 ^FF0000->^000000 ^DAA520"+ .@count[.@i] +"^000000 points";
  65.         close;
  66.     case 4:
  67.         .@nb = query_sql( "select weekindex, rank from mvp_rank_reward where char_id = "+ getcharid(0), .@week, .@rank );
  68.         if ( !.@nb ) {
  69.             mes "You don't have unclaim rewards.";
  70.             close;
  71.         }
  72.         mes "You have ["+ .@nb +"] unclaimed rewards.";
  73.         for ( .@i = 0; .@i < .@nb; ++.@i )
  74.             mes ( .@i +1 ) +". Rank."+ .@rank[.@i] +" from "+ callfunc( "F_InsertPlural", .this_week_index - .@week[.@i], "week" ) +" ago.";
  75.         next;
  76.         for ( .@i = 0; .@i < .@nb; ++.@i )
  77.             .@menu$[.@i] = "Claim Rank."+ .@rank[.@i] +" from "+ callfunc( "F_InsertPlural", .this_week_index - .@week[.@i], "week" ) +" ago.";
  78.         .@s = select( implode( .@menu$, ":" ) ) -1;
  79.         if ( checkweight( .reward[ .@rank[.@s] -1 ], .amount[ .@rank[.@s] -1 ] ) == false ) {
  80.             mes "You are currently ^FF0000overweight^000000.";
  81.             close;
  82.         }
  83.         getitem .reward[ .@rank[.@s] -1 ], .amount[ .@rank[.@s] -1 ];
  84.         query_sql "delete from mvp_rank_reward where char_id = "+ getcharid(0) +" and weekindex = "+ .@week[.@s] +" and rank = "+ .@rank[.@s];
  85.     }
  86.     close;
  87. OnInit:
  88.     // set reward here ... 1st place won 10 red pot, 2nd place won 9 orange pot ... etc ...
  89.     setarray .reward, 14624, 14624, 14624 , 14407, 14407, 14407, 14407, 12103, 12258, 11502;
  90.     setarray .amount, 3, 2, 1, 4, 4, 4, 4, 3, 3, 250;
  91.    
  92.     if ( !$mvp_rank_1st_sunday )
  93.         query_sql "select curdate() - dayofweek( curdate() ) +1", $mvp_rank_1st_sunday; // TRICK !! how to save the 1st sunday once the script installed
  94. OnSun0000:
  95.     query_sql "select datediff( curdate(), '"+ $mvp_rank_1st_sunday +"' ) /7", .this_week_index;
  96.     if ( .this_week_index == $mvp_rank_week_index ) end;
  97.     .@query$  = "SELECT char_id, `name`, IF(@d=t.`mvp_kills`, @r, @r:=@i), @d:=t.`mvp_kills`, @i:=@i+1 ";
  98.     .@query$ += "FROM `mvp_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
  99.     .@query$ += "ORDER BY `mvp_kills` DESC LIMIT 10";
  100.     .@nb = query_sql(.@query$, .@cid, .@name$, .@rank, .@kills, .@dummy);
  101.     if ( .@nb ) {
  102.         for ( .@i = 0; .@i < .@nb; ++.@i ) {
  103.             .@reward_query$[.@i] = "( "+ .@cid[.@i] +", "+ $mvp_rank_week_index +", "+ .@rank[.@i] +" )";
  104.             .@archive_query$[.@i] = "( "+ $mvp_rank_week_index +", "+ .@rank[.@i] +", "+ .@cid[.@i] +", '"+ escape_sql(.@name$[.@i]) +"', "+ .@kills[.@i] +" )";
  105.         }
  106.     //  query_sql "truncate table mvp_rank_archive"; // uncomment this line if you love to periodically clean your data
  107.         query_sql "insert into mvp_rank_reward values "+ implode( .@reward_query$, ", " );
  108.         query_sql "insert into mvp_rank_archive values "+ implode( .@archive_query$, ", " );
  109.         query_sql "truncate table mvp_rank";
  110.     }
  111.     $mvp_rank_week_index = .this_week_index;
  112.     end;
  113. OnNPCKillEvent:
  114.     if ( getmonsterinfo( killedrid, MOB_MVPEXP ) ) {
  115.         query_sql "insert into mvp_rank values ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) ) +"', 1 ) on duplicate key update name = '"+ escape_sql( strcharinfo(0) )+"', mvp_kills = mvp_kills +1";
  116.         query_sql "select mvp_kills from `mvp_rank` where char_id = "+ getcharid(0), .@killed;
  117.         dispbottom "~ You've killed "+ .@killed +" MVP. ~";
  118.         specialeffect2 EF_BASH3D2;
  119.     }
  120.     end;
  121. }
Advertisement
Comments
  • prashant0695
    274 days
    # text 0.06 KB | 0 0
    1. <script src="https://pastebin.com/embed_js/baCTJTZv"></script>
  • prashant0695
    274 days
    # text 0.22 KB | 0 0
    1. Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
    2.  
    3. If you have questions, please contact your organization's network administrator and provide the codes shown below
  • prashant0695
    274 days
    # text 0.22 KB | 0 0
    1. Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
    2.  
    3. If you have questions, please contact your organization's network administrator and provide the codes shown below
  • prashant0695
    274 days
    # text 0.22 KB | 0 0
    1. Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
    2.  
    3. If you have questions, please contact your organization's network administrator and provide the codes shown below
Add Comment
Please, Sign In to add comment
Advertisement