frankie86ph 0 Posted May 20, 2023 Hi, Need help with some simple syntax for part of a larger script. My script aims to adjust load out of dynamically created AI depending on the contents of ammo crates. I'm currently stuck regarding the counting of specific weapons in an ammo crate. How can I create a new variable, which returns the number of specific weapons stored in a specific ammo crate? For example I want to count the number of M14's currently stored in ammo_box_1? Share this post Link to post Share on other sites
Ibragim A 163 Posted May 20, 2023 Use weaponsItemsCargo and magazinesAmmoCargo: _countWeapons = count ((weaponsItemsCargo ammo_box_1) select {typeOf _x == "arifle_Katiba_F"}); _countMagazines = count ((magazinesAmmoCargo ammo_box_1) select {_x == "30Rnd_65x39_caseless_green"}); Share this post Link to post Share on other sites
pierremgi 4905 Posted May 22, 2023 You can use hashmap, even if it's not the main use that was created for: private _hash = (getWeaponCargo ammo_box_1 #0) createHashMapFromArray (getWeaponCargo ammo_box_1 #1); private _count = _hash getOrDefault ["arifle_CTARS_blk_F",0]; // or what weapon class you want or private _idx = (getWeaponCargo ammo_box_1 #0) find "arifle_CTARS_blk_F"; private _count = [(getWeaponCargo ammo_box_1 #1) select _idx,0] select (_idx <0) ; Share this post Link to post Share on other sites