Home   Help Search Login Register  

Author Topic: foreach units  (Read 863 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
foreach units
« on: 02 Jul 2005, 10:41:27 »
im trying to add event handlers to all units in the game so i added a trigger
Anybody present Once
condition : This
On activation :
"_X AddEventHandler [{Fired},{_This Exec {TimedGrenade.sqs}}]" ForEach thislist ; "_X AddEventHandler [{Fired},{_This Exec {fired.sqs}}]" ForEach thislist ; "_X AddEventHandler [{Fired},{_This Exec {RPGdeviate.sqs}}]" ForEach thislist

i get no error messages but in one of the scripts thats how it tells me to do it but its not ?

qqqqqq

  • Guest
Re:foreach units
« Reply #1 on: 02 Jul 2005, 11:37:14 »
So what's the problem?

Offline 456820

  • Contributing Member
  • **
Re:foreach units
« Reply #2 on: 02 Jul 2005, 11:58:00 »
it doesnt work as in the scripts dont activate when i fire

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:foreach units
« Reply #3 on: 02 Jul 2005, 12:54:48 »
Try changing the brackets the other way around:
Code: [Select]
{_x AddEventHandler ["Fired",{_This Exec "TimedGrenade.sqs"}]} ForEach thislist ; {_x AddEventHandler ["Fired",{_This Exec "fired.sqs"}]} ForEach thislist ; {_x AddEventHandler ["Fired",{_This Exec "RPGdeviate.sqs"}]} ForEach thislist???
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

big_ears

  • Guest
Re:foreach units
« Reply #4 on: 02 Jul 2005, 13:22:56 »
Not that I know what I'm talking about however if it is in the "On Activation" box then don't you need to change all the "_this" to just "this"???  So just get rid of the underscore???  Not sure though.  

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:foreach units
« Reply #5 on: 02 Jul 2005, 14:03:12 »
No, that won't work, an eventhandler passes its arguments in the array called _this.

Good try though    ;D


Planck
« Last Edit: 02 Jul 2005, 14:07:28 by Planck »
I know a little about a lot, and a lot about a little.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:foreach units
« Reply #6 on: 02 Jul 2005, 14:26:35 »
First, you can simplify those three calls and combine them into one. This makes it more readable and efficient:
Code: [Select]
{_x addEventHandler["fired",{_this exec"TimedGrenade.sqs";_this exec"fired.sqs";_this exec"RPGdeviate.sqs"}]} forEach thislistSecondly, try adding a delay of 1 second to that trigger, ie fill in 1 in the Max/Mid/Min fields of the trigger property dialog and see if that helps.
« Last Edit: 02 Jul 2005, 14:27:32 by Killswitch »