OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Flauta on 14 Aug 2006, 20:26:47

Title: Addevnethandler issue.. FAST!
Post by: Flauta on 14 Aug 2006, 20:26:47
Hey Folks!!!

I was wondering if there is a way to script the idea of these
Code: [Select]
{_x addeventhandler ["fired",{_x setcaptive false}]} foreach thislist  comand...
Despisting the "Addeventhandler" sintax.. the problme is that it desnot work... Ivé tried whit this setcaptive false instead of _x setcaptive false, but i sitll cant put it to work... any ideas??

I need Fast Answers!!!
Title: Re: Addevnethandler issue.. FAST!
Post by: nominesine on 14 Aug 2006, 20:35:37

Code: [Select]
{_x addeventhandler ["fired",{_x setcaptive false}]} foreach thislistI need Fast Answers!!!

This is as fast as I am these days. Your code should read
Code: [Select]
{_x addeventhandler ["fired",{this setcaptive false}]} foreach thislist since the eventHandler is actually added to a unit, and then this makes sense to the game engine wich _x forEach thislist doesn't. If Im wrong it's due to lack of time ;)

EDIT: Sorry, i just noticed you last remark. I will look at it again, but i wont be so fast.

EDIT2: From where do you get thislist? Try forEach units groupName

EDIT3 (for clarity):
Code: [Select]
{_x addeventhandler ["fired",{this setcaptive false}]} foreach units groupName
Title: Re: Addevnethandler issue.. FAST!
Post by: Flauta on 14 Aug 2006, 20:48:21
it is a trigger... nevermind about that.. because the trigger put all of them to setcaptive true.. and it wotks.. but when te EH execs, it givesa error whit "this" and it dosnt do anything whit _X
Title: Re: Addevnethandler issue.. FAST!
Post by: THobson on 14 Aug 2006, 20:59:49
Try

{_x addeventhandler ["fired",{(_this select 0) setcaptive false}]} foreach thislist

This is a guess as I cannot access the link to GB's list at the following location at the moment.

http://www.ofpec.com/COMREF/index.php?action=list&letter=a#addEventHandler
Title: Re: Addevnethandler issue.. FAST!
Post by: nominesine on 14 Aug 2006, 21:08:18
I was going to suggest that you use _this, but Thobson is usually correct so try his advice first. The reason Im guessing is that I cannot access OFP and test anything right now.
Title: Re: Addevnethandler issue.. FAST!
Post by: THobson on 14 Aug 2006, 21:16:04
In the context of an EH _this is an array.  I am guessing (because I can't get to GB's additional Info at the moment) that the first element of the array for a "fired" EH will be the unit that did the firing.  Seems like a reasonable guess
Title: Re: Addevnethandler issue.. FAST!
Post by: nominesine on 14 Aug 2006, 21:22:48
...and you can't setCaptive an array. That makes sense. I stand corrected.
Title: Re: Addevnethandler issue.. FAST!
Post by: THobson on 14 Aug 2006, 21:35:13
Thanks to bedges the broken link is now fixed.  Here is an extract:

For a "fired" Event Handler:
_this select 0 : who fired
_this select 1 : with what weapon
_this select 2 : with what muzzle
_this select 3 : mode (either single, or burst, or auto)
_this select 4 : the type of ammo used
Title: Re: Addevnethandler issue.. FAST!
Post by: Flauta on 14 Aug 2006, 22:01:30
Thanks!!

Fast answers needed, Fast Ansewers found!!

Thanks to all!