Jump to content
  • 0

Set a timer in NPC script.


Question

Posted

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.

3 answers to this question

Recommended Posts

Posted (edited)

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
Posted

@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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...