Home   Help Search Login Register  

Author Topic: foreach addeventhandler?  (Read 542 times)

0 Members and 1 Guest are viewing this topic.

bored_onion

  • Guest
foreach addeventhandler?
« on: 08 Dec 2004, 20:48:26 »
is it possible to addeventhandlers to multiple units in a trigger zone using the foreach command in the triggers activation. i tried it like this but it told me that "fired" was an unknown operator:

Code: [Select]
"_x addeventhandler ["fired",{_this exec "fire.sqs"}] foreach units thislist
see any problems?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:foreach addeventhandler?
« Reply #1 on: 08 Dec 2004, 20:59:08 »
Yes you can...

Code: [Select]
"_x addeventhandler [""fired"",{_this exec ""fire.sqs""}]" foreach units thislist
I know somebody comes to tell that that many quotes won't work but they do ::)

But you probably can do it like this too
Code: [Select]
{_x addeventhandler ["fired",{_this exec "fire.sqs"}]} foreach units thislist
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

bored_onion

  • Guest
Re:foreach addeventhandler?
« Reply #2 on: 08 Dec 2004, 21:31:35 »
it now says that it expected a group or array rather than an object with reference to the "foreach units thislist" bit - any ideas for this? btw, i used your first solution.
« Last Edit: 08 Dec 2004, 21:31:55 by bored_onion »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:foreach addeventhandler?
« Reply #3 on: 08 Dec 2004, 21:56:01 »
;D
Ah silly me...
forgot to correct that one thing... ::)

Do not use units thislist, just thislist
thislist returns an arry already, so no need for units

Code: [Select]
"_x addeventhandler [""fired"",{_this exec ""fire.sqs""}]" foreach thislist
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

bored_onion

  • Guest
Re:foreach addeventhandler?
« Reply #4 on: 08 Dec 2004, 22:00:05 »
cheers - should work good now ;D