From b8e845a56be07a1a5741b5be21b739fd161796c7 Mon Sep 17 00:00:00 2001 From: LinkIsGrim Date: Wed, 6 Mar 2024 03:30:39 -0300 Subject: [PATCH] Common - Use canAdd for FUNC(addToInventory) --- .../common/functions/fnc_addToInventory.sqf | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/addons/common/functions/fnc_addToInventory.sqf b/addons/common/functions/fnc_addToInventory.sqf index dd561ac09e..a5f2741bf5 100644 --- a/addons/common/functions/fnc_addToInventory.sqf +++ b/addons/common/functions/fnc_addToInventory.sqf @@ -29,16 +29,16 @@ private _addedToUnit = false; switch (_container) do { case "vest": { - _canAdd = [_unit, _classname, 1, false, true, false] call CBA_fnc_canAddItem; + _canAdd = (vestContainer _unit) canAdd _classname; }; case "backpack": { - _canAdd = [_unit, _classname, 1, false, false, true] call CBA_fnc_canAddItem; + _canAdd = (backpackContainer _unit) canAdd _classname; }; case "uniform": { - _canAdd = [_unit, _classname, 1, true, false, false] call CBA_fnc_canAddItem; + _canAdd = (uniformContainer _unit) canAdd _classname; }; default { - _canAdd = [_unit, _classname] call CBA_fnc_canAddItem; + _canAdd = [_unit, _classname] call CBA_fnc_canAddItem; // replace with canAdd with ignoreMaxSoldierLoad in 2.18 if (_canAdd) then { switch (_type select 1) do { case "primary": { @@ -78,16 +78,10 @@ switch (_type select 0) do { _unit addWeaponGlobal _classname; } else { { - _x params ["_parameters", "_container"]; - - if (_parameters call CBA_fnc_canAddItem) exitWith { - _container addWeaponCargoGlobal [_classname, 1]; // addWeaponGlobal will replace the weapon currently in a slot + if (_x canAdd _classname) exitWith { + _x addWeaponCargoGlobal [_classname, 1]; // addWeaponGlobal will replace the weapon currently in a slot }; - } forEach [ - [[_unit, _classname, 1, false, false, true], backpackContainer _unit], - [[_unit, _classname, 1, false, true, false], vestContainer _unit], - [[_unit, _classname, 1, true, false, false], uniformContainer _unit] - ]; + } forEach [backpackContainer _unit, vestContainer _unit, uniformContainer _unit]; }; }; };