OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 on 02 Jul 2005, 10:41:27

Title: foreach units
Post by: 456820 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 ?
Title: Re:foreach units
Post by: qqqqqq on 02 Jul 2005, 11:37:14
So what's the problem?
Title: Re:foreach units
Post by: 456820 on 02 Jul 2005, 11:58:00
it doesnt work as in the scripts dont activate when i fire
Title: Re:foreach units
Post by: h- 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???
Title: Re:foreach units
Post by: big_ears 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.  
Title: Re:foreach units
Post by: Planck 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
Title: Re:foreach units
Post by: Killswitch 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.