objectParent command replacing fnc_getBackpackAssignedUnit

This commit is contained in:
commy2 2015-08-30 10:45:14 +02:00
parent 2f54cfadbc
commit 32300a0a80
3 changed files with 7 additions and 29 deletions

View File

@ -3,7 +3,6 @@
ADDON = false; ADDON = false;
PREP(backpackOpened); PREP(backpackOpened);
PREP(getBackpackAssignedUnit);
PREP(isBackpack); PREP(isBackpack);
PREP(onOpenInventory); PREP(onOpenInventory);

View File

@ -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

View File

@ -1,7 +1,7 @@
/* /*
* Author: commy2 * Author: commy2
* *
* Handle the open inventory event. Display message on traget client. * Handle the open inventory event. Display message on target client.
* *
* Argument: * Argument:
* Input from "InventoryOpened" eventhandler * Input from "InventoryOpened" eventhandler
@ -11,16 +11,17 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private "_target"; params ["_unit","_backpack"];
params ["","_backpack"];
// exit if the target is not a backpack // exit if the target is not a real backpack, i.e. parachute, static weapon bag etc.
if !([_backpack] call FUNC(isBackpack)) exitWith {}; if !([_backpack] call FUNC(isBackpack)) exitWith {false};
// get the unit that wears the backpack object // get the unit that wears the backpack object
_target = _this call FUNC(getBackpackAssignedUnit); private "_target";
_target = objectParent _backpack;
if (isNull _target) exitWith {false}; if (isNull _target) exitWith {false};
// raise event on target unit // raise event on target unit
["backpackOpened", _target, [_target, _backpack]] call EFUNC(common,targetEvent); ["backpackOpened", _target, [_target, _backpack]] call EFUNC(common,targetEvent);