2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2015-03-15 08:02:11 +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:
2015-09-18 11:09:40 +00:00
* 0: Unit that claims another object. ObjNull to remove claim. <OBJECT>
* 1: The object that gets claimed. <OBJECT>
* 2: Lock the claimed object aswell? (optional: false) <BOOL>
2015-03-15 08:02:11 +00:00
*
* Return Value:
2015-09-18 11:09:40 +00:00
* None
2015-03-15 08:02:11 +00:00
*
2017-06-08 13:31:51 +00:00
* Example:
* [bob, flag, true] call ace_common_fnc_claim
*
2015-09-20 20:29:38 +00:00
* Public: No
2015-03-15 08:02:11 +00:00
*/
2015-08-26 13:20:11 +00:00
2015-09-18 11:09:40 +00:00
params ["_unit", "_target", ["_lockTarget", false]];
2015-01-11 16:42:31 +00:00
2015-12-12 15:48:54 +00:00
private _owner = _target getVariable [QGVAR(owner), objNull];
2015-01-11 16:42:31 +00:00
if (!isNull _owner && {!isNull _unit} && {_unit != _owner}) then {
2016-10-02 10:55:31 +00:00
ERROR("Claiming already owned object.");
2015-01-11 16:42:31 +00:00
};
2015-03-15 08:02:11 +00:00
// transfer this immediately
_target setVariable [QGVAR(owner), _unit, true];
2015-01-11 16:42:31 +00:00
2015-03-15 08:02:11 +00:00
// lock target object
2015-01-11 16:42:31 +00:00
if (_lockTarget) then {
2015-03-15 08:02:11 +00:00
if (!isNull _unit) then {
2016-06-04 10:12:56 +00:00
[QGVAR(lockVehicle), _target, _target] call CBA_fnc_targetEvent;
2015-03-15 08:02:11 +00:00
} else {
2016-06-04 10:12:56 +00:00
[QGVAR(unlockVehicle), _target, _target] call CBA_fnc_targetEvent;
2015-03-15 08:02:11 +00:00
};
2015-01-11 16:42:31 +00:00
};
2015-03-15 08:02:11 +00:00
/*
systemChat str locked _target;
systemChat str (_target getVariable [QGVAR(lockStatus), locked _target]);
*/