there is a command called magazines which returns all the ammo of a unit.
SO you could use magazines player to return an array containinf all of the magazines he has
If you wanted to know how many m16 the player had you would do this.
_magcount = {_x == {m16}} count magazines player