Home   Help Search Login Register  

Author Topic: Using Deactivation in Trigger  (Read 1794 times)

0 Members and 1 Guest are viewing this topic.

Offline terran4999

  • Members
  • *
Using Deactivation in Trigger
« on: 26 May 2008, 07:30:04 »
Hey

Does anyone know how to deactivate a script using the Deactivation field of a trigger ????

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Using Deactivation in Trigger
« Reply #1 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
« Last Edit: 26 May 2008, 11:53:25 by THobson »

Offline schuler

  • Contributing Member
  • **
Re: Using Deactivation in Trigger
« Reply #2 on: 26 May 2008, 18:06:03 »
or i think you can name the trigger ,,, like trig1 then code
Code: [Select]
deleteVehicle trig1
Semper Fi

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Using Deactivation in Trigger
« Reply #3 on: 26 May 2008, 19:29:25 »
That would delete the trigger, but it would do nothing to stop a running script.

Offline Gcfungus

  • Members
  • *
Re: Using Deactivation in Trigger
« Reply #4 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.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline schuler

  • Contributing Member
  • **
Re: Using Deactivation in Trigger
« Reply #5 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

 
Semper Fi

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Using Deactivation in Trigger
« Reply #6 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

Offline terran4999

  • Members
  • *
Re: Using Deactivation in Trigger
« Reply #7 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

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Using Deactivation in Trigger
« Reply #8 on: 28 May 2008, 02:20:37 »
Are you 100% sure the trigger is deactivating?
urp!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Using Deactivation in Trigger
« Reply #9 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.

Offline terran4999

  • Members
  • *
Re: Using Deactivation in Trigger
« Reply #10 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.
« Last Edit: 30 May 2008, 23:54:42 by terran4999 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Using Deactivation in Trigger
« Reply #11 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.
« Last Edit: 31 May 2008, 14:44:37 by THobson »

Offline schuler

  • Contributing Member
  • **
Re: Using Deactivation in Trigger
« Reply #12 on: 31 May 2008, 18:17:59 »
yes to THobson but isnt there a _playmove somewhere ?
cheer schuler
Semper Fi