Jump to content
[evo] dan

Trying to delete triggers created via script, getting error message

Recommended Posts

I am using the following code in my mission to create some triggers, and then if the players succeed or fails at the mission, then deleting the other trigger so as to free up performance and prevent race conditions.

//create all the trigger references here
_trg = createTrigger ["EmptyDetector", _markerLocation];
_trg1 = createTrigger ["EmptyDetector", getMarkerPos _selectedHospital];
_trg2 = createTrigger ["EmptyDetector", getMarkerPos _selectedHospital];

//create the first trigger for joining group
_trg setTriggerArea [10, 10, 0, false];
_trg setVariable ["officer", _unit];
_trg setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_trg setTriggerStatements ["this", "[(thisTrigger getVariable 'officer')] join group (thisList select 0);", ""];

//create the second trigger for leaving the group - don't forget to succeed the mission with this and call a new side mission
_trg1 setTriggerArea [20, 20, 0, false];
_trg1 setVariable ["officer", _unit];
_trg1 setTriggerActivation ["ANY", "PRESENT", true];
_trg1 setTriggerStatements ["(thisTrigger getVariable 'officer') in thisList", format["[(thisTrigger getVariable 'officer')] join grpNull; ['%1','SUCCEEDED'] call BIS_fnc_taskSetState; sideMissionCount = sideMissionCount + 1; call EVODan_fnc_sideMissionSelection; deleteVehicle %2",_missionNumber, _trg2], ""];

//generate a third trigger if the civilian dies and set the mission to fail, but still call for another one to be spawned
_trg2 setTriggerArea [20, 20, 0, false];
_trg2 setVariable ["officer", _unit];
_trg2 setTriggerActivation ["ANY", "PRESENT", true];
_trg2 setTriggerStatements ["!alive (thisTrigger getVariable 'officer')", format["[(thisTrigger getVariable 'officer')] join grpNull; ['%1','FAILED'] call BIS_fnc_taskSetState; sideMissionCount = sideMissionCount + 1; call EVODan_fnc_sideMissionSelection; deleteVehicle %2; deleteVehicle %3;",_missionNumber, _trg, _trg1], ""];

However, as soon as I press start in the editor, I get an error message referring to the "deleteVehicle" command, saying

 

deleteVehicle 1780388: |#|<no shape>;
  
  Error invalid number in experssion

I thought the createTrigger command returned a reference to the trigger, and that all I had to do was refer to this by formatting it into the trigger statements.

Syntax:
createTrigger [type, position, makeGlobal]
Parameters:
[type, position, makeGlobal]: Array
type: String - usually "EmptyDetector"
position: Position2D, Position3D or Object
makeGlobal (Optional): Boolean - locality flag (available since Arma 3 v1.43.129935)
true (Default) - trigger is global Effects of this scripting command are broadcasted over the network and happen on every computer in the network
false - trigger is local Effects of this scripting command are not broadcasted over the network and remain local to the client the command is executed on
Return Value:
Object - created trigger
Syntax:
deleteVehicle object
Parameters:
object: Object

Where have I gone wrong on this as I have checked both Biki pages and this should work from what I read (amongst other forum posts). I have even tried making it into a string but this just delays the error until its triggered.

Share this post


Link to post
Share on other sites

Ok. I have managed to figure this out. I have had to assign the variable to the trigger space using setVariable before referencing it.

 

It now looks like:

//create all the trigger references here
_trg = createTrigger ["EmptyDetector", _markerLocation];
_trg1 = createTrigger ["EmptyDetector", getMarkerPos _selectedHospital];
_trg2 = createTrigger ["EmptyDetector", getMarkerPos _selectedHospital];

//create the first trigger for joining group
_trg setTriggerArea [10, 10, 0, false];
_trg setVariable ["officer", _unit];
_trg setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_trg setTriggerStatements ["this", "[(thisTrigger getVariable 'officer')] join group (thisList select 0);", ""];

//create the second trigger for leaving the group - don't forget to succeed the mission with this and call a new side mission
_trg1 setTriggerArea [20, 20, 0, false];
_trg1 setVariable ["officer", _unit];
_trg1 setVariable ["trigger2", _trg2];
_trg1 setTriggerActivation ["ANY", "PRESENT", true];
_trg1 setTriggerStatements ["(thisTrigger getVariable 'officer') in thisList", format["[(thisTrigger getVariable 'officer')] join grpNull; ['%1','SUCCEEDED'] call BIS_fnc_taskSetState; sideMissionCount = sideMissionCount + 1; call EVODan_fnc_sideMissionSelection; deleteVehicle (thisTrigger getVariable 'trigger2')",_missionNumber], ""];

//generate a third trigger if the civilian dies and set the mission to fail, but still call for another one to be spawned
_trg2 setTriggerArea [20, 20, 0, false];
_trg2 setVariable ["officer", _unit];
_trg2 setVariable ["trigger0", _trg];
_trg2 setVariable ["trigger1", _trg1];
_trg2 setTriggerActivation ["ANY", "PRESENT", true];
_trg2 setTriggerStatements ["!alive (thisTrigger getVariable 'officer')", format["[(thisTrigger getVariable 'officer')] join grpNull; ['%1','FAILED'] call BIS_fnc_taskSetState; sideMissionCount = sideMissionCount + 1; call EVODan_fnc_sideMissionSelection; deleteVehicle (thisTrigger getVariable 'trigger0'); deleteVehicle (thisTrigger getVariable 'trigger1');",_missionNumber], ""];

 

  • Confused 1

Share this post


Link to post
Share on other sites

The problem probably is that you turn the object reference into string, or smth..
Maybe try giving the trigger a name (setVehicleVarName) and using that instead :shrug:

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

×