Jump to content
Sign in to follow this  
blackpixxel

Add a list of magazines to a player

Recommended Posts

Hi,

I have the following problem:

I made a list of all the magazines of a unit using this command:

_magazinesList = magazinesAmmo _unit;

Now I want to add all the magazines from the list back to the unit, after I removed each of them. I tried it like this:

{player addmagazine [(_magazinesList select _x) select 0,(_magazinesList select _x) select 1]}foreach _magazinesList;

But it doesn't work.

I am not a scripting expert, so I hope that someone could answer this hopefully simple question.

Thank you for your help!

BlackPixxel

Share this post


Link to post
Share on other sites

The forEach command will iterate over each item in the array - _x represents the item itself and not its index, so using "_magazinesList select _x" is wrong.

The code should be:

{player addmagazine [_x select 0, _x select 1]}foreach _magazinesList;

Share this post


Link to post
Share on other sites

Wow, thank you for your fast response!

It works great now, and I learned something new.

Thanks alot!

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  

×