Jump to content
  • 0

How create a 'input' with 'timer'?


Kavaline

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.01
  • Content Count:  18
  • Reputation:   1
  • Joined:  02/15/20
  • Last Seen:  

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

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

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";
	.@limit = gettimetick(0) + 5000;
	input(.@text);
	clear();
	
	if (gettimetick(0) >= .@limit) {
		mes "time over";
		close;
	}
	
	mes "you did it";
	close;

 

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

  • 1

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

Just set temporary variables when time run out, when input is done >> check that variables.

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

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.01
  • Content Count:  18
  • Reputation:   1
  • Joined:  02/15/20
  • Last Seen:  

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";
	.@limit = gettimetick(0) + 5000;
	input(.@text);
	clear();
	
	if (gettimetick(0) >= .@limit) {
		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...