2015-03-11 11:22:27 +00:00
/*
* Author: commy2
*
* Unit claims the ownership over an object. This is used to prevent multiple players from draging the same ammo box or using up the same wheel when repairing etc.
*
* Arguments:
* 0: Unit that claims another object. ObjNull to remove claim. (Object)
* 1: The object that gets claimed. (Object)
* 2: Lock the claimed object aswell? (Bool)
*
* Return Value:
* NONE
*
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-01-11 16:42:31 +00:00
2015-03-11 11:22:27 +00:00
private ["_unit", "_target", "_lockTarget"];
2015-01-11 16:42:31 +00:00
_unit = _this select 0;
_target = _this select 1;
_lockTarget = _this select 2;
if (isNil "_lockTarget") then {_lockTarget = false};
2015-03-11 11:22:27 +00:00
private "_owner";
_owner = _target getVariable [QGVAR(owner), objNull];
2015-01-11 16:42:31 +00:00
if (!isNull _owner && {!isNull _unit} && {_unit != _owner}) then {
2015-01-12 04:02:33 +00:00
diag_log text "[ACE] ERROR: Claiming already owned object.";
2015-01-11 16:42:31 +00:00
};
2015-03-11 11:22:27 +00:00
// transfer this immediately
_target setVariable [QGVAR(owner), _unit, true];
2015-01-11 16:42:31 +00:00
2015-03-11 11:22:27 +00:00
// lock target object
2015-01-11 16:42:31 +00:00
if (_lockTarget) then {
2015-03-11 11:22:27 +00:00
if (!isNull _unit) then {
["lockVehicle", _target, _target] call FUNC(targetEvent);
} else {
["unlockVehicle", _target, _target] call FUNC(targetEvent);
};
2015-01-11 16:42:31 +00:00
};
2015-03-11 11:22:27 +00:00
/*
systemChat str locked _target;
systemChat str (_target getVariable [QGVAR(lockStatus), locked _target]);
*/