OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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.
-
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.
-
Shit. That means I need to learn more scripting...
-
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 :)
-
Aaa. It worked!
Cheers m8. Its just what I needed.
-
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).
-
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
-
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.