Jump to content
Sign in to follow this  
DanBonehill

Help with ending a TVT mission

Recommended Posts

Hi all,

I hope you can help. I've got a TVT mission for my clan to play where each side compete to complete 3 objectives. The winner will be the team who completes the most objectives. (2 or more) I can't use the normal End Triggers as this isn't enough.

Someone has given me the below code as a way of counting who has completed the most objectives and thus end the mission.

_count = 0;
{
   if (taskState _x == "Succeeded") then {
       _count = _count + 1;
   };
} foreach [task1, task2, task3, task4, task5, task6];

if (_count >= 2) then {
   ["end1", true, true] call BIS_fnc_endMission;
} else {
   ["end1", false, true] call BIS_fnc_endMission;
};

However when the trigger fires to run the script I get the following error in my RPT files

_count = 0;
{
if (taskState _x == "Succeeded") then {
_cou>
 Error position: <taskState _x == "Succeeded") then {
_cou>
 Error taskstate: Type Bool, expected Task

I'm still fairly new to scripting and can't figure out how to amend this correctly or any other way to get this to work.

If anyone could help that would be great.

To clarify I need something that will count up how many objectives are "successful" and whichever side has the most wins and the other looses.

Share this post


Link to post
Share on other sites

It is expecting the task IDs to be passed in, try putting " " around your task1, task2, etc.

Or try and use the BIS function, taskCompleted, in the same manner you are checking for it with the "== Succeeded":

_count = 0;

if ([_x] call BIS_fnc_taskCompleted) then {

_count = _count +1;

} forEach ["task1", "task2", ...];

if (_count >= 2) then {/* end mission stuff  */};

Edited by JShock

Share this post


Link to post
Share on other sites
It is expecting the task IDs to be passed in, try putting " " around your task1, task2, etc.

Or try and use the BIS function, taskCompleted, in the same manner you are checking for it with the "== Succeeded":

_count = 0;

if ([_x] call BIS_fnc_taskCompleted) then {

_count = _count +1;

} forEach ["task1", "task2", ...];

if (_count >= 2) then {/* end mission stuff  */};

Thanks so much. That works perfectly

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  

×