Stevan Corak 0 Posted August 23, 2021 Hello everyone I'm still new to arma3 scripting and I'm having problems with a mission countdown. This is the On Activation callsing [900] execVM "timer.sqf"; And this is the script 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; }; My question is how do I end the task if the timer comes down to 0 Share this post Link to post Share on other sites
sarogahtyp 1109 Posted August 23, 2021 I guess setTaskState is for doing this. Also sleep 1 does not wait 1 second exactly it waits a minimum of 1 second and the deviation adds up. Therefore it's better to compare to mission time: private "_end_time"; _end_time = time + (_this select 0); while { time < _end_time } do { hintSilent format["Time Left: \n %1", [((_end_time - time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring]; sleep 1; }; YOURTASK setTaskState "Failed"; Not tested... Share this post Link to post Share on other sites
Stevan Corak 0 Posted August 23, 2021 Thanks a lot! Share this post Link to post Share on other sites
pierremgi 4910 Posted August 23, 2021 Think about something like this: while { time < _end_time && ((YOURTASK call BIS_fnc_taskState) in ["CREATED","ASSIGNED"]) } do { hintSilent format["Time Left: \n %1", [((_end_time - time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring]; sleep 1; }; if (_time >= _end_time) then {YOURTASK setTaskState "Failed"}; 2 Share this post Link to post Share on other sites