ACE3/addons/common/functions/fnc_getNumberMagazinesIn.sqf

38 lines
773 B
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-09-21 11:08:10 +00:00
/*
* Author: Glowbal
* Count magazines of unit.
2015-01-16 23:21:47 +00:00
*
2015-09-21 11:08:10 +00:00
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
*
* Return Value:
* Magazine amount <NUMBER>
*
* Example:
* [bob, "magazine"] call ace_common_fnc_getNumberMagazinesIn
*
2015-09-21 11:08:10 +00:00
* Public: No
2015-01-16 23:21:47 +00:00
*/
2015-09-21 11:08:10 +00:00
params ["_unit", "_magazine"];
2015-05-14 22:12:40 +00:00
private _return = 0;
2015-09-21 11:08:10 +00:00
2015-01-16 23:21:47 +00:00
if (_unit isKindOf "CAManBase") then {
2015-01-18 19:09:19 +00:00
_return = {_x == _magazine} count magazines _unit;
2015-01-16 23:21:47 +00:00
} else {
2015-01-18 19:09:19 +00:00
{
_return = _return + ({_x == _magazine} count magazines _x);
2015-09-21 11:08:10 +00:00
false
} count crew _unit;
2015-01-16 23:21:47 +00:00
(getMagazineCargo _unit) params [["_magNames", []], ["_magCount", []]];
{
if (_magazine == _x) exitWith {_return = _return + (_magCount select _forEachIndex)};
} forEach _magNames;
2015-01-16 23:21:47 +00:00
};
2015-05-14 22:12:40 +00:00
_return