Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://rathena.org/board/topic/115277-mvp-ranking-with-rewards-help-please/
- /*
- create table mvp_rank (
- char_id int(11) primary key,
- name varchar(23) default '',
- mvp_kills int(11) default 0,
- key (mvp_kills)
- ) engine = innodb;
- create table mvp_rank_archive (
- weekindex int(11),
- rank tinyint(4) unsigned,
- char_id int(11) unsigned default 0,
- name varchar(23) default '',
- points int(11) unsigned not null,
- key (weekindex)
- ) engine = myisam;
- create table mvp_rank_reward (
- char_id int(11),
- weekindex int(11),
- rank tinyint(4) unsigned,
- key (char_id)
- ) engine = innodb;
- */
- prontera,143,170,5 script MVP Ladder 100,{
- mes "[^A0522DM^006400V^0000FFP^000000^000000^000000 Ladder]";
- mes "Hello! "+(Sex?"Mr":"Ms")+", ^228B22"+strcharinfo(0)+"^000000";
- mes "What are you doing here?";
- next;
- switch( select( "^FF4500Check Rankings^000000.", "^006400My Stats^000000.", "^4F4F4FPrevious Week Ranking^000000", "^D8BFD8Claim Rewards^000000" ) ) {
- mes "[^A0522DM^006400V^0000FFP^000000^000000^000000 Ladder]";
- case 1:
- mes "Rankings :^FF0000->^000000";
- .@query$ = "SELECT `name`, IF(@d=t.`mvp_kills`, @r, @r:=@i), @d:=t.`mvp_kills`, @i:=@i+1 ";
- .@query$ += "FROM `mvp_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
- .@query$ += "ORDER BY `mvp_kills` DESC LIMIT 10";
- .@nb = query_sql(.@query$, .@name$, .@rank, .@kills, .@dummy);
- if ( !.@nb ) {
- mes " ^C0C0C0No entry.^000000";
- close;
- }
- for ( .@i = 0; .@i < .@nb; ++.@i )
- mes .@rank[.@i] +". ^7B68EE"+ .@name$[.@i] +"^000000 ^FF0000->^000000 ^BDB76B"+ .@kills[.@i] +"^000000 points";
- close;
- case 2:
- 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 ) ) {
- mes "You haven't kill ^A0522DM^006400V^0000FFP^000000^000000^000000 this week";
- close;
- }
- mes "You have killed ^BDB76B"+ .@kills +"^000000 ^A0522DM^006400V^0000FFP^000000^000000^000000s";
- mes "Your current rank is No."+ .@rank;
- close;
- case 3:
- mes "Previous week ranking :^FF0000->^000000";
- .@nb = query_sql( "select rank, name, points from mvp_rank_archive where weekindex = "+( .this_week_index -1 )+" order by rank", .@rank, .@name$, .@count );
- if ( !.@nb ) {
- mes " ^C0C0C0No entry.^000000";
- close;
- }
- for ( .@i = 0; .@i < .@nb; ++.@i )
- mes .@rank[.@i] +". ^7B68EE"+ .@name$[.@i] +"^000000 ^FF0000->^000000 ^DAA520"+ .@count[.@i] +"^000000 points";
- close;
- case 4:
- .@nb = query_sql( "select weekindex, rank from mvp_rank_reward where char_id = "+ getcharid(0), .@week, .@rank );
- if ( !.@nb ) {
- mes "You don't have unclaim rewards.";
- close;
- }
- mes "You have ["+ .@nb +"] unclaimed rewards.";
- for ( .@i = 0; .@i < .@nb; ++.@i )
- mes ( .@i +1 ) +". Rank."+ .@rank[.@i] +" from "+ callfunc( "F_InsertPlural", .this_week_index - .@week[.@i], "week" ) +" ago.";
- next;
- for ( .@i = 0; .@i < .@nb; ++.@i )
- .@menu$[.@i] = "Claim Rank."+ .@rank[.@i] +" from "+ callfunc( "F_InsertPlural", .this_week_index - .@week[.@i], "week" ) +" ago.";
- .@s = select( implode( .@menu$, ":" ) ) -1;
- if ( checkweight( .reward[ .@rank[.@s] -1 ], .amount[ .@rank[.@s] -1 ] ) == false ) {
- mes "You are currently ^FF0000overweight^000000.";
- close;
- }
- getitem .reward[ .@rank[.@s] -1 ], .amount[ .@rank[.@s] -1 ];
- query_sql "delete from mvp_rank_reward where char_id = "+ getcharid(0) +" and weekindex = "+ .@week[.@s] +" and rank = "+ .@rank[.@s];
- }
- close;
- OnInit:
- // set reward here ... 1st place won 10 red pot, 2nd place won 9 orange pot ... etc ...
- setarray .reward, 14624, 14624, 14624 , 14407, 14407, 14407, 14407, 12103, 12258, 11502;
- setarray .amount, 3, 2, 1, 4, 4, 4, 4, 3, 3, 250;
- if ( !$mvp_rank_1st_sunday )
- query_sql "select curdate() - dayofweek( curdate() ) +1", $mvp_rank_1st_sunday; // TRICK !! how to save the 1st sunday once the script installed
- OnSun0000:
- query_sql "select datediff( curdate(), '"+ $mvp_rank_1st_sunday +"' ) /7", .this_week_index;
- if ( .this_week_index == $mvp_rank_week_index ) end;
- .@query$ = "SELECT char_id, `name`, IF(@d=t.`mvp_kills`, @r, @r:=@i), @d:=t.`mvp_kills`, @i:=@i+1 ";
- .@query$ += "FROM `mvp_rank` t, (SELECT @d:=0, @r:=0, @i:=1)q ";
- .@query$ += "ORDER BY `mvp_kills` DESC LIMIT 10";
- .@nb = query_sql(.@query$, .@cid, .@name$, .@rank, .@kills, .@dummy);
- if ( .@nb ) {
- for ( .@i = 0; .@i < .@nb; ++.@i ) {
- .@reward_query$[.@i] = "( "+ .@cid[.@i] +", "+ $mvp_rank_week_index +", "+ .@rank[.@i] +" )";
- .@archive_query$[.@i] = "( "+ $mvp_rank_week_index +", "+ .@rank[.@i] +", "+ .@cid[.@i] +", '"+ escape_sql(.@name$[.@i]) +"', "+ .@kills[.@i] +" )";
- }
- // query_sql "truncate table mvp_rank_archive"; // uncomment this line if you love to periodically clean your data
- query_sql "insert into mvp_rank_reward values "+ implode( .@reward_query$, ", " );
- query_sql "insert into mvp_rank_archive values "+ implode( .@archive_query$, ", " );
- query_sql "truncate table mvp_rank";
- }
- $mvp_rank_week_index = .this_week_index;
- end;
- OnNPCKillEvent:
- if ( getmonsterinfo( killedrid, MOB_MVPEXP ) ) {
- 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";
- query_sql "select mvp_kills from `mvp_rank` where char_id = "+ getcharid(0), .@killed;
- dispbottom "~ You've killed "+ .@killed +" MVP. ~";
- specialeffect2 EF_BASH3D2;
- }
- end;
- }
Advertisement
Comments
-
- <script src="https://pastebin.com/embed_js/baCTJTZv"></script>
-
- Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
- If you have questions, please contact your organization's network administrator and provide the codes shown below
-
- Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
- If you have questions, please contact your organization's network administrator and provide the codes shown below
-
- Based on your organization's access policies, access to application HatenaBlog of type Blogging has been blocked.
- 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