Jump to content
Sign in to follow this  
gfresco

HELP with task script for dedicated server.

Recommended Posts

Hey. i need help getting a script that selects and assigns tasks for players on a dedicated server. Currently sometimes it assigns one task for everyone, sometimes a different one, sometimes no task at all. in editor preview/sp it works flawlessly. This is how the script works.

in the editor where players spawn in is a trigger activated by independent present (the playable units) with the activation area covering where players spawn/start. This is its init:

nul = []execVM "Tasks\random1.sqf";

in the init.sqf of the mission folder:

//Side task system
missions = [1,2,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20];

in tasks\random1.sqf:

if ((count missions) == 0) then {hint "All available assignments completed"};
_mission = missions select (floor(random(count missions)));

if (_mission == 1) then {[] execVM "tasks\mission1.sqf"};
if (_mission == 2) then {[] execVM "tasks\mission2.sqf"};
if (_mission == 3) then {[] execVM "tasks\mission3.sqf"};
if (_mission == 4) then {[] execVM "tasks\mission4.sqf"};
if (_mission == 5) then {[] execVM "tasks\mission5.sqf"};
if (_mission == 6) then {[] execVM "tasks\mission6.sqf"};
if (_mission == 7) then {[] execVM "tasks\mission7.sqf"};
if (_mission == 8) then {[] execVM "tasks\mission8.sqf"};
if (_mission == 9) then {[] execVM "tasks\mission9.sqf"};
if (_mission == 10) then {[] execVM "tasks\mission10.sqf"};
if (_mission == 11) then {[] execVM "tasks\mission11.sqf"};
if (_mission == 12) then {[] execVM "tasks\mission12.sqf"};
if (_mission == 13) then {[] execVM "tasks\mission13.sqf"};
if (_mission == 14) then {[] execVM "tasks\mission14.sqf"};
if (_mission == 15) then {[] execVM "tasks\mission15.sqf"};
if (_mission == 16) then {[] execVM "tasks\mission16.sqf"};
if (_mission == 17) then {[] execVM "tasks\mission17.sqf"};
if (_mission == 18) then {[] execVM "tasks\mission18.sqf"};
if (_mission == 19) then {[] execVM "tasks\mission19.sqf"};
if (_mission == 20) then {[] execVM "tasks\mission20.sqf"};

missions = missions - [_mission];

and this is an example of one of the mission sqf's (the rest of the mission is handled via ig triggers):

_grp = createGroup east;
_pos = getmarkerpos "spawn2";
officer2 = _grp createUnit ["caf_ag_me_t_ak47", _pos, [], 5, "FORM"];
officer2 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn3";
officer3 = _grp createUnit ["caf_ag_me_t_ak74", _pos, [], 5, "FORM"];
officer3 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
officer4 = _grp createUnit ["caf_ag_me_t_pkm", _pos, [], 5, "FORM"];
officer4 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
ep = _grp createUnit ["caf_ag_me_t_pkm", _pos, [], 10, "FORM"];
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
ep2 = _grp createUnit ["caf_ag_me_t_ak74", _pos, [], 10, "FORM"];

//Task4 - Raid insurgent compound. 
OPCOM=[GUER,"HQ"];
OPCOM sideChat "Transmitting additional assignment, over.";
sleep 3;
[GUER,"task_19",["Raid this compound and kill the training commanders. Act quickly to ensure they do not flee the area, otherwise the search for them may be extensive and painstaking.","Eliminate the commander","Eliminate Insurgent"],objNull,true] call BIS_fnc_taskCreate;
hint "New Secondary Objective Assigned.";
"compound2" setmarkeralpha 0.5;

Anyone know where this script is going wrong?

Share this post


Link to post
Share on other sites

GUER is not a valid side. Use independent or side player or some other valid reference to whoever your giving the mission to.

if ((count missions) == 0) then {hint "All available assignments completed"};
_mission = missions select (floor(random(count missions)));

_spawnMission = _mission execVM (format["tasks\mission%1.sqf", _mission]);

//Is this the right place for this?
//Mission is removed from the list just because it has been assigned, NOT completed
//See below mission script
//missions = missions - [_mission];

_mission = _this select 0;

//I presume these are the commanders to kill
_grp = createGroup east;
_pos = getmarkerpos "spawn2";
officer2 = _grp createUnit ["caf_ag_me_t_ak47", _pos, [], 5, "FORM"];
officer2 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn3";
officer3 = _grp createUnit ["caf_ag_me_t_ak74", _pos, [], 5, "FORM"];
officer3 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
officer4 = _grp createUnit ["caf_ag_me_t_pkm", _pos, [], 5, "FORM"];
officer4 addvest "V_Chestrig_rgr";
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
ep = _grp createUnit ["caf_ag_me_t_pkm", _pos, [], 10, "FORM"];
_grp = createGroup east;
_pos = getmarkerpos "spawn4";
ep2 = _grp createUnit ["caf_ag_me_t_ak74", _pos, [], 10, "FORM"];

//Task4 - Raid insurgent compound. 
OPCOM=[side player,"HQ"];
OPCOM sideChat "Transmitting additional assignment, over.";
sleep 3;
[group player,"task_19",["Raid this compound and kill the training commanders. Act quickly to ensure they do not flee the area, otherwise the search for them may be extensive and painstaking.","Eliminate the commander","Eliminate Insurgent"],objNull,true] call BIS_fnc_taskCreate;
hint "New Secondary Objective Assigned.";
"compound2" setmarkeralpha 0.5;

waitUntil {["task_19"] call BIS_fnc_taskState == "Succeeded" || {!alive _x}count units player};
if (["task_19"] call BIS_fnc_taskState == "Succeeded") then {
missions = missions - [_mission];
}else{
//could fail and remove the mission here or ??
};

Edited by Larrow

Share this post


Link to post
Share on other sites

Firstly, your sideChat line. According to the BIKI, sideChat has to be used this way:

[side, string] sideChat chatText

As Larrow already stated, your side declaration "GUER" is not correct. You need to use one of the following:

blufor opfor independent resistance civilian (side player)

Same for your call of "BIS_fnc_taskCreate".

Secondly, if you don't want to assign the result of a script to a variable then simply don't do it. *duh* ;)

Thirdly, make a space betweem [] and "execVM" as I don't know if that can cause a problem. Anyway, your line can actually look like this:

execVM "Tasks\random1.sqf"; //[] is not needed if no parameters are given and no return value is expected

Then, instead of making a construction like:

_mission = missions select (floor(random(count missions)));

you may use what's already available:

_mission = missions call BIS_fnc_selectRandom;

does the job and is better readable.

Also, you should not use public variables unless you need to, especially if you use such "un-unique" names like " missions " or "officer2". If you should coincidently have two different scripts which both use a public variable called "missions", you're f**ked . Because nobody and nothing warns you if you overwrite an already existing variable. So be careful with that.

Well, I don't know if there's still some issues, but for now correct these and try again.

TIP: Launch ArmA 3 with the startup parameter "-showScriptErrors" (with the dash at the beginning). This will show you a box in the upper half of your screen whenever something is wrong with a script used in your mission. This makes debugging a lot easier as you instantly see what went when wrong.

In Steam, you can do this by right-clicking ArmA 3 in your library and then click "Set Launch Options..." in the "General" tab.

Best regards,

Johnny

Edited by waltenberg

Share this post


Link to post
Share on other sites
Then, instead of making a construction like:

PHP Code:

_mission = missions select (floor(random(count missions)));

you may use what's already available:

PHP Code:

_mission = missions call BIS_fnc_selectRandom;

does the job and is better readable.

And its slower, why call a function for that insignificant piece of code, that tbo reads perfectly alright. Ok slower here really is not going to make a difference but meh

Share this post


Link to post
Share on other sites

I get it. And tbh, I am concerned about code performance as well. But for the sake of "meh", I prefer the BIS function call if it doesn't matter. ^_^

Share this post


Link to post
Share on other sites

"GUER" is valid. Try doing a "hint str independent", it should say "GUER", just as blufor should say "WEST"

sideChat will also work just fine with a unit object.

As for your question, let the server select the mission, run the mission script and I'd suggest using SHK taskmaster it broadcast the tasks. Currently every player will get a random mission since everyone runs the script

---------- Post added at 01:02 PM ---------- Previous post was at 01:01 PM ----------

I meant "hint str (side player)" as a GUER unit

Share this post


Link to post
Share on other sites

Ah, correct :) Got it confused with west/east

Edited by cuel

Share this post


Link to post
Share on other sites

Thanks a ton for all the assistance folks, i am going to sit down tonight and try to tighten it up. I do really appreciate the help people here provide

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  

×