OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Baphomet on 14 Oct 2002, 22:31:47

Title: Killing scripts on trigger deactivation
Post by: Baphomet on 14 Oct 2002, 22:31:47
I have a trigger set to run a script when a player of a certain side is within its boundaries. On the activation of the trigger it is supposed to run a looping script for the duration of time that the player is in the trigger bounds. What do I do to stop the script from running after the person leaves the trigger area? I'm thinking I have to enter something in the deactivation field. I'm not sure what.
Title: Re:Killing scripts on trigger deactivation
Post by: Rodd on 14 Oct 2002, 23:06:59
The easiest way I can think of is to check the trigger condition itself inside the looping script so that it stops looping (and exits) when you want it to.
Title: Re:Killing scripts on trigger deactivation
Post by: Baphomet on 15 Oct 2002, 00:37:02
Shit. That means I need to learn more scripting...
Title: Re:Killing scripts on trigger deactivation
Post by: Bremmer on 15 Oct 2002, 02:46:45
A leetle bit more ... but its not hard  ;)

Set your trigger to repeating if you haven't already done so.
In On Activation I assume you have something like [] exec "script.sqs".
Modify this so it reads:

trig = true; [] exec "script.sqs"

In On Deactivation put

trig= false

Now in your looping script you can insert a condition that checks when trig is true or false. eg:

#loop
.
.
.
? not trig : exit
.
.
.
goto "loop"


Give it a go - its easier than you think  :)
Title: Re:Killing scripts on trigger deactivation
Post by: Baphomet on 15 Oct 2002, 15:49:49
Aaa. It worked!
Cheers m8. Its just what I needed.
Title: Re:Killing scripts on trigger deactivation
Post by: Baphomet on 15 Oct 2002, 16:10:19
Hm. I'm wondering now If I could take it up a notch or two. Say, adding a condition to allow the trigger to run based on the type of unit that is within it. I'm pretty sure you define that under condition string instead of the default "this" you'd specify the unit.

For example if I wanted a 5t truck to only run the script when its within the trigger boundaries. Right now I have the expcond string set to this&&(local Player).
Title: Re:Killing scripts on trigger deactivation
Post by: Mike on 15 Oct 2002, 16:23:38
if you only want the 5 ton truck to activate the trigger and nothing else, group the trigger to the truck with the (f2)grouping command.. go to the triggers activation, make sure its on vehicle..  I think u can do this several times for several trucks/units or whatever
Title: Re:Killing scripts on trigger deactivation
Post by: Baphomet on 16 Oct 2002, 19:56:51
Hm. I was more or less thinking -any- 5t truck. Not just one, not just a truck with a specific name, just a generic 5t truck of any type.