Jump to content
Sign in to follow this  
behemeth

Ammo Count of Objects in Container

Recommended Posts

Hey all,

 

I'm, trying to find out the Ammo count of CfgMagazine objects in a vehicle/container. I know, I can retrieve the magazine from a container by using getMagazineCargo. However, this only returns the type of magazine and the total count of magazines... Nothing about the actual ammo in the magazines. I found that there now is a setMagazineAmmoCargo command which allows adding magazine with custom ammo count, which is great. Yet, I couldn't find a similar command, like the same as get, to solve my problem of knowing how much ammo is in the magazine in a container.

I also tried a workaround with

_unit action ["TakeMagazine", _container, _magazineString]

to get the magazine and do a count outside the container... However, this only plays the "Take" animation but does nothing else. According to (old) posts, this action is broken.

 

Sadly, the there exist posts reaching back to the Arma 2 days with the given questions and no answers could solve the problem. Maybe you've got some updates for me.

 

Thanks!

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/magazinesAmmo

it returns the magazines name along with the amount of ammo inside of said magazine in the form of a nested array. so if you want to sort it and get name/ammo from it then use this to separate the name from the ammo(if you not comfortable with nested arrays) and whichever element inside _magNameArry you select, it will have the ammo amount inside the same element slot in _magCountArry

 

_magArry = magazinesAmmo containerName;
_magNameArry = [];
_magCountArry = [];

{
	_name = (_x select 0);
	_ammoCount = (_x select 1);
	_magNameArry pushBack _name;
	_magCountArry pushBack _ammoCount;
} forEach _magArry;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks so much @gokitty1199,

 

while it's not the exact command I needed (this seems to only give the vehicle's armament ammo), the command helped me to find magazinesAmmoCargo, which does exactly what I need! Also big thanks for providing the extremely helpful example code!

 

  • Like 1

Share this post


Link to post
Share on other sites

@HazJ thanks, but no... I already knew those. They don't give the ammo count. See the posts above for the right ones (which are hard to google... at least I didn't find them before @gokitty1199 hint.

Here the relevant ones:

Adding magazines with specific ammo count to container:

https://community.bistudio.com/wiki/addMagazineAmmoCargo

Getting the magazines with respective ammo count in a container

https://community.bistudio.com/wiki/magazinesAmmoCargo

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  

×