ACE3/addons/common/functions/fnc_getNumberMagazinesIn.sqf
johnb432 8f46ffd8d5
General - Change count to forEach where appropriate (#9890)
count -> forEach

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2024-04-04 08:15:26 -03:00

37 lines
764 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal
* Count magazines of unit.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
*
* Return Value:
* Magazine amount <NUMBER>
*
* Example:
* [bob, "magazine"] call ace_common_fnc_getNumberMagazinesIn
*
* Public: No
*/
params ["_unit", "_magazine"];
private _return = 0;
if (_unit isKindOf "CAManBase") then {
_return = {_x == _magazine} count magazines _unit;
} else {
{
_return = _return + ({_x == _magazine} count magazines _x);
} forEach crew _unit;
(getMagazineCargo _unit) params [["_magNames", []], ["_magCount", []]];
{
if (_magazine == _x) exitWith {_return = _return + (_magCount select _forEachIndex)};
} forEach _magNames;
};
_return