Home   Help Search Login Register  

Author Topic: event handler  (Read 3392 times)

0 Members and 1 Guest are viewing this topic.

Offline sharkattack

  • Former Staff
  • ****
event handler
« on: 27 Dec 2007, 12:47:15 »
me again

is it possible to add an event handler to all units within a trigger area ?..

many thanx in advance ...   :good:
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #1 on: 27 Dec 2007, 13:39:18 »
Yes, just get the units with the "list" of the trigger and add the corresponding handlers.
Code: [Select]
{
   _x addEventHandler blah blah blah blah;
} forEach list trigger_name;

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #2 on: 27 Dec 2007, 13:53:48 »
rodger that mate
will try asap 

many thanx  mandoble  :good:

edit
=====
im doing somthing wrong 

this is the EH ( detect  gunfire)  i m trying to add to all units within a trigger called badlands

this addEventHandler ["fired",{if (!(_this select 2 in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs"}}
« Last Edit: 27 Dec 2007, 14:05:36 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #3 on: 27 Dec 2007, 14:14:51 »
if you are doing that inside the forEach, then it should be _x addEventHandler ... instead of this addEventHandler

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #4 on: 28 Dec 2007, 10:43:31 »
me again   :whistle:

please forgive my noobishness    :-[

i tried with the below code  but keep getting an error message   missing }

any one help me get the correct the syntax

{_x addEventHandler ["fired",{if (!(_this select 2 in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs"}} forEach list badlands;

many thanx in advance 
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #5 on: 28 Dec 2007, 14:52:27 »
yes, I see 3 { and 2 }, try with "gunshots.sqs"}}}

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #6 on: 29 Dec 2007, 13:51:17 »
new error
foreach : type string expected code   ??? 
===========================

also
the EH  works on player unit  if called from his init

this addEventHandler ["fired",{if (!(_this select 2 in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs"}}

however if i add pipebomb to the weapons which will not activate the trigger ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD";"PipeBomb"])  it fails to recognize them
so if a player places a charge  the EH is fired .. have tried with timeBomb no change  .. anyone  no of a solution ??   :good:
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #7 on: 29 Dec 2007, 15:40:28 »
";"PipeBomb" --> ","PipeBomb"
there is a ; there instead of a ,

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #8 on: 29 Dec 2007, 15:50:57 »
 :-[

thanx a lot mate

edit
===
still dosnt work after correcting
« Last Edit: 29 Dec 2007, 15:52:56 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #9 on: 29 Dec 2007, 16:33:22 »
also, try changing
Code: [Select]
(_this select 2 ...by
Code: [Select]
( (_this select 2) ...

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #10 on: 30 Dec 2007, 11:32:32 »
sorry to be a  pain in the arse    :P

but im still unable to get it to work ...

i tried with this

{_x addEventHandler ["fired",{if (!((_this select 2) in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs"}}} forEach list badlands

same error returned

foreach : type string expected code  ???
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #11 on: 30 Dec 2007, 12:52:47 »
where are you executing that code? inside sqs or sqf? if sqf, there is a missing ; at the end.
Also you are missing the end ] of the addEventHandler command.

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #12 on: 31 Dec 2007, 11:24:38 »
hi mate
im executing the command  from init sqs ..

i tried
 
{_x addEventHandler ["fired",{if (!((_this select 2) in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs"}}}] forEach list badlands

error missing ;          ???

many thanx for your help ...
« Last Edit: 31 Dec 2007, 12:04:29 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: event handler
« Reply #13 on: 31 Dec 2007, 12:25:49 »
Code: [Select]
{_x addEventHandler ["fired",{if (!((_this select 2) in ["M4A1SD","MP5SD","M9SD","AKS74UN","MakarovSD"]) && !myvar_akFired) then {myvar_akFired=true; _this exec "gunshots.sqs";}}];} forEach list badlands;

Offline sharkattack

  • Former Staff
  • ****
Re: event handler
« Reply #14 on: 31 Dec 2007, 12:43:22 »
excellent ....   thanx a million mandoble  ... works a treat   :good:

now to get the EH to recognize satchel charges ...

any ideas on how to add satchels to the weapons array 

have tried  adding  "Put"  (weapon class name)
and both PipeBomb and TimeBomb (magazine classname)
to weapons array  but still everytime i  set a charge  the handler is fired

all the best for new 2008
« Last Edit: 31 Dec 2007, 13:11:34 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match