Jump to content

Recommended Posts

Hi guys, I found this code for the tasks in a Steam thread.

 

if ((!isServer) && (player != player)) then
{
  waitUntil {player == player};
}; 

0 = [] spawn {
sleep 1;

[player,["task1"],["Go to the area and destroy enemy artillery","Go to the area and destroy enemy artillery",""], getPosATL arty_1 ,1,2,true,"destroy"] call BIS_fnc_taskCreate;
waitUntil{!(alive arty_1)};
["task1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[player,["task2"],[format[" Go to the area and kill two officers %1",name unit_1],format[" Go to the area and kill two officers %1",name unit_1],""], getPosATL unit_1,1,2,true,"kill"] call BIS_fnc_taskCreate;
waitUntil{!(alive unit_1)};
["task2", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[player,["task3"],[format[" Go to the area and kill two officers %1",name unit_2],format[" Go to the area and kill two officers %1",name unit_2],""], getPosATL unit_2,1,2,true,"kill"] call BIS_fnc_taskCreate;
waitUntil{!(alive unit_2)};
["task3", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[player,["task4"],["Grab intel","Grab intel",""], getMarkerPos "marker_0" ,1,2,true,"move"] call BIS_fnc_taskCreate;
waitUntil{player distance (getMarkerPos "marker_0") < 2};
["task4", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[player,["task5"],["Exfill at the base ","Exfill at the base ",""], getMarkerPos "marker_1" ,1,2,true,"move"] call BIS_fnc_taskCreate;
waitUntil{player distance (getMarkerPos "marker_1") < 10};
["task5", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

};

 

In the editor it works correctly. On the server it works, but when the artillery is destroyed, which is the first task, it jumps and it is completed, but the "destroy" icon does not disappear from the map. The other icons that are generated do disappear as each task is completed. Can somebody help me. Thanks.

Share this post


Link to post
Share on other sites

First of all, this script is not optimized. The first condition is just a waste of code. In MP, you always think about where you need to run a script.

Creating tasks is not difficult but you must define who are tasked.

Here, lets say all players (because you are using player without condition)

And it's the jungle with commands like createSimpleTask, createTask, taskState, taskResult, BIS_fnc_setTask, BIS_fnc_setTaskLocal,... +... + modules and functions for modules.

Anyway, these BIS functions are sometimes complex (in term of broadcast, JIP, displays...).
So, I suggest you to read these to pages:
https://community.bistudio.com/wiki/Arma_3:_Task_Framework_Tutorial

https://community.bistudio.com/wiki/Arma_3:_Task_Framework

 

To make it short, the main function: BIS_fnc_taskCreate is AG EG  That means you can script from where you want , and, as the effect is global, the broadcast is easy (no remoteExec needed, but will depend on what you paremetered for this function).

That doesn't mean you must run it everywhere! init.sqf or initPlayerLocal.sqf is not fine. think about initServer.sqf... where player doesn't exist in MP dedicated server.

The reason why your script referring to player is not a good idea.

 

So, think about initServer.sqf, and read the 3 links above.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks Pierre, I will follow your advice. I keep you informed.

Share this post


Link to post
Share on other sites

Hi guys:
Following Pierre's instructions, I have given some thought to the topic of tasks and this code if it works correctly on the server. The last task I have introduced with positioning on the map, to, if necessary, not use invisible markers. Friends like Pierre will be able to improve this code, sure they will, but it works and it's simple, enough. Thanks Pierre.

 

if (!isServer) exitWith {};

0 = [] spawn {
sleep 1;

0 = [] spawn {
[west,["task1"],["Go to the area and destroy enemy artillery","Go to the area and destroy enemy artillery",""], getPosATL arty_1 ,1,2,true,"destroy"] call BIS_fnc_taskCreate;
waitUntil{!(alive arty_1)};
["task1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;
};

waitUntil{!(alive arty_1)};
[west,["task2"],[format[" Go to the area and kill two officers %1",name unit_1],format[" Go to the area and kill two officers %1",name unit_1],""], getPosATL unit_1,1,2,true,"kill"] call BIS_fnc_taskCreate;
waitUntil{!(alive unit_1)};
["task2", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[west,["task3"],[format[" Go to the area and kill two officers %1",name unit_2],format[" Go to the area and kill two officers %1",name unit_2],""], getPosATL unit_2,1,2,true,"kill"] call BIS_fnc_taskCreate;
waitUntil{!(alive unit_2)};
["task3", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[west,["task4"],["Grab intel","Grab intel",""], getMarkerPos "marker_0" ,1,2,true,"move"] call BIS_fnc_taskCreate;
waitUntil{sleep 1;(({isPlayer _x && _x distance (getMarkerPos "marker_0") < 5} count playableUnits > 0));};
["task4", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

[west,["task5"],["Exfill at the base ","Exfill at the base ",""], getMarkerPos "marker_1" ,1,2,true,"move"] call BIS_fnc_taskCreate;
waitUntil{sleep 1;(({isPlayer _x && _x distance (getMarkerPos "marker_1") < 5} count playableUnits > 0));};
["task5", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

_markerstr = createMarker ["marker_2",[11412,20620.8]];
_markerstr setMarkerShape "ICON";
[west,["task6"],["Exfill at the base ","Exfill at the base ",""], getMarkerPos "marker_2" ,1,2,true,"move"] call BIS_fnc_taskCreate;
waitUntil{sleep 1;(({isPlayer _x && _x distance (getMarkerPos "marker_2") < 5} count playableUnits > 0));};
["task6", "SUCCEEDED",true] spawn BIS_fnc_taskSetState;

};

 

  • Like 1

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

×