Jump to content
Sign in to follow this  
maltti

Task update for Dummies!

Recommended Posts

Yes, I have read many articles, tried everything and its not working. Argh!

Here we go:

Mission on my dedicated server.

SetTaskState and everything working fine when playing. BUT when JIP player connects, its just doesn´t update the tasks for a player (All the tasks shows not completed).

What I´m here looking for is a PLAIN and SIMPLE example how to update tasks for a JIP players. Just a basic thing.

Thank you people!

Share this post


Link to post
Share on other sites

Double trigger method is pretty basic:

Trigger 1

Condition: !alive officer (or whatever the task condition should be)

onAct: tsk1 = true; publicvariable "tsk1"

Trigger 2

Condition: tsk1

onAct: task1 settaskstate "succeeded"

Since tsk1 is publicvariabled it will be synced for JIPs and will fire the 2nd trigger, which updates the status.

Share this post


Link to post
Share on other sites

Thanks for a reply. I did what you said and same thing happens again. Working fine when playing, but status is not updated for a jip players.

Share this post


Link to post
Share on other sites

I could be wrong, but I don't think publicVariable persists for JIP players that join after the variable was broadcast, which would explain why shk's solution isn't working for you.

I suggest using the multiplayer framework that's built into the game. Simply place the Multiplayer Framework module into your mission somewhere and use the following line for all of your task updates:

[nil,taskName,"per",rSETTASKSTATE,"Succeeded"] call RE

Share this post


Link to post
Share on other sites

ST dux, could you give me step by step instructions for that module thingie ? Never used one.

Share this post


Link to post
Share on other sites

1. Press F7

2. Double-click on the map

3. Select "Multiplayer Framework"

That's it. Then use the line I posted above to update tasks, replacing "taskName" with the name of the task you wish to update.

Share this post


Link to post
Share on other sites

Trigger 1

Condition: !alive officer (or whatever the task condition should be)

onAct: tsk1 = true; publicvariable "tsk1"

Please don't do that. Only let 1 client or let the server execute a publicVariable command, unless you prefer to have a potential desync bomb.

Share this post


Link to post
Share on other sites

Cannot find that "multiplayer framework" from that list. Only stuffs from "Ambient Animals" to "zone restriction" but not a thing you mentioned. This can´t be that hard... yaaay ! :(

Share this post


Link to post
Share on other sites

No real reason to let a player tell all machines that a task have been completed in most cases (especially if the completion condition is a trigger), instead do if (isServer) then {tsk1 = true; publicvariable "tsk1";};

Also, the second trigger may run before the task is even defined, in which case when the task does get created eventually it will not be updated. Instead, either add a [] spawn {waitUntil {!isNil "tsk1"}; waitUntil {tsk1}; task1 setTaskState "succeeded"; at the end of the script that is creating the task so that it'll never try to update the task before it is created, or make the trigger's condition tsk1 && !isNil "task1" rather than just tsk1. I used the first method a few times and it worked, not 100% sure if the second one works as I haven't tried it and it has some mess-up potential depending on how certain things work, so I recommend the first (aka spawn the task updating code in the script that creates the task after the task was created).

Example script:

{
_x createDiaryRecord["Diary", ["Credits", "Original mission by MechaStalin, overhauled and completely re-scripted by GalZohar"]];
_x createDiaryRecord["Diary", ["Briefing", "Your mission tonight is to eradicate all air defenses from the island of Utes which is currently under CDF control. We must also take this opportunity to destroy a <marker name='obj5'>USMC F-35</marker> that has been stationed here, as we may not get another chance. You may need to capture one of the enemy bases for more explosives. Good luck!"]];

_x setVariable ["tskAAgun1", _x createSimpleTask["Destroy East AA Gun"]]; 
_x setVariable ["tskAAgun2", _x createSimpleTask["Destroy West AA Gun"]]; 
_x setVariable ["tskAAgun3", _x createSimpleTask["Destroy South AA Gun"]]; 
_x setVariable ["tskradar", _x createSimpleTask["Destroy the radar"]]; 
_x setVariable ["tskf35", _x createSimpleTask["Destroy the F35 Fighter"]]; 

(_x getVariable "tskAAgun1") setSimpleTaskDescription["Destroy the <marker name='obj1'>Eastern ZU-23</marker>.", "Destroy East AA Gun", "East AA Gun"];
(_x getVariable "tskAAgun2") setSimpleTaskDescription["Destroy the <marker name='obj2'>Western ZU-23</marker>.", "Destroy West AA Gun", "West AA Gun"];
(_x getVariable "tskAAgun3") setSimpleTaskDescription["Destroy the <marker name='obj3'>Southern ZU-23</marker>.", "Destroy South AA Gun", "South AA Gun"];
(_x getVariable "tskradar") setSimpleTaskDescription["Destroy the <marker name='obj4'>ground based aircraft radar system</marker>.", "Destroy the radar", "Radar"];
(_x getVariable "tskf35") setSimpleTaskDescription["Destroy the <marker name='obj5'>USMC's F-35 fighter</marker>.", "Destroy the F35 Fighter", "F35"];

(_x getVariable "tskAAgun1") setSimpleTaskDestination (getMarkerPos "obj1");
(_x getVariable "tskAAgun2") setSimpleTaskDestination (getMarkerPos "obj2");
(_x getVariable "tskAAgun3") setSimpleTaskDestination (getMarkerPos "obj3");
(_x getVariable "tskradar") setSimpleTaskDestination (getMarkerPos "obj4");
(_x getVariable "tskf35") setSimpleTaskDestination (getMarkerPos "obj5");
} forEach opforUnits;

[] spawn
{
waitUntil {!isNil "obj1flag"};
waitUntil {obj1flag};
{
	(_x getVariable "tskAAgun1") setTaskState "Succeeded";
} forEach opforUnits;
};

[] spawn
{
waitUntil {!isNil "obj2flag"};
waitUntil {obj1flag};
{
	(_x getVariable "tskAAgun2") setTaskState "Succeeded";
} forEach opforUnits;
};

[] spawn
{
waitUntil {!isNil "obj3flag"};
waitUntil {obj1flag};
{
	(_x getVariable "tskAAgun3") setTaskState "Succeeded";
} forEach opforUnits;
};

[] spawn
{
waitUntil {!isNil "obj4flag"};
waitUntil {obj1flag};
{
	(_x getVariable "tskradar") setTaskState "Succeeded";
} forEach opforUnits;
};

[] spawn
{
waitUntil {!isNil "obj5flag"};
waitUntil {obj1flag};
{
	(_x getVariable "tskf35") setTaskState "Succeeded";
} forEach opforUnits;
};

Where opforUnits is an array consisting of all opfor units as the mission is using group respawn and thus if you want the tasks and notes to exist for all playable units in the mission, you need to create and update the tasks/notes for all of them. If the mission is using none/instant/base respawn, you can replace the _x with player and remove the { .... } forEach opforUnits so that it only runs once.

Edited by galzohar

Share this post


Link to post
Share on other sites

@Maltti:

That's strange, but it might not be necessary. As long as the Functions module is up, I think the multiplayer framework should work anyway. Give it a shot.

@galzohar:

That is far more complicated than it needs to be.

Share this post


Link to post
Share on other sites

Hadn't seen yet a good example of using the multiplayer framework, so I honestly don't understand how that is supposed to work and whether or not that would work.

The reason SHK's solution doesn't work is simply the reason I stated - You're trying to update a task before it exists, since trigger line can run before the task-creating-script. When 2 things run independently from eachother yet one uses the other, you need to make sure they run in correct order in 1 way or another. Spawning the scripts that update the tasks in the end of the same script that creates them will guarantee it runs in correct order.

PublicVariable definitely updates the variable for JIP clients. The only thing I don't know is if client ran the publicVariable command if it'll keep working after that client disconnects or not, but it shouldn't be an issue if you do things in a reasonable way, that is, handle objective completion and running publicVariable commands only on the server.

Edited by galzohar

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  

×