Thomas1632 0 Posted October 8, 2020 Hi everybody, As I just wrote in the title, I need to display a countdown in game for one of my scenarios. I want to start the countdown thanks to a trigger. Can someone help me? Thanks! P.S: sorry for my english, I'm french... Share this post Link to post Share on other sites
engima 327 Posted October 8, 2020 [] spawn { private _timeLeft = 60; // Mission time in seconds. while {_timeLeft >= 0} do { hint str _timeLeft; sleep 1; _timeLeft = _timeLeft - 1; }; }; 4 Share this post Link to post Share on other sites
Thomas1632 0 Posted October 8, 2020 Thanks for your reply. I'm a beginner in Arma 3 scripting, where do I have to write these commands ? Thanks ! Share this post Link to post Share on other sites
engima 327 Posted October 8, 2020 Put the code in a file called "mission_counter.sqf" in the Arma 3 mission root folder. (In this case you can skip the first and the last line - the spawn command). Then in the trigger activation field, write: _nil = execVM "mission_counter.sqf"; This means that when the trigger fires, the execVM command is executed. This command starts the file mission_counter.sqf that starts to run in the background. Once in a second, this script displays seconds left as a hint. 4 Share this post Link to post Share on other sites
Enigx 39 Posted October 9, 2020 I have used this script just yesterday in my clan mission. I have simulated a rocket launch countdown with two intermittent image icons of a rocket red and yellow that alternate each second. Very great effect combined with an alarm sound. Put this file timer.sqf in your folder mission (or other but remember to change it on execVM string) timer.sqf /* Activate by trigger or debug console nul = [SECONDS] execVM "timer.sqf"; - SECONDS - <NUMBER>: countdown number in seconds */ private "_time"; _time = _this select 0; while {(_time > 0)} do { _time = _time - 1; // ********* this part is the intermittant images. _imgCnd = ""; if (_time % 2 == 0) then { _imgCnd = "<img size='5' image= 'images\rocketRed.jpg' align='center'/><br/><br/>"; } else { _imgCnd = "<img size='5' image= 'images\rocketYellow.jpg' align='center'/><br/><br/>"; }; _txtCnd = format["<t font='TahomaB' t size='1.25' t color='#FF0000'>Countdown activated.<br/>Time to launch:<br/><t size='2.25'>%1<br/></t>", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring]; hintsilent parseText format[_imgCnd + _txtCnd]; // **************** sleep 1; }; put two images (one red and one yellow for exaple), or whatever you want, in a folder (images\ in the example). Activate the script by trigger or debug console (on global effect of course) by: nul = [SECONDS] execVM "timer.sqf"; Seconds: duration in second of the countdown (ie 5min = 300, -> nul = [300] execVM "timer.sqf";) The result is a countdown with the two images that alternate each second. if you don't want the image substitue with this (that is the same of enigma, the difference is that the time is in mm:ss and with a more actractive colors)) /* Activate by trigger or debug console nul = [SECONDS] execVM "timer.sqf"; - SECONDS - <NUMBER>: countdown number in seconds */ private "_time"; _time = _this select 0; while {(_time > 0)} do { _time = _time - 1; _txtCnd = format["<t font='TahomaB' t size='1.25' t color='#FF0000'>Countdown activated.<br/>Time to launch:<br/><t size='2.25'>%1<br/></t>", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring]; hintsilent parseText format[_txtCnd]; sleep 1; }; Salut 2 Share this post Link to post Share on other sites
Thomas1632 0 Posted October 9, 2020 Hi, thanks for all your replies! I solved my problem thanks to you both! Share this post Link to post Share on other sites
ZaellixA 383 Posted October 10, 2020 Just keep in mind that since the scheduler is not very precise, the deviation from the actual timing may be quite important when you are "counting" for a "considerable" amount of time... 1 Share this post Link to post Share on other sites
Melody_Mike 127 Posted October 11, 2020 Heya! Perhaps you could use the BI version of the timer, which as far as I know, doesn't require scheduling. Pop this into a script file ( "timer.sqf" ) and execute it from a trigger ( nul = execVM "timer.sqf"; ). Notice I put 60 seconds in the timer: _initialCountDown = [60] call BIS_fnc_countDown; addMissionEventHandler ["EachFrame",{hintSilent format["%1", [(([0] call BIS_fnc_countdown)/60)+.01,"HH:MM"] call BIS_fnc_timetostring]}]; 2 Share this post Link to post Share on other sites