diff --git a/addons/common/fnc_addMagazine.sqf b/addons/common/fnc_addMagazine.sqf index e1ab8e1fc..e5771669e 100644 --- a/addons/common/fnc_addMagazine.sqf +++ b/addons/common/fnc_addMagazine.sqf @@ -49,7 +49,7 @@ if (!isClass _config || {getNumber (_config >> "scope") < 2}) exitWith { }; if (_verify) then { - if (_unit canAdd _item) then { + if ([_unit, _item, 1, true, true, true] call CBA_fnc_canAddItem) then { if (_ammo < 0) then { _unit addMagazine [_item, 1E6]; // addMagazine STRING is not synched when used on remote units. addMagazine ARRAY is. } else { @@ -58,16 +58,21 @@ if (_verify) then { _return = true; } else { - _unit switchMove "ainvpknlmstpslaywrfldnon_1"; + private _vehicle = vehicle _unit; + if (_vehicle isEqualTo _unit) then { + _unit switchMove "ainvpknlmstpslaywrfldnon_1"; - private _weaponHolder = nearestObject [_unit, "WeaponHolder"]; + private _weaponHolder = nearestObject [_unit, "WeaponHolder"]; - if (isNull _weaponHolder || {_unit distance _weaponHolder > 2}) then { - _weaponHolder = createVehicle ["GroundWeaponHolder", [0,0,0], [], 0, "NONE"]; - _weaponHolder setPosASL getPosASL _unit; - }; + if (isNull _weaponHolder || {_unit distance _weaponHolder > 2}) then { + _weaponHolder = createVehicle ["GroundWeaponHolder", [0,0,0], [], 0, "NONE"]; + _weaponHolder setPosASL getPosASL _unit; + }; - [_weaponHolder, _item] call CBA_fnc_addMagazineCargo; + _return = [_weaponHolder, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; + } else { + _return = [_vehicle, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; + }; }; } else { if (_ammo < 0) then { diff --git a/addons/common/fnc_addMagazineCargo.sqf b/addons/common/fnc_addMagazineCargo.sqf index f57fab7b4..56d3979fe 100644 --- a/addons/common/fnc_addMagazineCargo.sqf +++ b/addons/common/fnc_addMagazineCargo.sqf @@ -13,6 +13,7 @@ Parameters: _item - name of magazine to _count - number of magazines to add (Default: 1) _verify - if true, then put item on the ground if it can't be added + _ammo - ammo count (Default: 1E6) Returns: true on success, false otherwise @@ -31,7 +32,7 @@ Author: ---------------------------------------------------------------------------- */ SCRIPT(addMagazineCargo); -params [["_container", objNull, [objNull]], ["_item", "", [""]], ["_count", 1, [0]], ["_verify", false, [false]]]; +params [["_container", objNull, [objNull]], ["_item", "", [""]], ["_count", 1, [0]], ["_verify", false, [false]], ["_ammo", 1E6, [0]]]; private _return = false; @@ -54,11 +55,11 @@ if (isNull _config || {getNumber (_config >> "scope") < 2}) exitWith { if (_verify) then { if (_container canAdd [_item, _count]) then { - _container addMagazineCargoGlobal [_item, _count]; + _container addMagazineAmmoCargo [_item, _count, _ammo]; _return = true; } else { while {_container canAdd _item && {_count > 0}} do { - _container addMagazineCargoGlobal [_item, 1]; + _container addMagazineAmmoCargo [_item, 1, _ammo]; _count = _count - 1; }; @@ -69,10 +70,10 @@ if (_verify) then { _weaponHolder setPosATL (getPosATL _container vectorAdd [random 2 - 1, random 2 - 1, 0]); }; - _weaponHolder addMagazineCargoGlobal [_item, _count]; + _weaponHolder addMagazineAmmoCargo [_item, _count, _ammo]; }; } else { - _container addMagazineCargoGlobal [_item, _count]; + _container addMagazineAmmoCargo [_item, _count, _ammo]; _return = true; };