From 6452c310052860b8767b602dc69ddcb24d0471d5 Mon Sep 17 00:00:00 2001 From: Drofseh Date: Thu, 24 Nov 2022 00:34:18 -0800 Subject: [PATCH 1/2] Attempt to add item to vehicle if unit in vehicle Attempt to add the item to the unit's vehicle instead of always chucking it out the window onto the ground. --- addons/common/fnc_addItem.sqf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/common/fnc_addItem.sqf b/addons/common/fnc_addItem.sqf index 2b2abf75dd..1cfb8a1aae 100644 --- a/addons/common/fnc_addItem.sqf +++ b/addons/common/fnc_addItem.sqf @@ -52,16 +52,21 @@ if (_verify) then { _unit addItem _item; _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_addItemCargo; + _return = [_weaponHolder, _item, 1, _verify] call CBA_fnc_addItemCargo; + } else { + _return = [_vehicle, _item, 1, _verify] call CBA_fnc_addItemCargo; + }; }; } else { _unit addItem _item; From 5926554fb6970c7098402e840deeb8b57831ad62 Mon Sep 17 00:00:00 2001 From: Drofseh Date: Fri, 25 Nov 2022 01:24:24 -0800 Subject: [PATCH 2/2] fix return for addMagazine and addItem --- addons/common/fnc_addItem.sqf | 6 +++--- addons/common/fnc_addMagazine.sqf | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/common/fnc_addItem.sqf b/addons/common/fnc_addItem.sqf index 1cfb8a1aae..c8fb456e36 100644 --- a/addons/common/fnc_addItem.sqf +++ b/addons/common/fnc_addItem.sqf @@ -11,7 +11,7 @@ Description: Parameters: _unit - the unit _item - name of the weapon to add - _verify - if true, then put item on the ground if it can't be added + _verify - if true, then put item in vehicle or on the ground if it can't be added Returns: true on success, false otherwise @@ -63,9 +63,9 @@ if (_verify) then { _weaponHolder setPosASL getPosASL _unit; }; - _return = [_weaponHolder, _item, 1, _verify] call CBA_fnc_addItemCargo; + [_weaponHolder, _item, 1, _verify] call CBA_fnc_addItemCargo; } else { - _return = [_vehicle, _item, 1, _verify] call CBA_fnc_addItemCargo; + [_vehicle, _item, 1, _verify] call CBA_fnc_addItemCargo; }; }; } else { diff --git a/addons/common/fnc_addMagazine.sqf b/addons/common/fnc_addMagazine.sqf index e5771669eb..b7341769b9 100644 --- a/addons/common/fnc_addMagazine.sqf +++ b/addons/common/fnc_addMagazine.sqf @@ -12,7 +12,7 @@ Parameters: _unit - the unit or vehicle _item - name of the magazine to add _ammo - ammo count - _verify - if true, then put item on the ground if it can't be added + _verify - if true, then put item in vehicle or on the ground if it can't be added Returns: true on success, false otherwise @@ -69,9 +69,9 @@ if (_verify) then { _weaponHolder setPosASL getPosASL _unit; }; - _return = [_weaponHolder, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; + [_weaponHolder, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; } else { - _return = [_vehicle, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; + [_vehicle, _item, 1, _verify, _ammo] call CBA_fnc_addMagazineCargo; }; }; } else {