Advertisement
Guest User

Untitled

a guest
Jan 5th, 2015
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. private ["_activatingPlayer","_isOK","_object","_worldspace","_location","_dir","_class","_uid","_key","_keySelected","_characterID","_donotusekey"];
  2. //PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
  3. _object = _this select 0;
  4. _worldspace = _this select 1;
  5. _class = _this select 2;
  6. _donotusekey = _this select 3;
  7. _keySelected = _this select 4;
  8. _activatingPlayer = _this select 5;
  9. _characterID = _keySelected;
  10.  
  11. _isOK = isClass(configFile >> "CfgVehicles" >> _class);
  12. if(!_isOK || isNull _object) exitWith { diag_log ("HIVE-pv3: Vehicle does not exist: "+ str(_class)); };
  13.  
  14. diag_log ("PUBLISH: Attempt " + str(_object));
  15. _dir = _worldspace select 0;
  16. _location = _worldspace select 1;
  17.  
  18. //Generate UID test using time
  19. _uid = _worldspace call dayz_objectUID3;
  20.  
  21. //Send request
  22. _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];
  23. diag_log ("HIVE: WRITE: "+ str(_key));
  24. _key call server_hiveWrite;
  25.  
  26. // Switched to spawn so we can wait a bit for the ID
  27. [_object,_uid,_characterID,_class,_dir,_location,_donotusekey,_activatingPlayer] spawn {
  28. private ["_object","_uid","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class","_location","_donotusekey","_activatingPlayer","_countr","_objectID","_objectUID","_dir","_newobject","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty"];
  29.  
  30. _object = _this select 0;
  31. _objectID = _object getVariable ["ObjectID","0"];
  32. _objectUID = _object getVariable ["ObjectUID","0"];
  33. _uid = _this select 1;
  34. _characterID = _this select 2;
  35. _class = _this select 3;
  36. _dir = _this select 4;
  37. // _location = _this select 5;
  38. _location = getPosATL _object;
  39. _donotusekey = _this select 6;
  40. _activatingPlayer = _this select 7;
  41.  
  42. _done = false;
  43. _retry = 0;
  44. // TODO: Needs major overhaul for 1.1
  45. while {_retry < 10} do {
  46.  
  47. sleep 1;
  48. // GET DB ID
  49. _key = format["CHILD:388:%1:",_uid];
  50. diag_log ("HIVE: WRITE: "+ str(_key));
  51. _result = _key call server_hiveReadWrite;
  52. _outcome = _result select 0;
  53. if (_outcome == "PASS") then {
  54. _oid = _result select 1;
  55. //_object setVariable ["ObjectID", _oid, true];
  56. diag_log("CUSTOM: Selected " + str(_oid));
  57. _done = true;
  58. _retry = 100;
  59.  
  60. } else {
  61. diag_log("CUSTOM: trying again to get id for: " + str(_uid));
  62. _done = false;
  63. _retry = _retry + 1;
  64. };
  65. };
  66.  
  67. if(!_done) exitWith { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
  68.  
  69. // add items from previous vehicle here
  70. _weapons = getWeaponCargo _object;
  71. _magazines = getMagazineCargo _object;
  72. _backpacks = getBackpackCargo _object;
  73. /* //Remove Weapon by SiothieGaming start
  74. call fnc_remWepSG;
  75. //Remove Weapon by SiothieGaming end */
  76. clearWeaponCargoGlobal _object;
  77. clearMagazineCargoGlobal _object;
  78. clearBackpackCargoGlobal _object;
  79.  
  80. // Remove marker
  81. deleteVehicle _object;
  82.  
  83. _newobject = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
  84.  
  85. // remove old vehicle from DB
  86. [_objectID,_objectUID,_activatingPlayer] call server_deleteObj;
  87.  
  88. // switch var to new vehicle at this point.
  89. _object = _newobject;
  90.  
  91. _object setDir _dir;
  92. _object setPosATL _location;
  93. /* if (_class == "SUV_Orange_DZE4") then {_object setVehicleInit 'this setObjectTexture [0, ''gui\suvDSRT.jpg''];';};
  94. if (_class == "SUV_White_DZE4") then {_object setVehicleInit 'this setObjectTexture [0, ''gui\suvGREY.jpg''];';}; */
  95. //Add weapons
  96. _objWpnTypes = _weapons select 0;
  97. _objWpnQty = _weapons select 1;
  98. _countr = 0;
  99. {
  100. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  101. _countr = _countr + 1;
  102. } count _objWpnTypes;
  103.  
  104. //Add Magazines
  105. _objWpnTypes = _magazines select 0;
  106. _objWpnQty = _magazines select 1;
  107. _countr = 0;
  108. {
  109. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  110. _countr = _countr + 1;
  111. } count _objWpnTypes;
  112.  
  113. //Add Backpacks
  114. _objWpnTypes = _backpacks select 0;
  115. _objWpnQty = _backpacks select 1;
  116. _countr = 0;
  117. {
  118. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  119. _countr = _countr + 1;
  120. } count _objWpnTypes;
  121.  
  122. _object setVariable ["ObjectID", _oid, true];
  123.  
  124. _object setVariable ["lastUpdate",time];
  125.  
  126. _object setVariable ["CharacterID", _characterID, true];
  127.  
  128. PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
  129.  
  130. _object call fnc_veh_ResetEH;
  131.  
  132. // for non JIP users this should make sure everyone has eventhandlers for vehicles.
  133. PVDZE_veh_Init = _object;
  134. publicVariable "PVDZE_veh_Init";
  135. processInitCommands;
  136. diag_log ("PUBLISH: " + str(_activatingPlayer) + " Upgraded " + (_class) + " with ID " + str(_uid));
  137. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement