Jump to content
Pablogamonal

Finish countdown to run script

Recommended Posts

I've this script

Quote

barricada2 removeAction (_this select 2);
[120] execVM "Barricadas\cuenta2.sqf"

that executes this one:

Quote

private "_time";
_time = _this select 0;

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


barricada2 setPos [2679.017,4803.602,6.477];
barricada2 setDir 352.207;
hint "Paso despejado.";
 

 

And I don't know how to use "terminate" command to finish the countdown and the execution of the script. Any ideas? 

Thx

Share this post


Link to post
Share on other sites
6 minutes ago, wogz187 said:

@Pablogamonal,
No need to terminate. You can run your script after the while loop. Check this out,


call {
	3 spawn {
		while {_this >1} do {
			sleep 1;
			_this= _this -1
		};
	systemChat "Countdown finished"
	}
}

If you put your script where the systemChat is then it will execute after the countdown.

Have fun!

Thanks for the reply. I think I have expressed myself wrong. What I want is to cancel the execution of the script. In this case, through a trigger, the script can only be run if there are two objects inside the trigger. What I want to do is that if one of the objects comes out, the countdown is canceled.

Share this post


Link to post
Share on other sites

Modify the script as

private "_time";
_time = _this select 0;

stopCountdown = 0;
publicVariable "stopCountdown";

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

barricada2 setPos [2679.017,4803.602,6.477];
barricada2 setDir 352.207;
hint "Paso despejado.";

To stop it, place a trigger that executes this

stopCountdown = 1;
publicVariable "stopCountdown";

I used publicVariable because I used this method in a MP mission running it by interaction menu, but it is the same.

 

If you want activate/deactivate countdown whenever you want you can use also ACE interaction menu. In this case

1) load ACE mod in your mission

3) Barricadas\cuenta2.sqf as I wrote above

2) Create initPlayerLocal.sqf in mission folder (if not already present) and add these strings in it

 authPlyrs = ["XXXXXXX", ... , "YYYYY"];    // <-- ADD HERE THE STEAM ID OF THE PLAYER/S ENABLED TO ACTIVATE/DEACTIVATE COUNTDOWN BY ACE COMMANDS
                _uidP = getPlayerUID player;
                if (_uidP in authPlyrs) then {
                    _actionAct = {[[120],"Barricadas\cuenta2.sqf"] remoteExec ["BIS_fnc_execVM",0];};
                        _CallAct = ['ActivateCoutdown', 'Activate Coutdown', '', _actionAct, {true}] call ace_interact_menu_fnc_createAction;
                        [player, 1, ["ACE_SelfActions"], _CallAct] call ace_interact_menu_fnc_addActionToObject;
                    
                        _actionDeact = {stopCountdown = 1;publicVariable "stopCountdown";};
                        _CallDeact = ['DeactivateCoutdown', 'Deactivate Coutdown', '', _actionDeact, {true}] call ace_interact_menu_fnc_createAction;
                        [player, 1, ["ACE_SelfActions"], _CallDeact] call ace_interact_menu_fnc_addActionToObject;
                };

It works also in MP. From editor run mission as MP to activate ACE and steam ID.

Two commands will be available, for enabled players withe the indicated steam ID, to start and stop countdown.

 

Cheers

Share this post


Link to post
Share on other sites

@Pablogamonal,

All wrapped up in a demo for you,
you_trigger_check (drive)
 

Spoiler

you_trigger_check={

	params [["_units", allPlayers], ["_trigger", objNull], ["_time", [false, 5]], ["_code", {systemChat "Countdown finished"}]];

	//systemChat "Spawned... waiting";

	waitUntil {uiSleep 1; {_x inArea _trigger} count _units == count _units};
	private _show= _time select 0;
	private _time= _time select 1;
	while {_time >0} do {

		if({_x inArea _trigger}count _units == count _units) then {
			if (_show) then {hintSilent str _time};
			uiSleep 1;
			_time = _time -1
		} else {_time=0}
	};

	if({_x inArea _trigger}count _units == count _units) then {
		_this spawn _code
	} else {
		_this spawn you_trigger_check
	}
};

example call from trigger On Activation:


call {
[[unit_1, unit_2], thisTrigger, [true, 8]] spawn you_trigger_check
} 

_code respects script params and provides "_this" within your code block to select units and trigger if need be
 


Have fun!

  • Like 2

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

×