Jump to content
Blitzen88

Putting an array of magazines into an ammo crate

Recommended Posts

Greetings,

 
Im trying to figure out how to gather a magazine from each unit of a group and add it to an ammobox.  The idea is that necessary magazines will be added to the ammobox regardless of the loadout.

 

Here is what I got:
 

Quote

_PlayerGroup = group _player;

 

_AllMags = {primaryWeaponMagazine _x} foreach units _PlayerGroup;

 

ammobox {addmagazinecargo _x, 5} foreach _Allmags;


But it isnt working...?

 

Share this post


Link to post
Share on other sites

addmagazinecargo is a command with local effects only. Read its biki entry.

Share this post


Link to post
Share on other sites
2 minutes ago, sarogahtyp said:

addmagazinecargo is a command with local effects only. Read its biki entry.

Would only be used for single player.  Dont know if that changes anything but I will checkout the wiki. 

Share this post


Link to post
Share on other sites

nevermind then. on SP it does not matter

Share this post


Link to post
Share on other sites

_allMags = flatten (units _playerGroup apply {primaryWeaponMagazine _x});

{ammobox addMagazineCargo [_x, 5]} count _Allmags;

 

In MP:

see also:  addMagazineCargoGlobal

Running the code locally (where player is), the difference is that with global command, the crate contents all magazines of all groups, with non-global one, you make the crate specific for each player.

Running the code on server only is probable non-sense (player is local if hosted, non-existent if dedicated). 

 

  • Like 1

Share this post


Link to post
Share on other sites
18 hours ago, pierremgi said:

_allMags = flatten (units _playerGroup apply {primaryWeaponMagazine _x});

{ammobox addMagazineCargo [_x, 5]} count _Allmags;

 

This seems to work perfectly. Thank you!

 

Now I gotta read up on “flatten” and “apply”

 

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

×