Jump to content
Sign in to follow this  
zbug

How to retrieve the actual number of a squad member

Recommended Posts

This sounds so simple it hurts, yet I wasn't able to find any answer or hint anywhere

 

You've got 3 dudes in your squad: number 1, number 2, number 3.

In the group units array, number 1 is at index 0, number 2 is at index 1, number 3 is at index 2.

Everything's good, I can easily retrieve the actual number by doing array index + 1.

 

However, something bad happens to number 2, so now you've got 2 dudes in your squad: number 1, number 3.

In the group units array, number 1 is at index 0, number 3 is at index 1, so I can't retrieve the number based on the array indexes anymore.

 

Yet the UI keeps displaying the correct squad numbers so the info must be somewhere.

Any idea?

 

Thanks!

Share this post


Link to post
Share on other sites

call this function on the unit

 

fget_UnitNumber.sqf

// MP MACHINE : All
// Called from : various
// Called using :  [unit] call ZEU_AD_fget_UnitNumber
// Description : Returns the Unit's group number as seen in the command gui
// removes the first 2 elements from that array and then recompiles as a string
/////////////////////////////////////////////////////
///// PRELIMS /////
/////////////////////////////////////////////////////
private["_u"];
 
  _u = _this select 0;
  parseNumber(([[str _u, count(toArray(str group _u))+1] call BIS_fnc_trimString, " "] call BIS_fnc_splitString) select 0)
  • Like 1

Share this post


Link to post
Share on other sites

What are you trying to do that requires that you know their index?

Share this post


Link to post
Share on other sites

Thanks for the answers!

 

What are you trying to do that requires that you know their index?

 

Spotting the squad members with map markers, and a simple squad management UI. Everything works except the numbers that were wrong, until now ;)

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  

×