vehicle inventory lock - compatibility with acre

This commit is contained in:
PabstMirror 2016-04-24 11:26:13 -05:00
parent 93450b9e38
commit 27c5598135
3 changed files with 25 additions and 22 deletions

View File

@ -17,14 +17,6 @@ class Extended_PostInit_EventHandlers {
}; };
}; };
class Extended_InventoryOpened_EventHandlers {
class CAManBase {
class ADDON {
clientInventoryOpened = QUOTE(_this call FUNC(onOpenInventory););
};
};
};
class Extended_InitPost_EventHandlers { class Extended_InitPost_EventHandlers {
class Car { class Car {
class ADDON { class ADDON {

View File

@ -3,3 +3,13 @@
//Add Event Handlers //Add Event Handlers
["VehicleLock_SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler); ["VehicleLock_SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler);
["VehicleLock_SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler); ["VehicleLock_SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler);
if (!hasInterface) exitwith {};
["SettingsInitialized", {
TRACE_1("SettingsInitialized eh",GVAR(LockVehicleInventory));
if (GVAR(LockVehicleInventory)) then {
["CAManBase", "InventoryOpened", {_this call FUNC(onOpenInventory);}] call CBA_fnc_addClassEventHandler;
};
}] call EFUNC(common,addEventHandler);

View File

@ -7,7 +7,7 @@
* 1: Container <OBJECT> * 1: Container <OBJECT>
* *
* Return Value: * Return Value:
* Handeled <BOOL> * None
* *
* Example: * Example:
* [player, car] call ACE_VehicleLock_fnc_onOpenInventory; * [player, car] call ACE_VehicleLock_fnc_onOpenInventory;
@ -20,10 +20,7 @@ params ["_unit", "_container"];
TRACE_2("params",_unit,_container); TRACE_2("params",_unit,_container);
//Only check for player: //Only check for player:
if (_unit != ace_player) exitWith {false}; if (_unit != ace_player) exitWith {};
private "_handeled";
_handeled = false;
if (GVAR(LockVehicleInventory) && //if setting not enabled if (GVAR(LockVehicleInventory) && //if setting not enabled
{(vehicle ace_player) == ace_player} && //Player dismounted {(vehicle ace_player) == ace_player} && //Player dismounted
@ -33,15 +30,19 @@ if (GVAR(LockVehicleInventory) && //if setting not enabled
) then { ) then {
//Give feedback that vehicle is locked //Give feedback that vehicle is locked
playSound "ACE_Sound_Click"; playSound "ACE_Sound_Click";
//don't open the vehicles inventory
_handeled = true;
// As of 1.54 the action needs to be delayed a frame to work, which used not to be the case //For compatibiltiy with ACRE, wait until the display is open, close it and then reopen the player's own inventory
//ref: http://gitlab.idi-systems.com/idi-systems/acre2-public/issues/70
[{ [{
TRACE_1("delaying a frame", ace_player); !isNull (findDisplay 602)
//Just opens a dummy groundContainer (so the player can still see their own inventory) },
ACE_player action ["Gear", objNull]; {
TRACE_1("car display open: closing", _this);
(findDisplay 602) closeDisplay 0;
[{
TRACE_1("Opening Player Inventory", _this);
ACE_player action ["Gear", objNull]
}, []] call EFUNC(common,execNextFrame); }, []] call EFUNC(common,execNextFrame);
},
[]] call EFUNC(common,waitUntilAndExecute);
}; };
_handeled