Jump to content
  • 0
Kavaline

How create a 'input' with 'timer'?

Question

Hi, I want a script that gives the player 5 seconds to type a word, with 'input'. But when the time runs out, the script runs normally, and after, read the event label of the time out.

Here is what I tried:

	mes "type anything in 5 seconds";
	addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::On5secs");
	input(.@text);
	deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::On5secs");
	next;
	mes "you did it";
	close;

On5secs:
	mes "time over";
	close;

Maybe is impossible for the 'timer' force close the 'input', but at least, I want a way that after the 'input', run the time out label if the time out, without run the lines above of the script. How I can do it?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Heya,

Don't use timers that run scripts on players (you should avoid using the addtimer command entirely). The reason for that is you're attempting to run two scripts at once, and the script engine doesn't support that very well. Set the timer as a local variable instead:

	mes "type anything in 5 seconds";
	[email protected] = gettimetick(0) + 5000;
	input([email protected]);
	clear();
	
	if (gettimetick(0) >= [email protected]) {
		mes "time over";
		close;
	}
	
	mes "you did it";
	close;

 

  • Upvote 1
  • MVP 1
Link to comment
Share on other sites

  • 0

Thanks for the answers 🙂

52 minutes ago, Tokei said:

Heya,

Don't use timers that run scripts on players (you should avoid using the addtimer command entirely). The reason for that is you're attempting to run two scripts at once, and the script engine doesn't support that very well. Set the timer as a local variable instead:

	mes "type anything in 5 seconds";
	[email protected] = gettimetick(0) + 5000;
	input([email protected]);
	clear();
	
	if (gettimetick(0) >= [email protected]) {
		mes "time over";
		close;
	}
	
	mes "you did it";
	close;

 

Works perfectly for what I want, because more than one player will activate the NPC. Thanks for the tip 👍

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

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.