OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: 456820 on 30 Aug 2007, 16:05:45

Title: if a leader do...
Post by: 456820 on 30 Aug 2007, 16:05:45
Well new computer and I've started creating missions again however after not doing any scripting for a very long time I'm now very rusty.

My question is...

I have a trigger which I want to run a script on every squad leader in the area. However I cant quite remember how to do so.

I have set the activation trigger up however this is running on every single soldier in the trigger how do I make the trigger check if its a squad leader?

Closest I could think of is "this and leader" in the condition field, however no luck like I expected.
Cheers.
Title: Re: if a leader do...
Post by: Mr.Peanut on 30 Aug 2007, 16:12:41
Welcome home!  :cool2:

A little more detail. Are you trying to get the trigger to activate for only the leaders, or trying to get the on activation code to run only on the leaders?
Title: Re: if a leader do...
Post by: 456820 on 30 Aug 2007, 16:13:30
Trying to get the trigger to activate for only the leaders.
Title: Re: if a leader do...
Post by: Mr.Peanut on 30 Aug 2007, 16:17:27
Code: [Select]
myLeader in thisList
or

Code: [Select]
myLeader1 in thisList || myLeader2 in thisList ...
or

Code: [Select]
({_x in thisList} count [myLeader1, myLeader2, ...]) > 0
edit: You could also group the trigger to the leaders, but make sure the trigger type is for the unit, not for the group.

Title: Re: if a leader do...
Post by: 456820 on 30 Aug 2007, 16:21:44
Thanks for the reply.

But by any chance is there a more easier way, for use of a lot of squads? for example about 100+ squads or will I have to start naming them all?  :D
Title: Re: if a leader do...
Post by: Nixer6 on 30 Aug 2007, 16:27:08
I guess you could loop thru the whole trigger list finding  :scratch:

leader group _this and then adding them to an array,  _leaders[].

Somebody who knows what they are doing will come along...I hope.  ;)
Title: Re: if a leader do...
Post by: Mr.Peanut on 30 Aug 2007, 16:42:35
Condition
Code: [Select]
{leader _x == _x} count thisList > 0;
OnActivation
Code: [Select]
{if (leader _x == _x) then {nul = [_x] execVM "myScript.sqf";}} forEach thisList
Title: Re: if a leader do...
Post by: 456820 on 30 Aug 2007, 17:05:44
thankyou very much, shall try and report back.
Title: Re: if a leader do...
Post by: 456820 on 30 Aug 2007, 17:35:01
Well seems to work, thanks alot.

#topic solved