From b24dce7298871416304603878f29e8592eca881d Mon Sep 17 00:00:00 2001 From: vbawol Date: Sun, 2 Jun 2013 11:46:48 -0500 Subject: [PATCH] + [FIXED] Testing some dupe fixes now require that no player is nearby when selling vehicles, safe actions, and "take" items. --- dayz_code/actions/object_pickup.sqf | 4 + dayz_code/actions/trade_any_boat.sqf | 4 + dayz_code/actions/trade_any_vehicle.sqf | 4 + dayz_code/compile/player_lockVault.sqf | 4 + dayz_code/compile/player_packVault.sqf | 42 +++--- dayz_code/compile/player_unlockVault.sqf | 159 +++++++++++++---------- 6 files changed, 127 insertions(+), 90 deletions(-) diff --git a/dayz_code/actions/object_pickup.sqf b/dayz_code/actions/object_pickup.sqf index b43d3e4fc..be98dd569 100644 --- a/dayz_code/actions/object_pickup.sqf +++ b/dayz_code/actions/object_pickup.sqf @@ -6,6 +6,10 @@ if(player isKindOf "PZombie_VB") exitWith {}; if(TradeInprogress) exitWith { cutText ["Take item already in progress." , "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 ["Cannot take item while another player is nearby." , "PLAIN DOWN"]; }; + _array = _this select 3; _type = _array select 0; _classname = _array select 1; diff --git a/dayz_code/actions/trade_any_boat.sqf b/dayz_code/actions/trade_any_boat.sqf index f34883508..071d34bff 100644 --- a/dayz_code/actions/trade_any_boat.sqf +++ b/dayz_code/actions/trade_any_boat.sqf @@ -3,6 +3,10 @@ private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in", if(TradeInprogress) exitWith { cutText ["Trade already in progress." , "PLAIN DOWN"]; }; TradeInprogress = true; +// Test cannot lock while another player is nearby +_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1; +if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot trade while another player is nearby." , "PLAIN DOWN"]; }; + // [part_out,part_in, qty_out, qty_in, loc]; _activatingPlayer = _this select 1; diff --git a/dayz_code/actions/trade_any_vehicle.sqf b/dayz_code/actions/trade_any_vehicle.sqf index df9b18616..74c6303a1 100644 --- a/dayz_code/actions/trade_any_vehicle.sqf +++ b/dayz_code/actions/trade_any_vehicle.sqf @@ -3,6 +3,10 @@ private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in", if(TradeInprogress) exitWith { cutText ["Trade already in progress." , "PLAIN DOWN"]; }; TradeInprogress = true; +// Test cannot lock while another player is nearby +_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1; +if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot trade while another player is nearby." , "PLAIN DOWN"]; }; + // [part_out,part_in, qty_out, qty_in, loc]; _activatingPlayer = _this select 1; diff --git a/dayz_code/compile/player_lockVault.sqf b/dayz_code/compile/player_lockVault.sqf index 9cd5934e6..37ba62a3d 100644 --- a/dayz_code/compile/player_lockVault.sqf +++ b/dayz_code/compile/player_lockVault.sqf @@ -12,6 +12,10 @@ _obj = _this; // 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", 12]) > 1; +if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot lock vault while another player is nearby." , "PLAIN DOWN"]; }; + _ownerID = _obj getVariable["CharacterID","0"]; _objectID = _obj getVariable["ObjectID","0"]; _objectUID = _obj getVariable["ObjectUID","0"]; diff --git a/dayz_code/compile/player_packVault.sqf b/dayz_code/compile/player_packVault.sqf index 13d410a01..551608ccc 100644 --- a/dayz_code/compile/player_packVault.sqf +++ b/dayz_code/compile/player_packVault.sqf @@ -9,7 +9,11 @@ TradeInprogress = true; _obj = _this; // Silently exit if object no longer exists -if(isNull _obj) exitWith { TradeInprogress = false; }; +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; +if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot pack vault while another player is nearby." , "PLAIN DOWN"]; }; _ownerID = _obj getVariable["CharacterID","0"]; _objectID = _obj getVariable["ObjectID","0"]; @@ -36,37 +40,36 @@ if(_location1 distance _location2 > 0.1) exitWith { _obj setVariable["packing",0]; }; -player playActionNow "Medic"; _dir = direction _obj; - _pos = _obj getVariable["OEMPos",(getposATL _obj)]; - -[player,"tentpack",0,false] call dayz_zombieSpeak; -sleep 3; -if(!isNull _obj) then { +if(!isNull _obj and alive _obj) then { - //place tent (local) - _bag = createVehicle ["WeaponHolder_ItemVault",_pos,[], 0, "CAN_COLLIDE"]; - _bag setdir _dir; - _bag setpos _pos; - player reveal _bag; + player playActionNow "Medic"; + [player,"tentpack",0,false] call dayz_zombieSpeak; + sleep 3; - _holder = "WeaponHolder" createVehicle _pos; - _weapons = getWeaponCargo _obj; _magazines = getMagazineCargo _obj; _backpacks = getBackpackCargo _obj; - //["dayzDeleteObj",[_objectID,_objectUID]] call callRpcProcedure; + // Remove from database dayzDeleteObj = [_objectID,_objectUID]; publicVariableServer "dayzDeleteObj"; - if (isServer) then { - dayzDeleteObj call server_deleteObj; - }; - + + // Set down vault "take" item + _bag = createVehicle ["WeaponHolder_ItemVault",_pos,[], 0, "CAN_COLLIDE"]; + + // Delete original deleteVehicle _obj; + + _bag setdir _dir; + _bag setpos _pos; + player reveal _bag; + + // Empty weapon holder + _holder = "WeaponHolder" createVehicle _pos; //Add weapons _objWpnTypes = _weapons select 0; @@ -95,7 +98,6 @@ if(!isNull _obj) then { _countr = _countr + 1; } forEach _objWpnTypes; - cutText ["Your Safe has been packed", "PLAIN DOWN"]; s_player_packvault = -1; diff --git a/dayz_code/compile/player_unlockVault.sqf b/dayz_code/compile/player_unlockVault.sqf index 7b688bc26..2958f3610 100644 --- a/dayz_code/compile/player_unlockVault.sqf +++ b/dayz_code/compile/player_unlockVault.sqf @@ -6,96 +6,115 @@ private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_we if(TradeInprogress) exitWith { cutText ["Unlock already in progress." , "PLAIN DOWN"]; }; TradeInprogress = true; +// Test cannot lock while another player is nearby +_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1; +if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot unlock vault while another player is nearby." , "PLAIN DOWN"]; }; + +_obj = _this; +_alreadyPacking = _obj getVariable["packing",0]; +_claimedBy = _holder getVariable["claimed","0"]; + {player removeAction _x} forEach s_player_combi;s_player_combi = []; s_player_unlockvault = 1; -_obj = _this; - -// Silently exit if object no longer exists -if(isNull _obj) exitWith { TradeInprogress = false; }; +// Silently exit if object no longer exists or alive +if(isNull _obj or !(alive _obj)) exitWith { TradeInprogress = false; }; _ownerID = _obj getVariable["CharacterID","0"]; -_objectID = _obj getVariable["ObjectID","0"]; -_objectUID = _obj getVariable["ObjectUID","0"]; -player playActionNow "Medic"; -_alreadyPacking = _obj getVariable["packing",0]; - -if (_alreadyPacking == 1) exitWith {TradeInprogress = false; s_player_unlockvault = -1; cutText ["That Safe is already being unlocked." , "PLAIN DOWN"]}; +if (_alreadyPacking == 1) exitWith {TradeInprogress = false; cutText ["That Safe is already being unlocked." , "PLAIN DOWN"]}; // Promt user for password if _ownerID != dayz_playerUID - if ((_ownerID == dayz_combination) or (_ownerID == dayz_playerUID)) then { - - _obj setVariable["packing",1]; + // Check if any players are nearby if not allow player to claim item. + _playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1; + + _playerID = getPlayerUID player; + + // Only allow if not already claimed. + if (_claimedBy == "0" or !_playerNear) then { + // Since item was not claimed proceed with claiming it. + _holder setVariable["claimed",_playerID,true]; + }; + _dir = direction _obj; - // _pos = getposATL _obj; _pos = _obj getVariable["OEMPos",(getposATL _obj)]; - //player playActionNow "Medic"; - sleep 1; - [player,"tentpack",0,false] call dayz_zombieSpeak; - sleep 5; + _objectID = _obj getVariable["ObjectID","0"]; + _objectUID = _obj getVariable["ObjectUID","0"]; - if(!isNull _obj) then { - - //place tent (local) - _holder = createVehicle ["VaultStorage",_pos,[], 0, "CAN_COLLIDE"]; - _holder setdir _dir; - _holder setpos _pos; - player reveal _holder; + _claimedBy = _holder getVariable["claimed","0"]; - _holder setVariable["CharacterID",_ownerID,true]; - _holder setVariable["ObjectID",_objectID,true]; - _holder setVariable["ObjectUID",_objectUID,true]; - _holder setVariable ["OEMPos", _pos, true]; + if (_claimedBy != _playerID) then { - _weapons = _obj getVariable["WeaponCargo",[]]; - _magazines = _obj getVariable["MagazineCargo",[]]; - _backpacks = _obj getVariable["BackpackCargo",[]]; - - // Remove locked vault - - deleteVehicle _obj; + if(!isNull _obj and alive _obj) then { - if (count _weapons > 0) then { - //Add weapons - _objWpnTypes = _weapons select 0; - _objWpnQty = _weapons select 1; - _countr = 0; - { - _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; - _countr = _countr + 1; - } forEach _objWpnTypes; + _obj setVariable["packing",1]; + + _weapons = _obj getVariable["WeaponCargo",[]]; + _magazines = _obj getVariable["MagazineCargo",[]]; + _backpacks = _obj getVariable["BackpackCargo",[]]; + + //player playActionNow "Medic"; + sleep 1; + [player,"tentpack",0,false] call dayz_zombieSpeak; + sleep 5; + + //place tent (local) + _holder = createVehicle ["VaultStorage",_pos,[], 0, "CAN_COLLIDE"]; + // Remove locked vault + deleteVehicle _obj; + _holder setdir _dir; + _holder setpos _pos; + player reveal _holder; + + _holder setVariable["CharacterID",_ownerID,true]; + _holder setVariable["ObjectID",_objectID,true]; + _holder setVariable["ObjectUID",_objectUID,true]; + _holder setVariable ["OEMPos", _pos, true]; + + if (count _weapons > 0) then { + //Add weapons + _objWpnTypes = _weapons select 0; + _objWpnQty = _weapons select 1; + _countr = 0; + { + _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + }; + + if (count _magazines > 0) then { + //Add Magazines + _objWpnTypes = _magazines select 0; + _objWpnQty = _magazines select 1; + _countr = 0; + { + _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + }; + + if (count _backpacks > 0) then { + //Add Backpacks + _objWpnTypes = _backpacks select 0; + _objWpnQty = _backpacks select 1; + _countr = 0; + { + _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + }; + + cutText ["Safe has been unlocked.", "PLAIN DOWN"]; }; - - if (count _magazines > 0) then { - //Add Magazines - _objWpnTypes = _magazines select 0; - _objWpnQty = _magazines select 1; - _countr = 0; - { - _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; - _countr = _countr + 1; - } forEach _objWpnTypes; - }; - - if (count _backpacks > 0) then { - //Add Backpacks - _objWpnTypes = _backpacks select 0; - _objWpnQty = _backpacks select 1; - _countr = 0; - { - _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; - _countr = _countr + 1; - } forEach _objWpnTypes; - }; - - cutText ["Safe has been unlocked.", "PLAIN DOWN"]; + } else { + TradeInprogress = false; + cutText [format[(localize "str_player_beinglooted"),"Safe"] , "PLAIN DOWN"]; }; } else { player playActionNow "Medic"; - sleep 3; + sleep 1; [player,"repair",0,false] call dayz_zombieSpeak; null = [player,25,true,(getPosATL player)] spawn player_alertZombies; sleep 5;