Heya,
Well normally you'd just do a initnpctimer, but since your event needs to run for 24 hours, you can't really expect it to work correctly as a lot can happen in those 24 hours. You need a different approach in that case to survive a server restart/crash or a script reload.
//===== rAthena Script =======================================
//= Floating Server Rates
//===== By: ==================================================
//= Lupus
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= It's a simply example of setbattleflag
//= This script will change your server rates from 1x to 1.5x every 6 hours
//= Note: It doesn't affect Card granted drops, MVP & Treasure Chests drops ^_-
//= It also doesn't affect CARD drops, because they are just 0.01%
//===== Additional Comments: =================================
//= You can make incredible scripts with 'setbattleflag'!
//============================================================
prontera,123,209,6 script Broker#FloatingRates 84,{
if ($floating_rates_hours_left > 0) {
.@seconds_left = 3600 - (gettime(2) * 60 + gettime(1));
.@hours_left = ($floating_rates_hours_left - 1) * 3600;
.@time_left = .@seconds_left + .@hours_left;
.@dun_d = .@time_left / 86400;
.@dun_h = (.@time_left / 3600) % 24;
.@dun_m = (.@time_left / 60) % 60;
.@dun_s = .@time_left % 60;
if (.@dun_d > 0) {
.@remaining$ = .@dun_d + " day" + (.@dun_d > 1 ? "s" : "") + " and ";
}
.@remaining$ = .@remaining$ + (.@dun_h < 10 ? "0" : "")+.@dun_h+":"+(.@dun_m < 10 ? "0" : "")+.@dun_m+":"+(.@dun_s < 10 ? "0" : "")+.@dun_s;
mes "[Broker]";
mes "The event will end in";
mes .@remaining$;
mes "Current rates are: "+($@brate/100)+"."+($@brate-$@brateminus)+"x "+($@jrate/100)+"."+($@jrate-$@jrateminus)+"x";
close;
}
mes "[Broker]";
mes "Our server's current fund is:";
mes "" + callfunc("F_InsertComma",$fr_zeny) + " Zeny";
next;
mes "[Broker]";
mes "Would you like to make a donation?";
next;
switch(select("Yes:No")) {
case 1:
Change_Amount:
mes "[Broker]";
mes "Please input your donation amount.";
next;
input .@fr_zeny;
if (.@fr_zeny < 1) {
mes "[Broker]";
mes "Input number greater than 0.";
end;
}
mes "[Broker]";
mes "Please confirm Zeny transfer..";
next;
switch(select("Cancel:Change Amount:Confirm")) {
case 1:
end;
case 2:
.@fr_zeny = 0;
next;
goto Change_Amount;
end;
case 3:
if (Zeny < .@fr_zeny) {
mes "[Broker]";
mes "Sorry, but you don't have enough";
mes "zeny to proceed on payment.";
end;
}
mes "[Broker]";
mes "Zeny has succesfully transfered.";
Zeny -= .@fr_zeny;
$fr_zeny += .@fr_zeny;
if ($fr_zeny >= .fr_targetdonation) {
$fr_zeny = 0;
// Up to you whether you want to add an extra hour or not, as otherwise the event will be below 24 hours.
$floating_rates_hours_left = 25;
donpcevent strnpcinfo(0) + "::OnMinute00";
}
end;
}
break;
case 2:
break;
}
end;
OnInit:
.fr_targetdonation = 5000;
OnMinute00:
if (gettime(2) == 0) {
$floating_rates_hours_left--;
}
if ($floating_rates_hours_left < 0) {
end;
}
else if ($floating_rates_hours_left == 0) {
$floating_rates_hours_left = -1;
.@default_brate = 100;
.@default_jrate = 100;
if (getbattleflag("base_exp_rate") != .@default_brate) {
setbattleflag("base_exp_rate", .@default_brate);
}
if (getbattleflag("job_exp_rate") != .@default_jrate) {
setbattleflag("job_exp_rate", .@default_jrate);
}
announce "Event is over, rates were changed back to: "+(.@default_brate/100)+"x "+(.@default_jrate/100)+"x ",bc_all,0xFF6060;
end;
}
$@brate = rand(500,800);
$@jrate = rand(500,599);
//$@drate = rand(100,150);
//Base exp
setbattleflag("base_exp_rate",$@brate);
//Job exp
setbattleflag("job_exp_rate",$@jrate);
$@brateminus = ($@brate/100) * 100;
$@jrateminus = ($@jrate/100) * 100;
announce "Current rates are: "+($@brate/100)+"."+($@brate-$@brateminus)+"x "+($@jrate/100)+"."+($@jrate-$@jrateminus)+"x ",bc_all,0xFF6060;
if ($floating_rates_hours_left == 1) {
announce "There is one hour left!",bc_all,0xFF6060;
}
end;
}