Jump to content
Sign in to follow this  
zigzagtshirt

Detect any task complete by side

Recommended Posts

Is there a way I can detect if ANY task has been completed by a side? I know how to detect if a specific task is completed, but I am running a server with randomly generated tasks so I don't know what they'll be ahead of time. Is there an event handler for this? My goal is to reward BLUFOR with additional respawn tickets when any task has been completed. Tasks are generated while in game.

Share this post


Link to post
Share on other sites
1 hour ago, zigzagtshirt said:

Is there a way I can detect if ANY task has been completed by a side? I know how to detect if a specific task is completed, but I am running a server with randomly generated tasks so I don't know what they'll be ahead of time. Is there an event handler for this? My goal is to reward BLUFOR with additional respawn tickets when any task has been completed. Tasks are generated while in game.

 

init.sqf or wherever you seem fit:

GOM_fnc_sidesTaskComplete = {

	_result = [];

	{

		_unit = _x;
		_tasks = _unit getvariable ["BIS_fnc_setTaskLocal_tasks",[]];

		if !(_tasks isEqualTo []) then {

			_hasCompletedTask = (_tasks findIf {[_x] call bis_fnc_taskCompleted} >= 0);
			if (_hasCompletedTask) then {_result pushBackUnique side _unit};

		};

	} forEach allUnits;

	_result

};

Now to check:

_sidesWithCompletedTasks = [] call GOM_fnc_sidesTaskComplete;

Returns an array of all sides that have units with at least one completed task.

Runs for 0.0311ms, pretty quick.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites
On 5/8/2018 at 8:01 AM, zigzagtshirt said:

Is there a way I can detect if ANY task has been completed by a side? I know how to detect if a specific task is completed, but I am running a server with randomly generated tasks so I don't know what they'll be ahead of time. Is there an event handler for this? My goal is to reward BLUFOR with additional respawn tickets when any task has been completed. Tasks are generated while in game.

I am doing a similar thing. Did you ever get this to work. If so mind sharing?

 

Thanks!

 

I am running this in the init.sqf with no luck.

call compile preprocessFileLineNumbers "scripts\ShoterAnimation\init.sqf";
[] execVM "scripts\PrykUav.sqf";
null=[]execVM"CRS\init.sqf";

GOM_fnc_sidesTaskComplete = {

	_result = [[west, 5] call BIS_fnc_respawnTickets];

	{

		_unit = _x;
		_tasks = _unit getvariable ["BIS_fnc_setTaskLocal_tasks",[]];

		if !(_tasks isEqualTo []) then {

			_hasCompletedTask = (_tasks findIf {[_x] call bis_fnc_taskCompleted} >= 0);
			if (_hasCompletedTask) then {_result pushBackUnique side _unit};

		};

	} forEach allUnits;

	_result

};

_sidesWithCompletedTasks = [] call GOM_fnc_sidesTaskComplete;

 

Share this post


Link to post
Share on other sites

So the script does not run when a task is completed. 

 

It works to add tickets, when calling the funtion in the debug command it works no problem. I have the call fnc in the init.sqf but I no longer believe that to be correct. GOM, perhaps you could lend me an idea as to were to put this.

 

Thanks!

Share this post


Link to post
Share on other sites
8 minutes ago, handlebar said:

So the script does not run when a task is completed. 

 

It works to add tickets, when calling the funtion in the debug command it works no problem. I have the call fnc in the init.sqf but I no longer believe that to be correct. GOM, perhaps you could lend me an idea as to wear to put this.

 

Thanks!

The function runs where you call it.

Since the init.sqf runs at mission start in SP and on every connecting player in MP you might want to run the check in the last line some place else.

 

Cheers

 

Share this post


Link to post
Share on other sites

So I am exectuting the script in the init.sqf via

 

[] execVM "scripts\taskcheck.sqf";

taskcheck.sqf

while {true} do

                {

              	call BIS_fnc_showMissionStatus;
                call GOM_fnc_sidesTaskComplete;         

 

                Sleep 25;

               

                hint "Tasks Complete Script Is Running - script check";

 

                };

This doesn't actually check for any task complete, it just adds tickets every 25 seconds without validating that a task is indeed complete.

 

GOM_fnc_sidesTaskComplete = {

	_result = [[west, 3] call BIS_fnc_respawnTickets];

	{

		_unit = _x;
		_tasks = _unit getvariable ["BIS_fnc_setTaskLocal_tasks",[]];

		if !(_tasks isEqualTo []) then {

			_hasCompletedTask = (_tasks findIf {[_x] call bis_fnc_taskCompleted} >= 0);
			if (_hasCompletedTask) then {_result pushBackUnique side _unit};

		};

	} forEach allUnits;

	_result

};

 

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
Sign in to follow this  

×