mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
events for claiming objects
This commit is contained in:
parent
c442703a13
commit
9750e5fbc3
@ -161,3 +161,12 @@ _vehicle setFuel _fuelLevel;
|
||||
|
||||
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
|
||||
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
|
||||
|
||||
["lockVehicle", {
|
||||
_this setVariable [QGVAR(lockStatus), locked _this];
|
||||
_this lock 2
|
||||
}] call FUNC(addEventhandler);
|
||||
|
||||
["unlockVehicle", {
|
||||
_this lock (_this getVariable [QGVAR(lockStatus), locked _this])
|
||||
}] call FUNC(addEventhandler);
|
||||
|
@ -1,7 +1,20 @@
|
||||
// by commy2
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target", "_lockTarget", "_owner"];
|
||||
private ["_unit", "_target", "_lockTarget"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
@ -9,20 +22,26 @@ _lockTarget = _this select 2;
|
||||
|
||||
if (isNil "_lockTarget") then {_lockTarget = false};
|
||||
|
||||
_owner = _target getVariable ["ACE_isUsedBy", objNull];
|
||||
private "_owner";
|
||||
_owner = _target getVariable [QGVAR(owner), objNull];
|
||||
|
||||
if (!isNull _owner && {!isNull _unit} && {_unit != _owner}) then {
|
||||
diag_log text "[ACE] ERROR: Claiming already owned object.";
|
||||
};
|
||||
|
||||
_target setVariable ["ACE_isUsedBy", _unit, true];
|
||||
// transfer this immediately
|
||||
_target setVariable [QGVAR(owner), _unit, true];
|
||||
|
||||
// lock target object
|
||||
if (_lockTarget) then {
|
||||
if (!isNull _unit) then {
|
||||
[_target, "{_locked = locked _this; _this setVariable ['ACE_lockStatus', _locked]; _this lock 2}", _target] call FUNC(execRemoteFnc);
|
||||
["lockVehicle", _target, _target] call FUNC(targetEvent);
|
||||
} else {
|
||||
[_target, "{_this lock (_this getVariable ['ACE_lockStatus', locked _this])}", _target] call FUNC(execRemoteFnc);
|
||||
["unlockVehicle", _target, _target] call FUNC(targetEvent);
|
||||
};
|
||||
};
|
||||
|
||||
//systemChat str locked _target; systemChat str (_target getVariable ['ACE_lockStatus', locked _target]);
|
||||
/*
|
||||
systemChat str locked _target;
|
||||
systemChat str (_target getVariable [QGVAR(lockStatus), locked _target]);
|
||||
*/
|
||||
|
@ -1,8 +1,19 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Counterpart of ace_common_fnc_claim. Check if the given object is claimed by another unit.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Any object. (Object)
|
||||
*
|
||||
* Return Value:
|
||||
* Is this object claimed by someone?
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_object";
|
||||
private "_target";
|
||||
|
||||
_object = _this select 0;
|
||||
_target = _this select 0;
|
||||
|
||||
!isNull (_object getVariable ["ACE_isUsedBy", objNull])
|
||||
!isNull (_target getVariable [QGVAR(owner), objNull])
|
||||
|
Loading…
Reference in New Issue
Block a user