ACE3/addons/common/functions/fnc_getCountOfItem.sqf
BrettMayson 3c5b46c42d
Medical - Support Magazine Treatment Items (#9816)
* count treatment items

* getCountofItem

Co-Authored-By: Blue <itzblueman@gmail.com>

* getCountofItem fix

Co-Authored-By: Blue <itzblueman@gmail.com>

* convert painkillers to magazine

* use isclass

Co-Authored-By: johnb432 <58661205+johnb432@users.noreply.github.com>

* forget to change variable

* Update addons/medical_treatment/functions/fnc_hasItem.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* better magazine adjustment

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/medical_treatment/functions/fnc_medication.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/medical_treatment/functions/fnc_treatmentFailure.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update docs/wiki/framework/arsenal-framework.md

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Header

* use switch statement in fnc_useItem

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* only check adding to mags that are not full

Co-Authored-By: LinkIsGrim <salluci.lovi@gmail.com>

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

* Update fnc_getCountOfItem.sqf

* Optimisations & header fix

* Update addons/common/functions/fnc_adjustMagazineAmmo.sqf

* Fixed vehicle implementation

---------

Co-authored-by: Blue <itzblueman@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
2024-03-21 22:56:24 +01:00

36 lines
916 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: Dedmen, Blue, johnb43
* Return how many items of type _itemType the player has in his containers (Uniform, Vest, Backpack)
* Doesn't count assignedItems, weapons, weapon attachments, magazines in weapons
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Classname of item (Case-Sensitive) <STRING>
*
* Return Value:
* Item Count <NUMBER>
*
* Example:
* [bob, "FirstAidKit"] call ace_common_fnc_getCountOfItem
*
* Public: Yes
*/
params ["_unit", "_itemType"];
private _count = 0;
private _isMagazine = isClass (configFile >> "CfgMagazines" >> _itemType);
{
(if (_isMagazine) then {
getMagazineCargo _x
} else {
getItemCargo _x
}) params ["_itemTypes", "_itemCounts"];
_count = _count + (_itemCounts param [_itemTypes find _itemType, 0]);
} forEach [uniformContainer _unit, vestContainer _unit, backpackContainer _unit];
_count