- script LOGIN -1,{
OnWhisperGlobal:
OnLoginCmnd:
OnPCLoginEvent:
set .@i, (gettime(7) * 365 * 24 * 60) + (gettime(8) * 24 * 60) + (gettime(3) * 60) +gettime(2);
if(.@i >= (#LastDailyReward + .MinWait)){
if(.@i < #LastDailyReward + .MaxWait){ set #DRewardCon, #DRewardCon + 1;
} else { set #DRewardCon, 1; }
//check incase command is invoke more than one time when player able to get reward
if (!#InvokeDaily || #InvokeDaily == 0) {
set #InvokeDaily, 1;
message strcharinfo(0),"You will get your daily reward when you active for couples minutes from now";
sleep2 1000 + .Rest * 60000;
set .@g, (#DRewardCon > getarraysize(.Rewards$)) ? (getarraysize(.Rewards$)-1) : #DRewardCon;
explode(.@XT$,.Rewards$[.@g],"|");
for(set .@x,0; .@x < getarraysize(.@XT$); set .@x,.@x + 1){
set .@TT[.@x], atoi(.@XT$[.@x]);
}
if(.Mode & 1 && .@TT[4]){ //[Note]: I need to figure out a checkweight for all items tired atm lol, for now ill leave it missing
for(set .@x,4; .@x < getarraysize(.@TT); set .@x,.@x + 2){ getitem .@TT[.@x], .@TT[.@x+1]; message strcharinfo(0),"Recived "+ .@TT[.@x+1] +" "+ getitemname(.@TT[.@x]); }
}
if(.Mode & 2){
if(.@TT[0]){ set zeny,zeny + .@TT[0]; message strcharinfo(0),"Recived "+ .@TT[0] +"z"; }
if(.@TT[1]){ setd getd(.Points$[0]),getd(.Points$[0]) + .@TT[1]; message strcharinfo(0),"Recived "+ .@TT[1] +" "+.Points$[1]; }
}
if(.Mode & 4 && (.@TT[3] || .@TT[4])) getexp .@TT[3], .@TT[4];
if(.Mode & 8){
for(set .@x,0; .@x < getarraysize(.BuffInfo); set .@x,.@x + 4){
if(#DRewardCon % .BuffInfo[.@x + 1] == 0)
sc_start .BuffInfo[.@x], .BuffInfo[.@x + 2] * 60000, .BuffInfo[.@x + 3];
}
}
message strcharinfo(0),"You have collected your daily reward, for "+#DRewardCon+" day"+((#DRewardCon > 1)?"s":"")+" in a row.";
set #LastDailyReward, .@i;
set #InvokeDaily, 0;
} else {
message strcharinfo(0),"You will get you daily reward in next few minutes, make sure you are in the main character.";
}
} else {
set .@days,(#LastDailyReward + .MinWait - .@i)/60/24;
set .@hours,((#LastDailyReward + .MinWait - .@i)/60)%24;
set .@mins,(#LastDailyReward + .MinWait - .@i)%60;
message strcharinfo(0),"You have "+ ((.@days) ? .@days +":Days " : "") +""+ ((.@hours) ? .@hours +":Hours " : "") +""+ ((.@mins) ? .@mins +":Minutes " : "") +"till your next reward";
}
end;
OnInit:
//Basic Settings
// 1: Item | 2: Points | 4: Exp
// 8: Gain Buffs Every X Consecutive Days logged in
// (a bit value, e.g. 3 = Items & Points from Multi)
set .Mode,1 + 2 + 4 + 8;
//To Enable @ Command '@loginreward' unslash next lines
// * Needs extra commands for typos
bindatcmd("reward" ,"LOGIN::OnLoginCmnd",0,99);
//Minimum Minuets Between Collecting Daily Reward
// Day: 22*60 - 24*60
// Week: 10080
set .MinWait,1320;
//Minuets Before Lose Consecutive Daily Reward
// Day: 48*60 - 50*60
// Week: 20160
set .MaxWait,3000;
//Number of mins after logging before collecting prize
set .Rest,9;
//Point Type
// [0] Points earned
// [1] Point name in mes
setarray .Points$,"#KAFRAPOINTS","K-Points";
// Consecutive Days Buff
// Each buff contains 4 variables (32 Total Max)
// <Type>,<Days>,<Duration>,<Rate>, // Buff 1
// <Type>,<Days>,<Duration>,<Rate>, // Buff 2
// ...;
//
// Example: 188,7,45,3
// -Every 7th consecutive day logged in Player gains +3 Str for 45 mins
//
// Type is 188, which references which SC_ to use, SC_INCSTR in this example
// -For a full list of SC_ visit the db/const.txt
// Days is days buff is applied, in this example 7, so every 7th day, 14,21,28....
// Duration is buff duration is Minuits, in this example 45 mins
// Rate is buff strength, in this example player gains 3 Str
setarray .BuffInfo ,260,2,360,1 // Life Insurance for 360 Mins Every 2nd Day
// Daily Prize items (max 128 days):
// "<Zeny>|<Points>|<BaseExp>|<JobExp>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc", // Day 1
// "<Zeny>|<Points>|<BaseExp>|<JobExp>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc" // Day 2
// ...;
// Total length of any days string must be 255 or shorter
// * If players login longer than the last set
// day, they will keep getting the last prize.
setarray .Rewards$,
"0|0|0|0|501|5",
end;
}
This is my full code, the reason behind the InvokeDaily variable is to avoid multiple script running when player invoke command @reward. this is because we have the delays to get the reward, thats mean when someone invoke @reward command, the script will sleep and for few mins and not yet end, so when player spam @reward command, they call the script again [ if(.@i >= (#LastDailyReward + .MinWait)) ] without any problem since the old script not yet ended. sorry for my bad english.