Hi, I write a script that a NPC have X charges (common for all players), and the players can spent a charge.
After this, the NPC starts a timer (common for all players) to recharge, until their limit of X charges.
Here is:
- script TestScript::QuickTest4_F_03,{
mes "[Quick Test]";
mes "What you want?";
next;switch(select("Use Charge","See Charge","Exit")){case1:if(.n_now >0){
mes "[Quick Test]";if(.n_now ==.n_max){
setnpctimer 0;
initnpctimer;
mes "Starting recharges.";}.n_now -=1;
getitem 512,1;
mes "Done. Current Charges: "+.n_now+"/"+.n_max+".";}else{
mes "[Quick Test]";
mes "No Charges.";}
close;case2:
mes "[Quick Test]";
mes "Next Charge in "+((.cont)/1000)+" seconds.";
close;}
close;OnInit:set.n_max,5;//max chargesset.n_now,5;//actual chargeset.delay,10*1000;//time to recover 1 chargeset.cont,0;//actual time left to recharge
end;OnTimer1000:if(.cont <=0){.cont =.delay;}else{.cont -=1000;
stopnpctimer;
setnpctimer 0;if(.cont <=0){.n_now++;if(.n_now ==.n_max) end;.cont =.delay;}
initnpctimer;}
end;}
prontera,164,170,4 duplicate(QuickTest)TestQuick#prt 4_F_03
But I can't make the timer work; the NPC aways says "Next Charge in 10 seconds.", and the charges don't recover.
I will appreciate if someone tell me were is the error, or another easier solution better than npctimer (I use 'OnTimer1000' because others NPCs will have different .delay's, so, I can use the same scope, and the 'addtimer' is attached to the player).
Question
Kavaline
Hi, I write a script that a NPC have X charges (common for all players), and the players can spent a charge.
After this, the NPC starts a timer (common for all players) to recharge, until their limit of X charges.
Here is:
But I can't make the timer work; the NPC aways says "Next Charge in 10 seconds.", and the charges don't recover.
I will appreciate if someone tell me were is the error, or another easier solution better than npctimer (I use 'OnTimer1000' because others NPCs will have different .delay's, so, I can use the same scope, and the 'addtimer' is attached to the player).
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.