Jump to content
Sign in to follow this  
_qor

Add numeric values of an array to one sum

Recommended Posts

Hey,

 

I want to know how much weapons and magazines are within a spefic cargo.

getWeaponCargo and getMagazineCargo return the following array:

 

[["AK_74","M4A1"],[4,30]]

 

So (getWeaponCargo _vehicle) select 1 would return all the amounts of the weapons. But how can I easily add them to one sum?

Share this post


Link to post
Share on other sites

how can I easily add them to one sum?

_wpnCount = (getWeaponCargo _vehicle) select 1;
_total = 0;
{_total = _total + _x} forEach _wpnCount;

Share this post


Link to post
Share on other sites

Great, it works.

Now I am finally aware of what forEach does ;)

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  

×