Home   Help Search Login Register  

Author Topic: Deleting event handlers  (Read 537 times)

0 Members and 1 Guest are viewing this topic.

Torak

  • Guest
Deleting event handlers
« on: 29 Oct 2003, 20:12:41 »
I have set up event handlers to keep the squad alive during the intro to a mission (not the actual intro, just the bit at the start of the mission where they're driving to the helipad), since they otherwise get shot up by the units I've added for effect. But how can I remove those event handlers so they don't have any further effect once the mission proper has started?

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Deleting event handlers
« Reply #1 on: 29 Oct 2003, 20:36:26 »
I have an idea, it could probably be done in better ways but anyway:

you execute the eventhandler with a script and in that script you have a boolean in the start, when they reach that point where you no longer need the eventhandler, just turn that boolean false(or true, depending on how you'll design that script) and the script will exit and nuthin will happen. Great huh? ;)

:beat: *Gets Shot* :beat:

Grendel

  • Guest
Re:Deleting event handlers
« Reply #2 on: 29 Oct 2003, 22:46:13 »
The only problem with the above approach, is that the event handler will still be there sucking a few cycles of computing power.  To fully get rid of the event handler first give it a name:

myevent= unit addeventhandler ["event","result"]

to remove it, use the boolean as suggested by The real Armstrong, but instead of simply exiting, add the following line to delete the EH:

unit removeeventhandler ["event",myevent]

this should work for you.

-Grendel

Offline KTottE

  • Former Staff
  • ****
Re:Deleting event handlers
« Reply #3 on: 29 Oct 2003, 22:54:19 »
The first step to knowledge is searching for information.

Our Command Reference contains all the commands used in OFP scripting, and in it I quickly found these two items:
removeAllEventHandlers and removeEventHandler.

"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Torak

  • Guest
Re:Deleting event handlers
« Reply #4 on: 30 Oct 2003, 11:51:15 »
Thanks all, that worked nicely!