How create a 'input' with 'timer'?

Kavaline

New member
Messages
14
Points
0
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?

 
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.

Code:
	.@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;
	}

 
Last edited by a moderator:
Back
Top