Jump to content
  • 0

Help on using NPC Timer


KaitoKid

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  268
  • Reputation:   27
  • Joined:  12/06/11
  • Last Seen:  

I'm making a script that involves NPC timer.

The rule is that the player will pay a zeny per hour and when a player dies the timer should pause and resumes when the player enters the map again.

But the problem is after the player dies the timer won't attach to the player anymore and doesn't resume the time used by the player.

pvp_n_1-5,99,113,4 script Battleground Warper::bg_warper 416,{
if(@bg_session == 1) {
B_Session:
 set @BGRemaintT,(getnpctimer(0)/1000);
 if(@BGRemainT >= 60)
  set @BGRemain$, (@BGRemainT / 60)+" minute/s^000000";
 else
  set @BGRemain$, @BGRemainT+" second/s^000000";
 mes "[Gate Keeper]";
 mes "Hello "+strcharinfo(0)+"!";
 mes "You have a remaining time of ^008000"+@BGRemain$;
 mes "What do you want?";
 switch(select("Return to the Battlegrounds:I want to end my session:Where can I trade this points?")) {
  case 1:
mes "[Gate Keeper]";
mes "As you wish.";
next;
startnpctimer "bg_warper",getcharid(0);
warp "bat_b02",87,89;
close;
  case 2:
mes "[Gate Keeper]";
mes "As you wish.";
next;
set @bg_session,0;
stopnpctimer "bg_warper",getcharid(0);
detachnpctimer "bg_warper";
mes "[Gate Keeper]";
mes "You're session is closed.";
close;
  case 3:
mes "[Gate Keeper]";
mes "You can trade you're Battlepoints on the Battleground shops.";
next;
 }
 goto B_Session;
}
mes "[Gate Keeper]";
mes "In the battleground there are tons of monsters you can defeat and earn ^008000Battleground Points^000000.";
mes "Which you can exchange for items at the ^0000FFBattleground Shop^000000";
next;
mes "[Gate Keeper]";
mes "A fee of 10k Zeny is charged per hour.";
mes "Would you like to enter the grounds?";
if(select("Yes:No") == 2) close;
next;
if(Zeny < 10000) {
 mes "[Gate Keeper]";
 mes "Please don't make me look stupid";
 mes "I know how to count money.";
 close;
}
mes "[Gate Keeper]";
mes "Just a little reminders:";
mes "I will Automatically deduct your zeny to extend your time.";
mes "If you want to stop your time just talk to me again.";
mes "Incase you got killed you're time will paused and will be resumed once you enter again.";
mes "^FF0000NOTE: If ever your character logged out you're time will be automatically terminated.^000000";
next;
set @bg_session, 1;
set @auto_extend, 1;
set Zeny,Zeny - 10000;
initnpctimer "bg_warper",getcharid(0);
warp "bat_b02",87,75;
close;
OnTimer10000:
 dispbottom "First 10 seconds of your time has begun!";
 end;
OnTimer20000:
 dispbottom "Another 10 seconds have passed.";
 end;
OnTimer30000:
 set @BGRemaintT,(getnpctimer(0)/1000);
 dispbottom " "+@BGRemainT;
 end;
OnTimer3000000:
 if(Zeny < 10000)  dispbottom "You don't have enough zeny left.";
 announce "You have 10 minutes remaining.",bc_self,0x008000;
 end;
OnTimer3600000:
OnTimer3600001:
 if(@auto_extend == 1) {
  if(Zeny < 10000) {
dispbottom "You don't have enough zeny left. Warping you out.";
stopnpctimer "bg_warper",getcharid(0);
detachnpctimer "bg_warper";
warp "mellina",85,83;
end;
  }
  set Zeny,Zeny - 5000;
  initnpctimer "bg_warper",getcharid(0);
  announce "10k Zeny is deducted. I have extended your time",bc_self,0xC0C0C0;
  end;
 }
 else {
  stopnpctimer "bg_warper",getcharid(0);
  detachnpctimer "bg_warper";
  set @bg_session, 0;
  announce "You're time is up!",bc_self;
  warp "mellina",85,83;
  end;
 }

OnTimerQuit:
 stopnpctimer "bg_warper",getcharid(0);
 detachnpctimer "bg_warper";
 set @bg_session, 0;
 end;

OnPCKillEvent:
 stopnpctimer "bg_warper",getcharid(0);
 if(strcharinfo(3) == "bat_b02")
  warp "pvp_n_1-5",99,107;
 end;
}

Edited by Arcenciel
Please use a codebox for long scripts.
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  201
  • Reputation:   47
  • Joined:  11/17/11
  • Last Seen:  

If all you want to do is attach the player to the script again, you can use the attachrid() function. Just have the npc store the players account id, then when the player dies, attachrid(.accountid) and continue.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  268
  • Reputation:   27
  • Joined:  12/06/11
  • Last Seen:  

Hmm.

I have already did what you have said but still it doesn't save the remaining time to the player.

Here is the edited script

 pvp_n_1-5,99,113,4 script Battleground Warper::bg_warper 416,{
if(@bg_session == 1) {
B_Session:
set @BGRemaintT,(getnpctimer(00,"bg_warper")/1000);
if(@BGRemainT >= 60)
set @BGRemain$, (@BGRemainT / 60)+" minute/s^000000";
else
set @BGRemain$, @BGRemainT+" second/s^000000";
mes "[Gate Keeper]";
mes "Hello "+strcharinfo(0)+"!";
mes "You have a remaining time of ^008000"+@BGRemain$;
mes "What do you want?";
switch(select("Return to the Battlegrounds:I want to end my session:Where can I trade this points?")) {
case 1:
mes "[Gate Keeper]";
mes "As you wish.";
next;
attachrid getcharid(3);
attachnpctimer strcharinfo(0);
startnpctimer "bg_warper",getcharid(3);
warp "kro_bat",0,0;
close;
case 2:
mes "[Gate Keeper]";
mes "As you wish.";
next;
set @bg_session,0;
stopnpctimer "bg_warper",getcharid(3);
detachnpctimer "bg_warper";
mes "[Gate Keeper]";
mes "You're session is closed.";
close;
case 3:
mes "[Gate Keeper]";
mes "You can trade you're Battlepoints on the Battleground shops.";
next;
}
goto B_Session;
}
mes "[Gate Keeper]";
mes "In the battleground there are tons of monsters you can defeat and earn ^008000Battleground Points^000000.";
mes "Which you can exchange for items at the ^0000FFBattleground Shop^000000";
next;
mes "[Gate Keeper]";
mes "A fee of 10k Zeny is charged per hour.";
mes "Would you like to enter the grounds?";
if(select("Yes:No") == 2) close;
next;
if(Zeny < 10000) {
mes "[Gate Keeper]";
mes "Please don't make me look stupid";
mes "I know how to count money.";
close;
}
mes "[Gate Keeper]";
mes "Just a little reminders:";
mes "I will Automatically deduct your zeny to extend your time.";
mes "If you want to stop your time just talk to me again.";
mes "Incase you got killed you're time will paused and will be resumed once you enter again.";
mes "^FF0000NOTE: If ever your character logged out you're time will be automatically terminated.^000000";
next;
set @bg_session, 1;
set @auto_extend, 1;
set Zeny,Zeny - 10000;
attachrid getcharid(3);
attachnpctimer strcharinfo(0);
initnpctimer "bg_warper",getcharid(3);
warp "kro_bat",0,0;
close;
OnTimer10000:
dispbottom "First 10 seconds of your time has begun!";
end;
OnTimer20000:
dispbottom "Another 10 seconds have passed.";
end;
OnTimer30000:
set @BGRemaintT,getnpctimer(0,"bg_warper");
dispbottom " "+@BGRemainT;
end;
OnTimer3000000:
if(Zeny < 10000)  dispbottom "You don't have enough zeny left.";
announce "You have 10 minutes remaining.",bc_self,0x008000;
end;
OnTimer3600000:
OnTimer3600001:
if(@auto_extend == 1) {
if(Zeny < 10000) {
dispbottom "You don't have enough zeny left. Warping you out.";
stopnpctimer "bg_warper",getcharid(3);
detachnpctimer "bg_warper";
warp "mellina",85,83;
end;
}
set Zeny,Zeny - 5000;
initnpctimer "bg_warper",getcharid(3);
announce "10k Zeny is deducted. I have extended your time",bc_self,0xC0C0C0;
end;
}
else {
stopnpctimer "bg_warper",getcharid(3);
detachnpctimer "bg_warper";
set @bg_session, 0;
announce "You're time is up!",bc_self;
warp "mellina",85,83;
end;
}

OnTimerQuit:
stopnpctimer "bg_warper",getcharid(3);
detachnpctimer "bg_warper";
set @bg_session, 0;
end;

OnPCKillEvent:
stopnpctimer "bg_warper",getcharid(3);
attachrid getcharid(3);
if(strcharinfo(3) == "kro_bat")
warp "pvp_n_1-5",99,107;
end;
}

Edited by padz535
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...