Jump to content
Sign in to follow this  
jakeplissken

Need a script to end task when vehicles destroyed.

Recommended Posts

I have a mission I am working on using Stratis. there are markers that spawn enemies and a radar vehicle that must be destroyed.

I have this code that someone sent me, but this does not really work. I am creating a single player mission and I do not need BIS_fnc_mp.

//put all of this in the server-only section of your scripting (e.g. init.sqf's server only section, initServer.sqf)
trg_whenAllOpforAreDead = createTrigger ["EmptyDetector", [0,0,0]];
_cond	= "(!alive radar1) <= 0";
_onAct	=
"
[
{
task_1 setTaskState 'Succeeded';
["TaskSucceeded",["","Destroy the radar equipment."]] call BIS_fnc_showNotification;
},
'bis_fnc_spawn'
] call BIS_fnc_MP;
";
_onDeact	= "";
trg_whenAllOpforAreDead setTriggerActivation ["NONE", "NOT PRESENT", true];
trg_whenAllOpforAreDead setTriggerStatements [_cond, _onAct, _onDeact];

I am looking for code that will check for a destroyed vehicle and then move to another task. I want to do it this way instead of covering the map in lines and modules. I have had a lot of problems finding a template for this method.

Thanks.

Share this post


Link to post
Share on other sites
waitUntil {!alive _vehicle};

["TaskID", "Succeded"] call BIS_fnc_taskSetState;

["TaskIDofNextTask", "ASSIGNED"] call BIS_fnc_taskSetState;

Share this post


Link to post
Share on other sites

Thank you. My mission code is now this. But it will not execute when I test the mission in the editor at all.

waitUntil { !isNil {player} };
waitUntil { player == player };

switch (side player) do
{

case WEST: // BLUFOR briefing goes here
{
player createDiaryRecord ["Diary", ["*Radar must be taken down.*", "*The OPFOR radar is stopping air traffic, we must take it down.*"]];

//Task1 - COMMENT
task_1 = player createSimpleTask ["Destroy AA Radar."];
task_1 setSimpleTaskDescription ["Destroy the radar.","Destroy the AA radar that OPFOR is using to take down allied planes.","Radar."];
task_1 setSimpleTaskDestination (getMarkerPos "task_1");
task_1 setTaskState "Assigned";
player setCurrentTask task_1;

waitUntil {!alive _vehicle};

["task_1", "Succeeded"] call BIS_fnc_taskSetState;

["task_2", "ASSIGNED"] call BIS_fnc_taskSetState;

//Task2 - COMMENT
task_2 = player createSimpleTask ["TASKNAME"];
task_2 setSimpleTaskDescription ["TASK DESCRIPTION","Example Task","WHAT WILL BE DISPLAYED ON THE MAP"];
task_2 setSimpleTaskDestination (getMarkerPos "task_2");

};

Is there something I am missing? This just will not run. Thanks very much for your help.

This is my init.sqf.

author = "John Cartwright";
briefingName = "Destroy OPFOR AA radar.";
onLoadName = "OPFOR demolition.";
onLoadMission = "Destroy the OPFOR radar installation.";
loadScreen = "\A3\Missions_F\data\img\Showcase_SCUBA_overview_CA.paa";

overviewText = "Free the skies of Stratis.";
overviewPicture = "\a3\missions_f\data\img\Showcase_SCUBA_overview_CA.paa";

class CfgDebriefing
{
class End1
{
       	title = "The radar was demolished, good work.";
       	subtitle = "";
       	description = "Now the skies are free once again.";
      		picture = "b_inf";
	pictureColor[] = {0.0,0.3,0.6,1};
};
class Loser: End1
{
       	title = "$STR_A3_Showcase_SCUBA_endLoser_title";
       	description = "$STR_A3_Showcase_SCUBA_endLoser_text";
};
};

_nul = [] execVM "scripts\player.sqf";
_nul = [] execVM "scripts\count.sqf";
_nul = [] execVM "scripts\east.sqf";

Edited by jakeplissken
Added more code.

Share this post


Link to post
Share on other sites

Take out the second BIS_fnc_taskSetState, it's redundant. And you need to replace "_vehicle" with the name of your vehicle/object/unit that needs to be destroyed/dead.

And in your second block of code, firstly that's your description.ext file, not the init.sqf, secondly the three script calls at the bottom of it won't work (at least I don't think so), so you need to put those at the being of your first code block after the two waitUntil lines at the top.

Share this post


Link to post
Share on other sites

Also, your switch block is syntactically incorrect as it's missing the closing "};" at the very end of the code block. Btw, if you only have one case in your switch, there's no reason to use a switch. Rather use:

if(playerSide == west) then {
   /* your code here */
};

And you should start your ArmA 3 with the startup parameter -showScriptErrors (with the dash at the beginning). With that, whenever a script error occurs, a grey box will pop up in your upper screen half showing you what went wrong where in which file.

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  

×