I have a NPC equal to yours and even with some more functions.
The NPC I created saves the time of Buff XP and checks when the player replays to see if there is still some time left for the Buff or it should be deleted.
This avoids leaving the Buff time paralyzed when the player moves, as if time continues to roll.
NPC: Buff Exp
- script Check_Buff_Bonus_XP -1,{
OnPCLogoutEvent:
if (getstatus(SC_CASH_PLUSEXP,0) == 1)
set BuffXP_Tempo, gettimetick(2);
end;
OnPCLoginEvent:
if (getstatus(SC_CASH_PLUSEXP,0) == 1) {
set .@tempo, gettimetick(2)-BuffXP_Tempo;
set .@tempo2,.@tempo*1000;
if (.@tempo2 >= getstatus(SC_CASH_PLUSEXP,5)) {
sc_end SC_CASH_PLUSEXP;
end;
}
else {
set .@rate, getstatus(SC_CASH_PLUSEXP,1);
set .@temposet, getstatus(SC_CASH_PLUSEXP,5)-.@tempo2;
sc_end SC_CASH_PLUSEXP;
sc_start4 SC_CASH_PLUSEXP,.@temposet,.@rate,0,0,0;
end;
}
}
}
NPC: Buff Drop
Code:
- script Check_Buff_Bonus_Drop -1,{
OnPCLogoutEvent:
if (getstatus(SC_CASH_RECEIVEITEM,0) == 1)
set BuffDrop_Tempo, gettimetick(2);
end;
OnPCLoginEvent:
if (getstatus(SC_CASH_RECEIVEITEM,0) == 1) {
set .@tempo, gettimetick(2)-BuffDrop_Tempo;
set .@tempo2,.@tempo*1000;
if (.@tempo2 >= getstatus(SC_CASH_RECEIVEITEM,5)) {
sc_end SC_CASH_RECEIVEITEM;
end;
}
else {
set .@rate, getstatus(SC_CASH_RECEIVEITEM,1);
set .@temposet, getstatus(SC_CASH_RECEIVEITEM,5)-.@tempo2;
sc_end SC_CASH_RECEIVEITEM;
sc_start4 SC_CASH_RECEIVEITEM,.@temposet,.@rate,0,0,0;
end;
}
}
}