Jump to content
  • 0
Sign in to follow this  
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?

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1
9 hours ago, Kavaline said:

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;


	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?

Not tested, but I think will work.

Spoiler

	.@duration = 5; // In Seconds
	.time = gettimetick(2) + .@duration;

	mes "You have " + callfunc("Time2Str", .time) + " to type anything...";
	addtimer(.@duration * 1000, strnpcinfo(NPC_NAME_UNIQUE) + "::OnTimerEnd");
	input(.@text$);

	if (.time < gettimetick(2))
	{
		mes "Everything is fine!";
		mes .@text$;
		deltimer(strnpcinfo(NPC_NAME_UNIQUE) + "::OnTimerEnd");
		close;
	}
	else
	{
OnTimerEnd:
		mes "The time is over!";
		close2;
		end;
	}

 

 

Edited by Cretino

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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