Jump to content
frankie86ph

Condition to Return Number of Specific Items / Gear in a Group

Recommended Posts

Hi,

I've been working the last few days on a shop GUI for an upcoming mission - this allows the player to upgrade AI squads with better equipment, weapons etc.

I'm trying to figure out a condition that would count the number of NVGoggles in a specific group (since the GUI enables the player to reinforce groups), I need a dynamic pricing - so first I need to count the number of existing nvgoggles within the group. What condition script would return the total number of NVGoggles in the inventory of units in a specific group.

Share this post


Link to post
Share on other sites
2 hours ago, frankie86ph said:

. What condition script would return the total number of NVGoggles in the inventory of units in a specific group.

 

A condition returns a boolean (FALSE or TRUE), not a number.
Number of NVGoogles in a specific group:
- for most of the cases (when mods/DLCs are smart for naming NVG with "goggles" in class names!):

{"goggles" in toLowerANSI str assignedItems _x} count units yourGroup;

 

- unfortunately, there is no will for standardization in DLCs/mods in Arma and the authors do what they want with names, categories, factions...

example: NVGs in CSLA Iron Curtain can be:   "CSLA_nokto" class....

So, the above code doesn't work here, but you can mount an array with all possible classes in your scenario:

private _NVGArray = ["CSLA_nokto","O_NVGoggles_grn_F",....];
{_NVGArray findAny assignedItems _x >-1} count units yourGroup;

 

- Last general method (without array of NVGs but slower):

{assignedItems _x findIf {getNumber (configFile / "cfgWeapons" / _x / "type") == 4096} >-1} count units yourGroup;

 

  • Like 1

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

×