Merge pull request #2311 from acemod/322backpack

objectParent command replacing fnc_getBackpackAssignedUnit
This commit is contained in:
commy2 2015-08-31 21:32:42 +02:00
commit 87cf7ded83
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);