Advertisement
Guest User

vehicle3

a guest
Sep 21st, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 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.  
  74. clearWeaponCargoGlobal _object;
  75. clearMagazineCargoGlobal _object;
  76. clearBackpackCargoGlobal _object;
  77.  
  78. // Remove marker
  79. deleteVehicle _object;
  80.  
  81. _newobject = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
  82.  
  83. // remove old vehicle from DB
  84. [_objectID,_objectUID,_activatingPlayer] call server_deleteObj;
  85.  
  86. // switch var to new vehicle at this point.
  87. _object = _newobject;
  88.  
  89. _object setDir _dir;
  90. _object setPosATL _location;
  91.  
  92. if (_class == "hilux1_civil_3_open") then {_object setVehicleInit 'this setObjectTexture [0, ''\custom\hilux.jpg''];';};
  93. //Add weapons
  94. _objWpnTypes = _weapons select 0;
  95. _objWpnQty = _weapons select 1;
  96. _countr = 0;
  97. {
  98. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  99. _countr = _countr + 1;
  100. } count _objWpnTypes;
  101.  
  102. //Add Magazines
  103. _objWpnTypes = _magazines select 0;
  104. _objWpnQty = _magazines select 1;
  105. _countr = 0;
  106. {
  107. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  108. _countr = _countr + 1;
  109. } count _objWpnTypes;
  110.  
  111. //Add Backpacks
  112. _objWpnTypes = _backpacks select 0;
  113. _objWpnQty = _backpacks select 1;
  114. _countr = 0;
  115. {
  116. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  117. _countr = _countr + 1;
  118. } count _objWpnTypes;
  119.  
  120. _object setVariable ["ObjectID", _oid, true];
  121.  
  122. _object setVariable ["lastUpdate",time];
  123.  
  124. _object setVariable ["CharacterID", _characterID, true];
  125.  
  126. PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
  127.  
  128. _object call fnc_veh_ResetEH;
  129.  
  130. // for non JIP users this should make sure everyone has eventhandlers for vehicles.
  131. PVDZE_veh_Init = _object;
  132. publicVariable "PVDZE_veh_Init";
  133.  
  134. processInitCommands;
  135.  
  136. diag_log ("PUBLISH: " + str(_activatingPlayer) + " Upgraded " + (_class) + " with ID " + str(_uid));
  137. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement