Jump to content
Sign in to follow this  
craptakular

Implement Tasks for Join in Progress MP players

Recommended Posts

Briefing.sqf:

//Task1
task_1 = player createSimpleTask ["Destroy Radar Position"];
task_1 setSimpleTaskDescription ["Destroy Radar Position","Destroy Radar Position","Objective 1"];
task_1 setSimpleTaskDestination (getMarkerPos "task_1");
task_1 setTaskState "Assigned";
player setCurrentTask task_1;

//Task2
task_2 = player createSimpleTask ["Destroy Training Camp"];
task_2 setSimpleTaskDescription ["Destroy Training Camp","Destroy Training Camp","Objective 2"];
task_2 setSimpleTaskDestination (getMarkerPos "task_2");

Trigger when Task 1 Completed: ON ACTIVATION

task_1 setTaskState "Succeeded";
["TaskSucceeded",["Task1 Completed"]] call bis_fnc_showNotification;
task_2 setTaskState "Assigned";
["TaskAssigned",["Now do Task 2"]] call bis_fnc_showNotification;

The above code works perfectly for everyone who is connected to the server but as soon as new people connect to the server they cannot see that Objective 1 is complete as it it still stuck on Assigned, but for the people who have been connected 100% of the time it correctly is marked as "completed".

How can I fix this? I don't want to use the modules and marker thing in the editor as it is a very cumbersome system and is hard to read when you have AI down, waypoints and triggers all over the map.

I did find a suggestion from an ARMA developer, he suggested using BIS_fnc_MP but I cannot work out how to incorporate my trigger code into the function, can someone help me?

https://community.bistudio.com/wiki/BIS_fnc_MP

Share this post


Link to post
Share on other sites

You could set a global variable on task completion and then use it for JIP to skip to the next task in your script.

DasClark

Share this post


Link to post
Share on other sites

Yes, DasClark is right - just separate the logic so that one trigger sets and publishes the variable (taskKillOfficerCompleted = true; pyblicVariable taskKillOfficerCompleted), another - works on this variable as condition and updates the task.

Share this post


Link to post
Share on other sites

Well, I'm writing from work now, so I can't post an example mission... But here's how to create such a mission:

1.Add a playable (say, BLUFOR) soldier for the player

2.Add an enemy unit named "officer"

init.sqf

task1_officerKilled = false; // Set the global variable - task not yet completed
task1 = player createSimpleTask ["Kill the officer!"]; // Create the task. Important - this creates a local task for the player, so if player teamswitches, the task would disappear
task1 setTaskState "Assigned"; // Assign the new task

Trigger 1 (this trigger monitors the game conditions and sets the corresponding task variable)

Condition

!alive officer

On activation

task1_officerKilled = true; publicVariable "task1_officerKilled";

Trigger 2 (this trigger monitors the task variable and updates the task state)

Condition

task1_officerKilled

On activation

task1 setTaskState "Succeeded";

You can monitor the state of task1_officerKilled variable in the Watch section of "Debug" window in the "Esc" menu, while previewing the mission.

Share this post


Link to post
Share on other sites

Create the file initPlayerLocal.sqf. Anything in that file will run on the client that connects to your mission and it's JIP compatible too.

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  

×