Jump to content
Sign in to follow this  
1para{god-father}

Delete Trigger via script

Recommended Posts

I am creating a trigger as follows:-

_triggerpremove = createTrigger["EmptyDetector",[getPos _vehiclpilot1 select 0,getPos _vehiclpilot1 select 1,0]];
_triggerpremove setTriggerArea [390,390,0,false];
_triggerpremove  setTriggerActivation ["EAST","PRESENT",true];
_triggerpremove  setTriggerTimeout [5,5,5,true];
_triggerpremove  setTriggerStatements ["this", "{_x setDammage 1} foreach thisList;",""];

I am then trying to clean up after so would like to delete the trigger, but cannot seem to thought it would be this but did not work ?

DeleteVehicle _triggerpremove;

Delete

Share this post


Link to post
Share on other sites

Is the deleteVehicle line in the same script as the code that creates it? If not, the game has no way of knowing what _triggerpremove is since it's a local variable and therefore only exists within the script that created it. The trigger is there of course, but the name "_triggerpremove" isn't.

You could either remove the _ from the variable names and make it a global variable in which case it should work.

Share this post


Link to post
Share on other sites

thisTrigger refers to the trigger itself, no names required.

you can delete the trigger itself in its own on act field, if the trigger is just supposed to activate once and then be deleted:

_triggerpremove  setTriggerStatements ["this", "{_x setDammage 1} foreach thisList; _null = thisTrigger spawn {sleep 1; deleteVehicle _this};",""];

i used spawn with 1 second sleep incase it will have issues with deleteing the trigger while it was running code, might as well work just fine if you used deleteVehicle thisTrigger

this is ofc asuming you only need trigger to activate once and then be deleted.

Share this post


Link to post
Share on other sites

I sometimes use setTriggerText rather than global naming if a trigger is to be deleted from outside it's own script. Note that there is one of obvious near/nearest... commands that is incapable of finding triggers for some weird reason. During deletion, search nearby for triggers and store them in a list. Loop over this list, and if triggerText matches what you're looking for delete as normal and exit the loop then script.

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  

×