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;
PREP(backpackOpened);
PREP(getBackpackAssignedUnit);
PREP(isBackpack);
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
*
* 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);