viewing paste mvp rank + auto daily top reward | Athena

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
 
/* 
 
CREATE TABLE IF NOT EXISTS `E-MVPRank` (
    `char_id` int(11) unsigned NOT NULL default '0',
    `name` varchar(30) NOT NULL DEFAULT '',
    `Count` int(11) unsigned NOT NULL default '0',
    PRIMARY KEY  (`char_id`)
) ENGINE=MyISAM;
 
*/
 
 
fayon,90,115,5  script  Sample  757,{
function send_mail;
 
query_sql( "SELECT `name`,`Count` FROM `E-MVPRank` ORDER BY `Count` DESC LIMIT 5",.@Name$,.@Count );
if( getarraysize( .@Name$ ) ){
    for( set .@i,0; .@i < getarraysize( .@Name$ ); set .@i,.@i + 1 )
        mes "[ "+( .@i + 1 )+". ] "+.@Name$[.@i]+" - "+.@Count[.@i]+" Points";
}else{
    mes "No Record Found.";
}
close;
 
OnNPCKillEvent:
if( getmonsterinfo( killedrid,MOB_MVPEXP ) )
    query_sql( "INSERT INTO `E-MVPRank` SET `char_id`='"+getcharid(0)+"',`name`='"+strcharinfo(0)+"',`Count`='1' ON DUPLICATE KEY UPDATE `Count`=`Count`+1" );
end;
 
OnClock0000:
do{
    query_sql( "SELECT `char_id` FROM `E-MVPRank` WHERE `Count` > 0 ORDER BY `Count` DESC LIMIT 100 OFFSET "+.@offset,.@cid );
    set .@size,getarraysize( .@cid );
    set .@i,0; 
    while( .@i < .@size ){
        .@rank = .@offset + .@i;
        // reward format
        // setarray .@reward,<item id>,<amount>,<zeny>;
        if( .@rank < 1 ) setarray .@reward,512,100,10000;
        else if( .@rank < 10 ) setarray .@reward,512,10,5000;
        else if( .@rank < 50 ) setarray .@reward,512,5,2500;
        else if( .@rank < 100 ) setarray .@reward,512,2,1250;
        else if( .@rank < 200 ) setarray .@reward,512,1,625;
        
        send_mail( ( .@rank+1 ),.@cid[.@i],.@reward[0],.@reward[1],.@reward[2] );
        set .@i,.@i + 1;
    }
    set .@offset,.@offset + 100;
    deletearray .@cid;
}while( .@offset < 200 );
query_sql( "TRUNCATE `E-MVPRank`" );
end;
 
function    send_mail   {
    .@rank = getarg(0);
    .@cid = getarg(1);
    .@item_id = getarg(2);
    .@amount = getarg(3);
    .@zeny = getarg(4);
    
    query_sql( "INSERT INTO `mail` ( send_name,dest_id,title,message,nameid,amount,identify,zeny,time ) VALUES ("+
        "'no-reply',"+.@cid+",'MVP Rank Top "+.@rank+" Reward',"+
        "'Brave one,% % Congratulations!% Your MVP Rank is "+.@rank+" % % % % % % [ Your reward is attached. ]',"+
        .@item_id+","+.@amount+",0,"+.@zeny+",UNIX_TIMESTAMP(NOW()))"
    );
    return;
}
 
}
Viewed 1450 times, submitted by Emistry.