OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: bardosy on 31 Aug 2005, 08:15:36

Title: group in vehicle
Post by: bardosy on 31 Aug 2005, 08:15:36
Sorry for newby-question, but I can't find answer in my downloaded documentations.

How can I know, if a whole group is in a vehicle?

I have a trigger and I want put an expression in the Condition field, like

group(player) in heli1
or
units group(player) in heli1

^these doesn't work, just I want explain what is my question.

Finally I use: (u1 in heli1)and(u2 in heli1)and...    where u1,u2,u3... are the names of group member.
It's works, but I feel there is some better solution.
Title: Re:group in vehicle
Post by: bedges on 31 Aug 2005, 08:21:25
Code: [Select]
count ({_x in vehicle_name} count units group group_name) == count units group group_name
syntax not guaranteed  ::)
Title: Re:group in vehicle
Post by: bardosy on 31 Aug 2005, 08:23:00
Thank you!!! I'll try it!!!

Title: Re:group in vehicle
Post by: THobson on 31 Aug 2005, 09:15:02
I thnk bedges meant:

{_x in vehicle_name} count units group_name) == count units group_name

That will work  if you know the name of the vehicle.  If you  don't or if the group may be spread across different vehicles try:

{_x != vehicle _x} count units groupname

will return the number that are in any vehicle.  So the test would then be:


{_x != vehicle _x} count units groupname == count units groupname

So many ways to do the same thing
Title: Re:group in vehicle
Post by: Baddo on 14 Sep 2005, 18:12:50
There is now a function in the function library to do this checking. It can check if all group members are in any vehicle (not necessarily in the same vehicle), or it can check if all group members are in one specific vehicle.

Follow this link:

groupInVehicle (http://www.ofpec.com/editors/funcref.php?letter=G#groupInVehicle)



Title: Re:group in vehicle
Post by: Kyle Sarnik on 14 Sep 2005, 20:51:02
I thnk bedges meant:

{_x in vehicle_name} count units group_name) == count units group_name

Carefull now, don't wanna get a missing "(" error, you best close those parentheses  ;)
Title: Re:group in vehicle
Post by: THobson on 14 Sep 2005, 20:57:10
True enough - sloppy cut and paste on my part.  :-[ I got rid of 'count (' but neglected to get rid of the closing ')'.  It should of course be:


{_x in vehicle_name} count units group_name == count units group_name

Title: Re:group in vehicle
Post by: bedges on 14 Sep 2005, 22:03:41
i should also put my hands up and admit my responsibility - they were after all my parentheses to begin with... :-[
Title: Re:group in vehicle
Post by: Triggerhappy on 14 Sep 2005, 22:12:34
yet again a correction, not exactly necessary, but possibly vital depending on the situation....:

{_x in vehicle_name} count units group_name == {alive _x} count units group_name


because if someone in the group dies, it might not register (and remove them from the group) until long after, but the whether they are alive (or dead) is always known

like i said, not absolutely necessary, but very good to have
Title: Re:group in vehicle
Post by: THobson on 14 Sep 2005, 22:53:52
Good catch.  :thumbsup: It's missing things like this that causes those strange bugs we all struggle over.

EDIT:

On further thought should it be:

{(_x in vehicle_name) and (alive _x)} count units group_name == {alive _x} count units group_name

Just in case a dead loon in the vehicle gets counted?
Title: Re:group in vehicle
Post by: Triggerhappy on 15 Sep 2005, 00:16:04
didn't think of that, althought the chances of something like that are incredibly slim, but, better safe than sorry :P
Title: Re:group in vehicle
Post by: bardosy on 15 Sep 2005, 07:49:35
Thanks for the correct answer guys!