Jump to content
Sign in to follow this  
sakura_chan

Returning a unit's number...

Recommended Posts

i've searched the forums and the comref, and I can't find a reliable way of returning a unit's number within the squad ie the number of the unit that shows up in the command bar. Does such a command/script exist?

Share this post


Link to post
Share on other sites

Leader's init:

{_x setVariable ["unitnumber",_forEachIndex+1,true]} forEach units group this

You get the unit's number with unit getVariable "unitnumber"

Share this post


Link to post
Share on other sites

I guess thats the way you have to do it. Trouble is that it I was using it in a situation where units could join or leave the squad, or be regrouped after some members were killed. Thanks!

Share this post


Link to post
Share on other sites

Number = (units groupName) find unitname;

hint format["position number for %1 is %2",unitname,Number];

should say something like "position number of unitname is 3".

This should in theory get you the number of the unit from the array (units groupname)

Share this post


Link to post
Share on other sites

Nope that doesn't work because units (groupname) just returns the units in a straight array. If unit 3 was killed then unit 4 would become unit 3 when called with units (groupname). The only way I can see to do it is global variables and just keep track of units entering or leaving the squad.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×