From 32300a0a809b62c89199bb3cc446dc628bd9eb7b Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 30 Aug 2015 10:45:14 +0200 Subject: [PATCH] objectParent command replacing fnc_getBackpackAssignedUnit --- addons/backpacks/XEH_preInit.sqf | 1 - .../functions/fnc_getBackpackAssignedUnit.sqf | 22 ------------------- .../functions/fnc_onOpenInventory.sqf | 13 ++++++----- 3 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 addons/backpacks/functions/fnc_getBackpackAssignedUnit.sqf diff --git a/addons/backpacks/XEH_preInit.sqf b/addons/backpacks/XEH_preInit.sqf index a47825d0b0..f4c6a1a5d8 100644 --- a/addons/backpacks/XEH_preInit.sqf +++ b/addons/backpacks/XEH_preInit.sqf @@ -3,7 +3,6 @@ ADDON = false; PREP(backpackOpened); -PREP(getBackpackAssignedUnit); PREP(isBackpack); PREP(onOpenInventory); diff --git a/addons/backpacks/functions/fnc_getBackpackAssignedUnit.sqf b/addons/backpacks/functions/fnc_getBackpackAssignedUnit.sqf deleted file mode 100644 index 85f5966aa9..0000000000 --- a/addons/backpacks/functions/fnc_getBackpackAssignedUnit.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: commy2 - * - * Returns the unit that has the given backpack object equipped. - * - * Argument: - * 0: Executing Unit (Object) - * 1: A backpack object (Object) - * - * Return value: - * Unit that has the backpack equipped. (Object) - */ -#include "script_component.hpp" -scopeName "main"; - -params ["_unit","_backpack"]; -_target = objNull; -{ - if (backpackContainer _x == _backpack) then {_target = _x; breakTo "main"}; -} count nearestObjects [_unit, ["Man"], 5]; -if (isNull _target) exitWith {ACE_Player}; -_target diff --git a/addons/backpacks/functions/fnc_onOpenInventory.sqf b/addons/backpacks/functions/fnc_onOpenInventory.sqf index d79f8aed9b..afeeb21313 100644 --- a/addons/backpacks/functions/fnc_onOpenInventory.sqf +++ b/addons/backpacks/functions/fnc_onOpenInventory.sqf @@ -1,7 +1,7 @@ /* * Author: commy2 * - * Handle the open inventory event. Display message on traget client. + * Handle the open inventory event. Display message on target client. * * Argument: * Input from "InventoryOpened" eventhandler @@ -11,16 +11,17 @@ */ #include "script_component.hpp" -private "_target"; -params ["","_backpack"]; +params ["_unit","_backpack"]; -// exit if the target is not a backpack -if !([_backpack] call FUNC(isBackpack)) exitWith {}; +// exit if the target is not a real backpack, i.e. parachute, static weapon bag etc. +if !([_backpack] call FUNC(isBackpack)) exitWith {false}; // get the unit that wears the backpack object -_target = _this call FUNC(getBackpackAssignedUnit); +private "_target"; +_target = objectParent _backpack; if (isNull _target) exitWith {false}; + // raise event on target unit ["backpackOpened", _target, [_target, _backpack]] call EFUNC(common,targetEvent);