Advertisement
Guest User

SwapObject

a guest
Jun 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.93 KB | None | 0 0
  1. private ["_class","_uid","_charID","_object","_worldspace","_key","_allowed","_obj","_inv","_objectID","_objectUID","_proceed","_activatingplayer","_clientKey","_exitReason","_playerUID"];
  2.  
  3. if (count _this < 8) exitWith {diag_log "Server_SwapObject error: Wrong parameter format";};
  4.  
  5. _charID =       _this select 0;
  6. _object =       _this select 1;
  7. _worldspace =   _this select 2;
  8. _class =        _this select 3;
  9. _obj =          _this select 4;
  10. _activatingplayer = _this select 5;
  11. _inv = _this select 6;
  12. _clientKey = _this select 7;
  13. _proceed = false;
  14. _objectID = "0";
  15. _objectUID = "0";
  16. _playerUID = getPlayerUID _activatingPlayer;
  17.  
  18. _exitReason = [_this,"SwapObject",(_worldspace select 1),_clientKey,_playerUID,_activatingPlayer] call server_verifySender;
  19. if (_exitReason != "") exitWith {diag_log _exitReason};
  20.  
  21. if(!isNull(_obj)) then {
  22.     // Find objectID
  23.     _objectID   = _obj getVariable ["ObjectID","0"];
  24.     // Find objectUID
  25.     _objectUID  = _obj getVariable ["ObjectUID","0"];
  26.     if !(DZE_GodModeBase) then {
  27.         _obj removeAllMPEventHandlers "MPKilled";
  28.     };
  29.     // Remove old object
  30.     deleteVehicle _obj;
  31.    
  32.     _proceed = true;
  33. };
  34.  
  35. if(isNull(_object)) then {
  36.     _proceed = false;
  37. };
  38.  
  39. if(_objectID == "0" && _objectUID == "0") then {
  40.     _proceed = false;
  41. } else {
  42.     [_objectID,_objectUID] call server_deleteObjDirect;
  43. };
  44.  
  45. _allowed = [_object, "Server"] call check_publishobject;
  46. if (!_allowed || !_proceed) exitWith {
  47.     if(!isNull(_object)) then {
  48.         deleteVehicle _object;
  49.     };
  50.     diag_log ("Invalid object swap by playerUID:" + _playerUID);
  51. };
  52.  
  53. // Publish variables
  54. _object setVariable ["CharacterID",_charID,true];
  55.    
  56. //_object setVariable ["ObjectUID",_objectUID,true];
  57. _object setVariable ["OEMPos",(_worldspace select 1),true];
  58.  
  59. //diag_log ("PUBLISH: Attempt " + str(_object));
  60.  
  61. //get UID
  62. _uid = _worldspace call dayz_objectUID2;
  63.  
  64. //Send request
  65. //_key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0, _charID, _worldspace, [], [], 0,_uid];
  66. _key = str formatText["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0, _charID, _worldspace call AN_fnc_formatWorldspace, _inv, [], 0,_uid]; // Precise Base Building 1.0.5
  67.  
  68. //diag_log ("HIVE: WRITE: "+ str(_key));
  69. _key call server_hiveWrite;
  70.  
  71. _object setVariable ["lastUpdate",diag_tickTime];
  72. _object setVariable ["ObjectUID", _uid,true];
  73. // _object setVariable ["CharacterID",_charID,true];
  74. if (DZE_GodModeBase && {!(_class in DZE_GodModeBaseExclude)}) then {
  75.     _object addEventHandler ["HandleDamage",{false}];
  76. } else {
  77.     _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  78. };
  79. // Test disabling simulation server side on buildables only.
  80. _object enableSimulation false;
  81.  
  82. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  83.  
  84. diag_log format["PUBLISH: Player %1(%2) upgraded or downgraded object to %3 with UID:%4 @%5",(_activatingPlayer call fa_plr2str),_playerUID,_class,_uid,((_worldspace select 1) call fa_coor2str)];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement