Jump to content
Sign in to follow this  
johnnyboy

Add new task dynamically and have it show for all MP players

Recommended Posts

Edit: Solution to this problem is in Post #3 below.

I found alot of Task related posts, but not the solution to this problem.

I have 5 tasks that I created using modules in editor. They are synched to all 10 playable units for my Group Respawn mission. Setting current tasks and setting task states works fine for all these tasks placed via the editor.

However, I have an additional task that I only want to reveal during mission play, so I am creating and assigning that via a script. I have this code in a function that I call with bis_func_mp:

task7 = player createSimpleTask ["Protect the Ship!"]; 
_td =  "The VBIED target is the ship!  We must prevent the boats from hitting the ship.  This is our top priority.  "+ SHIP_PATH_TEXT;
task7 setSimpleTaskDescription [_td,"Protect the Ship!",""]; 
task7 setTaskState "Assigned"; 
player setCurrentTask task7;

This works for current player except I am not seeing the nice task notification when I assign the task. And more importantly, after getting killed when i spawn to the next playable unit, I do not see this new task at all.

What gives?

I thought maybe that since editor placed modules that are synched to all playable units work, then maybe I should change this code to assign to all playable units. In the code below GG is a global array containing all 10 playable units:

{task7 = _x createSimpleTask ["Protect the Ship!"]; } foreach GG;
_td =  "The VBIED target is the ship!  We must prevent the boats from hitting the ship.  This is our top priority.  "+ SHIP_PATH_TEXT;
task7 setSimpleTaskDescription [_td,"Protect the Ship!",""]; 
task7 setTaskState "Assigned"; 
{_x setCurrentTask task7;} foreach GG;

I hoped the code above would create and assign new tasks to all playable units. But in this case only the Task is created. This Task has a name but does not have a description. And it is not assigned as current. And it does not show up for a respawned player.

Any suggestions?

Edited by JohnnyBoy

Share this post


Link to post
Share on other sites
Three words, "F*** simple task",

Jshock, I love you man. This is simpler and works like a charm on dedicated server. All spawned into units showed the new task. In the code below _td is variable with task description in it, and GG is an array of playable units that I want the task assigned to:

_td =  "The VBIED target is the ship!  We must prevent the boats from hitting the ship.  This is our top priority.  "+ SHIP_PATH_TEXT;
task7 = [[], GG, [_td, "Protect the Ship!",""], nil, "ASSIGNED", 10, true, true] call BIS_fnc_setTask; 
[task7] call BIS_fnc_taskSetCurrent;

The above code is in a separate function called addTask.sqf, which I am calling from a trigger with:

[[], "addTaskEverywhere" ] call BIS_fnc_MP;

And this is in my init.sqf:

addTaskEveryWhere = compileFinal "_handle = execVM ""Scripts\addTask.sqf"";";

I don't know if I really need to BIS_fnc_MP these task functions or not, but it appears to work, so if it ain't broke, don't fix it! :)

Edited by JohnnyBoy

Share this post


Link to post
Share on other sites
I don't know if I really need to BIS_fnc_MP these task functions or not, but it appears to work, so if it ain't broke, don't fix it! :)

Yeah I was thinking more JIP there, but I'm not sure if the "global" setting in fnc_setTask applies to them too or not.

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  

×