From f4909fd67646fed6d2c902c681afbd8f62160756 Mon Sep 17 00:00:00 2001 From: "[VB]AWOL" Date: Sun, 24 Nov 2013 03:35:13 -0600 Subject: [PATCH] test for #767 and #766 --- SQF/dayz_code/compile/player_lockVault.sqf | 3 +- SQF/dayz_code/compile/player_packVault.sqf | 4 +- SQF/dayz_code/compile/player_unlockDoor.sqf | 74 +++++++++++-------- SQF/dayz_code/compile/player_unlockVault.sqf | 8 +- .../compile/player_upgradeVehicle.sqf | 4 +- SQF/dayz_code/init/compiles.sqf | 19 +++++ 6 files changed, 71 insertions(+), 41 deletions(-) diff --git a/SQF/dayz_code/compile/player_lockVault.sqf b/SQF/dayz_code/compile/player_lockVault.sqf index 997de6c1d..e439b2c79 100644 --- a/SQF/dayz_code/compile/player_lockVault.sqf +++ b/SQF/dayz_code/compile/player_lockVault.sqf @@ -16,8 +16,7 @@ _text = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "displayName" // Silently exit if object no longer exists if(isNull _obj) exitWith { TradeInprogress = false; }; -// Test cannot lock while another player is nearby -_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1; +_playerNear = _obj call dze_isnearest_player; if(_playerNear) exitWith { TradeInprogress = false; cutText [(localize "str_epoch_player_11") , "PLAIN DOWN"]; }; _ownerID = _obj getVariable["CharacterID","0"]; diff --git a/SQF/dayz_code/compile/player_packVault.sqf b/SQF/dayz_code/compile/player_packVault.sqf index 9fee4f12d..12e014aa7 100644 --- a/SQF/dayz_code/compile/player_packVault.sqf +++ b/SQF/dayz_code/compile/player_packVault.sqf @@ -16,8 +16,8 @@ _text = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "displayName" // Silently exit if object no longer exists if(isNull _obj or !(alive _obj)) exitWith { TradeInprogress = false; }; -// Test cannot lock while another player is nearby -_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1; +_playerNear = _obj call dze_isnearest_player; + if(_playerNear) exitWith { TradeInprogress = false; cutText [(localize "str_epoch_player_16") , "PLAIN DOWN"]; }; _ownerID = _obj getVariable["CharacterID","0"]; diff --git a/SQF/dayz_code/compile/player_unlockDoor.sqf b/SQF/dayz_code/compile/player_unlockDoor.sqf index 22ae730a2..c9fc46e4b 100644 --- a/SQF/dayz_code/compile/player_unlockDoor.sqf +++ b/SQF/dayz_code/compile/player_unlockDoor.sqf @@ -17,46 +17,56 @@ if(!isNull dayz_selectedDoor) then { // our target _obj = dayz_selectedDoor; - // get object combination - _objectCharacterID = _obj getVariable ["CharacterID","0"]; + _notNearestPlayer = _obj call dze_isnearest_player; - // Check combination - if (DZE_Lock_Door == _objectCharacterID) then { - - [player,"combo_unlock",0,false] call dayz_zombieSpeak; - - // close display + if (_notNearestPlayer) then { + // close display since another player is closer _display = findDisplay 41144; _display closeDisplay 3000; - - // unlock if locked - if(_obj animationPhase "Open_hinge" == 0) then { - _obj animate ["Open_hinge", 1]; - }; - - if(_obj animationPhase "Open_latch" == 0) then { - _obj animate ["Open_latch", 1]; - }; - KeyCodeTry = nil; - + cutText ["Failed, another player is closer than you are.", "PLAIN DOWN"]; } else { - DZE_Lock_Door = ""; - [player,"combo_locked",0,false] call dayz_zombieSpeak; - [player,20,true,(getPosATL player)] spawn player_alertZombies; + + // get object combination + _objectCharacterID = _obj getVariable ["CharacterID","0"]; - if (isNil 'KeyCodeTry') then {KeyCodeTry = 0;}; + // Check combination + if (DZE_Lock_Door == _objectCharacterID) then { + + [player,"combo_unlock",0,false] call dayz_zombieSpeak; - KeyCodeTry = KeyCodeTry + 1; - - if (!isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;}; - - if(KeyCodeTry >= ((round(random 4)) + 4)) then { - - if (isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;}; - - cutText [(localize "str_epoch_player_19"), "PLAIN DOWN"]; + // close display _display = findDisplay 41144; _display closeDisplay 3000; + + // unlock if locked + if(_obj animationPhase "Open_hinge" == 0) then { + _obj animate ["Open_hinge", 1]; + }; + + if(_obj animationPhase "Open_latch" == 0) then { + _obj animate ["Open_latch", 1]; + }; + KeyCodeTry = nil; + + } else { + DZE_Lock_Door = ""; + [player,"combo_locked",0,false] call dayz_zombieSpeak; + [player,20,true,(getPosATL player)] spawn player_alertZombies; + + if (isNil 'KeyCodeTry') then {KeyCodeTry = 0;}; + + KeyCodeTry = KeyCodeTry + 1; + + if (!isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;}; + + if(KeyCodeTry >= ((round(random 4)) + 4)) then { + + if (isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;}; + + cutText [(localize "str_epoch_player_19"), "PLAIN DOWN"]; + _display = findDisplay 41144; + _display closeDisplay 3000; + }; }; }; } else { diff --git a/SQF/dayz_code/compile/player_unlockVault.sqf b/SQF/dayz_code/compile/player_unlockVault.sqf index eb161587f..5e92734ba 100644 --- a/SQF/dayz_code/compile/player_unlockVault.sqf +++ b/SQF/dayz_code/compile/player_unlockVault.sqf @@ -8,12 +8,12 @@ private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_we if(TradeInprogress) exitWith { cutText [(localize "str_epoch_player_21") , "PLAIN DOWN"]; }; TradeInprogress = true; -// Test cannot lock while another player is nearby -_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1; -if(_playerNear) exitWith { TradeInprogress = false; cutText [(localize "str_epoch_player_20") , "PLAIN DOWN"]; }; - _obj = _this; +_playerNear = _obj call dze_isnearest_player; + +if(_playerNear) exitWith { TradeInprogress = false; cutText [(localize "str_epoch_player_20") , "PLAIN DOWN"]; }; + _unlockedClass = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "unlockedClass"); _text = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "displayName"); diff --git a/SQF/dayz_code/compile/player_upgradeVehicle.sqf b/SQF/dayz_code/compile/player_upgradeVehicle.sqf index d2337be31..a5f331772 100644 --- a/SQF/dayz_code/compile/player_upgradeVehicle.sqf +++ b/SQF/dayz_code/compile/player_upgradeVehicle.sqf @@ -20,8 +20,10 @@ _IsNearVehicle = count (_findNearestVehicle); if (_IsNearVehicle >= 1) then { _vehicle = _findNearestVehicle select 0; + + _notNearestPlayer = _vehicle call dze_isnearest_player; - if (!isNull _vehicle and local _vehicle) then { + if (!isNull _vehicle and local _vehicle and !_notNearestPlayer) then { _classname = typeOf _vehicle; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 79c52369f..f02834baa 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -417,6 +417,25 @@ if (!isDedicated) then { _objName = toLower(toString(_objName)); _objName }; + + dze_isnearest_player = { + private ["_notClosest","_playerDistance","_nearPlayers","_obj","_playerNear"]; + if(!isNull _this) then { + _nearPlayers = _this nearEntities ["CAManBase", 12]; + _playerNear = ({isPlayer _x} count _nearPlayers) > 1; + _notClosest = false; + if (_playerNear) then { + // check if another player is closer + _playerDistance = player distance _this; + { + if (_playerDistance > (_x distance _this)) exitWith { _notClosest = true; }; + } forEach _nearPlayers; + }; + } else { + _notClosest = false; + }; + _notClosest + }; dayz_originalPlayer = player;