OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: terran4999 on 26 May 2008, 07:30:04

Title: Using Deactivation in Trigger
Post by: terran4999 on 26 May 2008, 07:30:04
Hey

Does anyone know how to deactivate a script using the Deactivation field of a trigger ????
Title: Re: Using Deactivation in Trigger
Post by: THobson on 26 May 2008, 11:41:24
Not in the way I suspect you think.  In the script you need to keep checking a variable, let's call it KillScript1, like this:
Code: [Select]
if KillScript1 then {exit}
It would be good if this could be in a loop and placed before the script does something important.

In the Deactivation field of your trigger put
Code: [Select]
KillScript1 = true
Title: Re: Using Deactivation in Trigger
Post by: schuler on 26 May 2008, 18:06:03
or i think you can name the trigger ,,, like trig1 then code
Code: [Select]
deleteVehicle trig1
Title: Re: Using Deactivation in Trigger
Post by: THobson on 26 May 2008, 19:29:25
That would delete the trigger, but it would do nothing to stop a running script.
Title: Re: Using Deactivation in Trigger
Post by: Gcfungus on 26 May 2008, 22:32:43
Yea, and then you would end up with an error trying to do things to an object that doesn't exist  :P.
Title: Re: Using Deactivation in Trigger
Post by: schuler on 27 May 2008, 07:13:24
deleting the trigger would stop the script from starting,
if he does not need the script to run he can kill it before it starts if it is in the trigger.  ;)
so why have the script exec and then kill it? just my point of view on the question asked .
cheers schuler

 
Title: Re: Using Deactivation in Trigger
Post by: THobson on 27 May 2008, 16:02:33
Mmmmm I may be a bit rusty but I do not think that trying to delete a trigger that does not exist would create a visible error.  I think the OFP engine just quietly ignors it.

I have often killed running scripts by using a trigger to set a variable in the way described above
Title: Re: Using Deactivation in Trigger
Post by: terran4999 on 28 May 2008, 00:52:12
Would my script look something like this:

Code: [Select]
_person = _this select 0

#loop

_person playMove "FXStandDip"

~1

if KillScript1 then {exit}

goto "loop"

then in the deactivation trigger i put : "Killscript1=true"

If i did everything correct it didn't work, the soldier kept doing it's pushup
Title: Re: Using Deactivation in Trigger
Post by: Mr.Peanut on 28 May 2008, 02:20:37
Are you 100% sure the trigger is deactivating?
Title: Re: Using Deactivation in Trigger
Post by: THobson on 30 May 2008, 19:45:28
If you have not got this working yet I suggest you describe here what your trigger looks like.
Title: Re: Using Deactivation in Trigger
Post by: terran4999 on 30 May 2008, 23:52:26
Ok,

I created a trigger that is activated by the player so its group to the player. The trigger is activated when player is present, in the deactivation field I typed "KillScript1 = true". Thats is all I did, but the soldier I applied the script on kept doing its pushup.
Title: Re: Using Deactivation in Trigger
Post by: THobson on 31 May 2008, 11:29:42
In this case you don't so much want to kill the script as to change the way it works.  Instead of:
Code: [Select]
if KillScript1 then {exit}

goto "loop"

Try:
Code: [Select]
if KillScript1 then {goto "end"}

goto "loop"
#end

Put here an action to make the player stand up.

exit

EDIT:
Note also that some playMoves stack up so if you issue several playMove instructions OFP will complete each one in turn.  That can lead to some delays in actioning a new playMove.  Not sure if the standDip playmove stacks, would be worth checking.
Title: Re: Using Deactivation in Trigger
Post by: schuler on 31 May 2008, 18:17:59
yes to THobson but isnt there a _playmove somewhere ?
cheer schuler