From 0fcf880a1d707c7a8645a9b7ea8d2dee288195d3 Mon Sep 17 00:00:00 2001 From: "[VB]AWOL" Date: Mon, 9 Dec 2013 08:59:44 -0600 Subject: [PATCH] fixes to swap object code --- SQF/dayz_code/actions/maintain_area.sqf | 2 +- .../actions/player_buildingDowngrade.sqf | 2 +- .../actions/player_buildingMaint.sqf | 2 +- SQF/dayz_code/actions/player_upgrade.sqf | 2 +- SQF/dayz_server/compile/server_swapObject.sqf | 44 ++++++++++++++----- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/SQF/dayz_code/actions/maintain_area.sqf b/SQF/dayz_code/actions/maintain_area.sqf index 6e9e55e8f..978dc689a 100644 --- a/SQF/dayz_code/actions/maintain_area.sqf +++ b/SQF/dayz_code/actions/maintain_area.sqf @@ -100,7 +100,7 @@ switch _option do { // Set location _object setPosATL _location; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,_objectID,_objectUID]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; publicVariableServer "PVDZE_obj_Swap"; player reveal _object; diff --git a/SQF/dayz_code/actions/player_buildingDowngrade.sqf b/SQF/dayz_code/actions/player_buildingDowngrade.sqf index a31221ef6..da3c0b013 100644 --- a/SQF/dayz_code/actions/player_buildingDowngrade.sqf +++ b/SQF/dayz_code/actions/player_buildingDowngrade.sqf @@ -141,7 +141,7 @@ if ((count _upgrade) > 0) then { cutText [format[(localize "str_epoch_player_142"),_text], "PLAIN DOWN", 5]; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,_objectID,_objectUID,player]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; publicVariableServer "PVDZE_obj_Swap"; player reveal _object; diff --git a/SQF/dayz_code/actions/player_buildingMaint.sqf b/SQF/dayz_code/actions/player_buildingMaint.sqf index 4b3136de0..9862bdb71 100644 --- a/SQF/dayz_code/actions/player_buildingMaint.sqf +++ b/SQF/dayz_code/actions/player_buildingMaint.sqf @@ -98,7 +98,7 @@ if (_proceed) then { // Set location _object setPosATL _location; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,_objectID,_objectUID,(getPlayerUID player)]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; publicVariableServer "PVDZE_obj_Swap"; cutText [format[(localize "str_epoch_player_144"),_text], "PLAIN DOWN", 5]; diff --git a/SQF/dayz_code/actions/player_upgrade.sqf b/SQF/dayz_code/actions/player_upgrade.sqf index 5c748cf6f..05289eba6 100644 --- a/SQF/dayz_code/actions/player_upgrade.sqf +++ b/SQF/dayz_code/actions/player_upgrade.sqf @@ -164,7 +164,7 @@ if ((count _upgrade) > 0) then { cutText [format[(localize "str_epoch_player_159"),_text], "PLAIN DOWN", 5]; }; - PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,_objectID,_objectUID,(getPlayerUID player)]; + PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,player]; publicVariableServer "PVDZE_obj_Swap"; player reveal _object; diff --git a/SQF/dayz_server/compile/server_swapObject.sqf b/SQF/dayz_server/compile/server_swapObject.sqf index 3914e4c07..26b2cb28c 100644 --- a/SQF/dayz_server/compile/server_swapObject.sqf +++ b/SQF/dayz_server/compile/server_swapObject.sqf @@ -1,26 +1,48 @@ -private ["_activatingplayerUID","_class","_uid","_charID","_object","_worldspace","_key","_allowed","_obj","_objectID","_objectUID"]; +private ["_activatingplayerUID","_class","_uid","_charID","_object","_worldspace","_key","_allowed","_obj","_objectID","_objectUID","_proceed","_activatingplayer"]; //[dayz_characterID,_tent,[_dir,_location],"TentStorage"] _charID = _this select 0; _object = _this select 1; _worldspace = _this select 2; _class = _this select 3; _obj = _this select 4; -_activatingplayerUID = _this select 5; +_activatingplayer = _this select 5; +_activatingplayerUID = (getPlayerUID _activatingplayer); -_obj removeAllMPEventHandlers "MPKilled"; +_proceed = false; -// Remove old object -deleteVehicle _obj; +_objectID = "0"; +_objectUID = "0"; -_objectID = _this select 5; -_objectUID = _this select 6; +if(!isNull(_obj)) then { + // Find objectID + _objectID = _obj getVariable ["ObjectID","0"]; + // Find objectUID + _objectUID = _obj getVariable ["ObjectUID","0"]; -if(_objectID == "0" && _objectUID == "0") exitWith {diag_log ("Object not valid: "+ str(_object));}; + _obj removeAllMPEventHandlers "MPKilled"; + // Remove old object + deleteVehicle _obj; + + _proceed = true; +}; -[_objectID,_objectUID,_activatingplayerUID] call server_deleteObj; +if(isNull(_object)) then { + _proceed = false; +}; + +if(_objectID == "0" && _objectUID == "0") then { + _proceed = false; +} else { + [_objectID,_objectUID,_activatingplayer] call server_deleteObj; +}; _allowed = [_object, "Server"] call check_publishobject; -if (!_allowed) exitWith { deleteVehicle _object; }; +if (!_allowed or !_proceed) exitWith { + if(!isNull(_object)) then { + deleteVehicle _object; + }; + diag_log ("Invalid object swap by playerUID:"+ str(_activatingplayerUID)); +}; // Publish variables _object setVariable ["CharacterID",_charID,true]; @@ -48,4 +70,4 @@ _object enableSimulation false; PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object]; -//diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid); +diag_log ("PUBLISH: " + str(_activatingPlayer) + " upgraded " + (_class) + " with ID " + str(_uid)); \ No newline at end of file