Jump to content
  • 0

Set a timer in NPC script.


Auryn

Question


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  147
  • Reputation:   1
  • Joined:  01/26/12
  • Last Seen:  

How to put a timer between those two ones ?

mes "[Rain]";
mes "Please come back later, I need to concentrate.";

mes "[Rain]";
mes "Ah, c'est toi !";
next;
mes "[Rain]";
mes "Oh, it's you. Here it is.";
getitem 6090,1;
close;

If someone know a good way, I would like to learn about it, cause it's being hard to find out.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  87
  • Reputation:   13
  • Joined:  02/15/12
  • Last Seen:  

I would suggest you to just create a new quest inside the database and then let it check if the timer has run out.

You could also use the gettimetick(2) script command.

First you set the current time with when the "timer" should ~start.

set q_timer, gettimetick(2);
close;


set .@timer, gettimetick(2)-q_timer;
set .@wait, 600-.@timer;
if(.@timer < 600)
{
mes "[Rain]";
mes "Please come back in "+.@wait+" seconds, I need to concentrate.";
close;
}
else{
mes "[Rain]";
mes "Ah, c'est toi !";
next;
mes "[Rain]";
mes "Oh, it's you. Here it is.";
getitem 6090,1;
close;
}

q_timer = time when the variable was set

if(.@timer < 600) = if *current time* minus time when variable was set, is smaller than 600 seconds execute code below

else = if it's bigger than 600 seconds or more have passed

To change the time which is needed before you get the item. edit the 600 to whatever number you want.

set .@wait, 600-.@timer;
if(.@timer < 600)

Edited by shadowseph
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

@shadowseph: That could be simplified by setting the permanent variable as:

gettimetick(2) + <delay, in seconds>

Then,

if (gettimetick(2) < q_timer) {
   mes "You must wait a little longer~";
   close;
}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  87
  • Reputation:   13
  • Joined:  02/15/12
  • Last Seen:  

You are right Euphy, it was late last night and i can't think properly when i'm sleepy.

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...