Here you go:
// http://rathena.org/board/topic/53708-double-exp-last-3-days-of-the-month/
- script DoubleExp_Last3days -1,{
function getDaysOfMonth;
function isLeapYear;
OnInit:
// save the "regular" rates, as defined in /conf/battle/exp.conf
set .base_exp_rate, getbattleflag("base_exp_rate");
set .job_exp_rate, getbattleflag("job_exp_rate");
OnClock0000: // every day, check if it's the last 3 days
sleep 500; // slow script execution
if (gettime(5) == 1 &&
(getbattleflag("base_exp_rate")!=.base_exp_rate || getbattleflag("job_exp_rate")!=.job_exp_rate)) {
// if it's the 1st of the month and rates are doubled, end the event
setbattleflag "base_exp_rate", .base_exp_rate;
setbattleflag "job_exp_rate", .job_exp_rate;
atcommand "@reloadmobdb";
announce "[server] : the Double Exp Event has ended.", bc_blue
announce "Current Rates: Base Exp = "+ .base_exp_rate/100 +"x Job Exp = "+ .job_exp_rate/100 +"x", bc_all,0x00FF00;
}
} else if (gettime(5) > (getDaysOfMonth() -3)) {
// start the Double Exp event
setbattleflag "base_exp_rate", .base_exp_rate*2;
setbattleflag "job_exp_rate", .job_exp_rate*2;
atcommand "@reloadmobdb";
announce "[server] : It's the last 3 days of the month... the Double Exp Event has started!", bc_blue;
announce "Current Rates: Base Exp = "+.@rates+"x Job Exp = "+.@rates+"x", bc_all,0x00FF00;
}
end;
function getDaysOfMonth {
switch (gettime(6)) {
case 2: // February
set .@days, isLeapYear(gettime(7)) ? 29 : 28;
break;
case 9: // September
case 4: // April
case 6: // June
case 11: // November
set .@days, 30;
break;
default:
set .@days, 31;
break;
}
return .@days;
}
function isLeapYear {
set .@year, getarg(0);
return ( .@year%4 == 0 && (.@year%100 != 0 || .@year%400 == 0) );
}
}