diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf index aa85c99e..98deb299 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf @@ -13,81 +13,59 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_cfgBaseBuilding","_fnc_lock","_fnc_unlock","_gArray","_owners","_playerGroup","_playerUID","_response","_type"]; +private ["_cfgBaseBuilding","_owners","_playerGroup","_playerUID","_response","_type","_locked","_LockStateChanged","_msg"]; //[[[end]]] params ["_unit","_lockStatus","_player",["_token","",[""]] ]; if !([_player, _token] call EPOCH_server_getPToken) exitWith{}; if (isNull _unit) exitWith{}; if (_player distance _unit > 20) exitWith{}; +_VehLockMessages = ['CfgEpochClient' call EPOCH_returnConfig, "VehLockMessages", true] call EPOCH_fnc_returnConfigEntry; _type = typeOf _unit; _playerUID = getPlayerUID _player; -_playerGroup = _player getVariable ["GROUP",""]; +_playerGroup = _player getVariable["GROUP", ""]; -_fnc_lock = { - _this setVariable ["EPOCH_Locked", true, true]; - EPOCH_saveStorQueue pushBackUnique _this; -}; -_fnc_unlock = { - _this setVariable ["EPOCH_Locked", false, true]; +_fnc_Lock_Unlock = { + _locked = !_locked; + _unit setVariable ["EPOCH_Locked", _locked, true]; + _LockStateChanged = true; }; _cfgBaseBuilding = 'CfgBaseBuilding' call EPOCH_returnConfig; -if (getNumber(_cfgBaseBuilding >> _type >> "isSecureStorage") == 1) then{ - +if (getNumber(_cfgBaseBuilding >> _type >> "isSecureStorage") == 1) then { _owners = _unit getVariable["STORAGE_OWNERS", []]; - - // locked > unlocked - if !(_unit getVariable ["EPOCH_Locked", true]) then { - - // allow group members and owner access + _locked = _unit getVariable ["EPOCH_Locked", true]; + _LockStateChanged = false; + if (_playerUID in _owners) then { + call _fnc_Lock_Unlock; + } + else { if (_playerGroup != "") then { if (_playerGroup in _owners) then { - _unit call _fnc_lock; - } else { - + call _fnc_Lock_Unlock; + } + else { _response = ["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE; - if ((_response select 0) == 1 && (_response select 1) isEqualType []) then { - _gArray = _response select 1; - if ( - {(_x select 0) in _owners}count(_gArray select 3) > 0 || - {(_x select 0) in _owners}count(_gArray select 4) > 0 || - _playerUID in _owners - ) then { - _unit call _fnc_lock; - }; + (_response param [1,[]]) params ["","","",["_modArray",[]],["_memberArray",[]]]; + if ( + {(_x select 0) in _owners} count _modArray > 0 || + {(_x select 0) in _owners} count _memberArray > 0 + ) then { + call _fnc_Lock_Unlock; }; }; - - } else { - if (_playerUID in _owners) then { - _unit call _fnc_lock; - }; - }; - - // unlocked > locked - } else { - - // allow group members and owner access - if (_playerGroup != "") then { - if (_playerGroup in _owners) then { - _unit call _fnc_unlock; - } else { - _response = ["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE; - if ((_response select 0) == 1 && (_response select 1) isEqualType []) then { - _gArray = _response select 1; - if ( - {(_x select 0) in _owners }count(_gArray select 3) > 0 || - {(_x select 0) in _owners}count(_gArray select 4) > 0 || - _playerUID in _owners - ) then { - _unit call _fnc_unlock; - }; - }; - }; - } else { - if (_playerUID in _owners) then { - _unit call _fnc_unlock; - }; }; }; + _msg = "You are not the owner"; + if (_LockStateChanged) then { + if (_locked) then { + EPOCH_saveStorQueue pushBackUnique _unit; + _msg = "Storage Locked"; + } + else { + _msg = "Storage Unlocked"; + }; + }; + if (_VehLockMessages) then { + [_msg,5] remoteExec ["Epoch_Message",_player]; + }; };