Hello guys. Please help me on this script.. I want to claim the reward by the same NPC by having an option of "Claim Rewards" after a week.. instead of inserting the rewards thru mail.. because in the server we turn-off the mailing system...thank you in advance..
/*
alter table `char` add column mvp_rank int(11) default 0 after delete_date, add index (mvp_rank);
create table mvp_rank_archive (
`date` datetime,
pos tinyint(4) unsigned,
cid int(11) unsigned default 0,
name varchar(23) default '',
points int(11) unsigned not null,
primary key ( `date`, pos )
) engine innodb;
*/
prontera,158,183,3 script MVP Ladder 100,{
mes "[MVP Ladder]";
mes "Hello!";
mes "What are you doing here?";
next;
switch(select("Check rankings.:My stats.:Previous Week ranking:Claim Rewards")) {
case 1:
mes "[MVP Ladder]";
mes "Rankings :->";
[email protected] = query_sql( "select name, mvp_rank from `char` where mvp_rank > 0 order by mvp_rank desc limit 10",
[email protected]$,
[email protected] );
if (
[email protected] ) {
mes "no entry";
close;
}
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected]++ )
mes (
[email protected] +1 )+". "+
[email protected]$[
[email protected]] +" -> "+
[email protected][
[email protected]] +" points";
close;
case 2:
query_sql "select mvp_rank from `char` where char_id = "+ getcharid(0),
[email protected];
mes "[MVP Ladder]";
mes "You have killed "+
[email protected] +" MVPs";
close;
case 3:
mes "[MVP Ladder]";
mes "Last week ranking";
if ( gettime(6) > 10 )
[email protected]_date$ = gettime(7) +"-"+( gettime(6) -1 )+"-00 00:00:00";
else if ( gettime(6) > 1 )
[email protected]_date$ = gettime(7) +"-0"+( gettime(6) -1 )+"-00 00:00:00";
else
[email protected]_date$ = ( gettime(7) -1 ) +"-12-00 00:00:00";
[email protected] = query_sql( "select name, points from mvp_rank_archive where `date` = '"+
[email protected]_date$ +"' order by pos",
[email protected]$,
[email protected] );
if (
[email protected] ) {
mes "no entry";
close;
}
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected]++ )
mes (
[email protected] +1 )+". "+
[email protected]$[
[email protected]] +" -> "+
[email protected][
[email protected]] +" points";
close;
}
close;
OnInit:
if ( $mvp_ladder_last_given == atoi( gettime(7) +""+ gettime(6) ) ) end;
goto L_give;
OnClock0000:
if ( gettime(4) != 1 ) end;
L_give:
[email protected] = query_sql( "select char_id, name, mvp_rank from `char` where mvp_rank > 0 order by mvp_rank desc limit 10",
[email protected],
[email protected]$,
[email protected] );
if (
[email protected] ) end;
setarray
[email protected], 501, 502, 503, 504, 505, 506, 507, 508, 509, 510;
setarray
[email protected], 10, 9, 8, 7, 6, 5, 4, 3, 2, 1;
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected]++ )
query_sql "insert into mail ( send_name, dest_id, title, message, nameid, amount, identify, zeny, time ) values ( '"+ escape_sql(
[email protected]$[
[email protected]] ) +"', "+
[email protected][
[email protected]] +", '[MVP RANK]', 'Congratulations for earning No. "+(
[email protected] +1 )+" position in MVP rank. Here is your reward.', "+
[email protected][
[email protected]] +", "+
[email protected][
[email protected]] +", 1, 0, unix_timestamp( now() ) )";
if ( gettime(6) > 10 )
[email protected]_date$ = gettime(7) +"-"+( gettime(6) -1 )+"-00 00:00:00";
else if ( gettime(6) > 1 )
[email protected]_date$ = gettime(7) +"-0"+( gettime(6) -1 )+"-00 00:00:00";
else
[email protected]_date$ = ( gettime(7) -1 ) +"-12-00 00:00:00";
for (
[email protected] = 0;
[email protected] <
[email protected];
[email protected]++ )
[email protected]$[
[email protected]] = "( '"+
[email protected]_date$ +"', "+(
[email protected] +1 )+", "+
[email protected][
[email protected]] +", '"+ escape_sql(
[email protected]$[
[email protected]] ) +"', "+
[email protected][
[email protected]] +" )";
query_sql "insert into mvp_rank_archive values "+ implode(
[email protected]$, "," );
query_sql "update `char` set mvp_rank = 0"; // reset the ladder
$mvp_ladder_last_given = atoi( gettime(7) +""+ gettime(6) );
end;
OnNPCKillEvent:
if ( getmonsterinfo( killedrid, MOB_MVPEXP ) ) {
query_sql "update `char` set mvp_rank = mvp_rank +1 where char_id = "+ getcharid(0);
query_sql "select mvp_rank from `char` where char_id = "+ getcharid(0),
[email protected];
dispbottom "~ You've killed "+
[email protected] +" MVP. ~";
specialeffect2 EF_HEAL2;
}
end;
}