Jump to content
hellstorm77

Countdown Timer on screen

Recommended Posts

I was wondering if someone could help me with a little script? What im trying to is active a trigger and on doing so a box appears with a count down timer

Share this post


Link to post
Share on other sites

[300] execVM "timer.sqf"

timer.sqf

private "_time";
_time = _this select 0;

while {_time > 0} do {
_time = _time - 1;  
hintSilent format["Time Left: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];	
sleep 1;
};

  • Like 1

Share this post


Link to post
Share on other sites

the only problem i have, when i want to make it 1 hour and 30 mins ([5400] execVM "timer.sqf") the count down is in mins and second (89:59) not 1 hour 30 mins

Share this post


Link to post
Share on other sites

[300] execVM "timer.sqf"

timer.sqf

private "_time";
_time = _this select 0;

while {_time > 0} do {
	_time = _time - 1;  
	hintSilent format["Time Left: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];	
	sleep 1;
};

 

 

Hey cobra been trying to get the timer to work, not sure where I put the time I want it to countdown from.

Share this post


Link to post
Share on other sites

Hey cobra been trying to get the timer to work, not sure where I put the time I want it to countdown from.

 

Its just a script an u cann pass it to it:

[your_start_time_here] execVM "timer.sqf"

do urself a favor and read this: execVM

Share this post


Link to post
Share on other sites

Hello there, I can't figure it out, when I enter the [your_start_time_here] execVM "timer.sqf" in the trigger on activation, it say to me : type script, nothing exept. Could you help me?

Share this post


Link to post
Share on other sites

Have you created the timer.sqf script and placed it in the root of your mission folder?

Share this post


Link to post
Share on other sites

Have you replaced your_start_time_here with a number?

  • Like 1

Share this post


Link to post
Share on other sites

Oh, in the trigger's onAct, it should be:

nul = [your_start_time_here] execVM "timer.sqf";

 

Share this post


Link to post
Share on other sites
On 3/4/2014 at 4:30 PM, cobra4v320 said:

[300] execVM "timer.sqf"

timer.sqf

 


private "_time";
_time = _this select 0;

while {_time > 0} do {
_time = _time - 1;  
hintSilent format["Time Left: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];	
sleep 1;
};
 

 

Excellent contribution, it really helped me a lot. Now, how can I change the color of the numbers that are being discounted? and at the moment of finishing the count as I do so that the information of the counter is beliminated on the screen? Thank you

Share this post


Link to post
Share on other sites
18 hours ago, Teuri said:

Excellent contribution, it really helped me a lot. Now, how can I change the color of the numbers that are being discounted? and at the moment of finishing the count as I do so that the information of the counter is beliminated on the screen? Thank you

For color you might use something like this:

//function:
TAG_fnc_coloredCountdownHint = {
	_color = "#45f442";//green
	_timeLeft = TAG_fnc_countdownEndTime - time;
	if (_timeLeft < 16) then {_color = "#eef441";};//yellow
	if (_timeLeft < 6) then {_color = "#ff0000";};//red
	if (_timeLeft < 0) exitWith {
		//exit and remove eventhandler while politely closing the door
		removeMissionEventhandler ["EachFrame",_thisEventHandler];
		hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color];
	};
	hintSilent parseText format ["Time Left:<br/><t color='%1'>--- %2 ---</t>", _color, [(_timeLeft/3600),"HH:MM:SS"] call BIS_fnc_timetostring];
};

//calling the function:
_duration = 20;
TAG_fnc_countdownEndTime = time + _duration;
addMissionEventHandler ["EachFrame",{[] call TAG_fnc_coloredCountdownHint}];

Cheers

  • Like 4

Share this post


Link to post
Share on other sites
On 3/17/2019 at 1:17 AM, Grumpy Old Man said:

For color you might use something like this:


//function:
TAG_fnc_coloredCountdownHint = {
	_color = "#45f442";//green
	_timeLeft = TAG_fnc_countdownEndTime - time;
	if (_timeLeft < 16) then {_color = "#eef441";};//yellow
	if (_timeLeft < 6) then {_color = "#ff0000";};//red
	if (_timeLeft < 0) exitWith {
		//exit and remove eventhandler while politely closing the door
		removeMissionEventhandler ["EachFrame",_thisEventHandler];
		hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color];
	};
	hintSilent parseText format ["Time Left:<br/><t color='%1'>--- %2 ---</t>", _color, [(_timeLeft/3600),"HH:MM:SS"] call BIS_fnc_timetostring];
};

//calling the function:
_duration = 20;
TAG_fnc_countdownEndTime = time + _duration;
addMissionEventHandler ["EachFrame",{[] call TAG_fnc_coloredCountdownHint}];

Cheers

Sorry to ask this I'm kind of noobish but how/where do I put this in.

 

Also, if I want to have another trigger activate when the timer ends, how would I be able to do that.

 

Will this works in a dedicate server ?

 

Thanks in advance script wizards of BI forum.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×