Advertisement
Guest User

server_spawnvehicle

a guest
May 20th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. private ["_player","_vehicledata","_arrow","_key","_garage","_class","_cid","_colour1","_inventory","_fuel","_damage","_hitpoints","_location","_dir","_worldspace","_uid","_vehiclelist","_newlist"];
  2. _player = _this select 0;
  3. _vehicledata = _this select 1;
  4. _arrow = _this select 2;
  5. _garage = _this select 3;
  6.  
  7. _class = _vehicledata select 0;
  8. _cid = str(_vehicledata select 1);
  9. _colour1 = _vehicledata select 2;
  10. _colour2 = _vehicledata select 3;
  11. _inventory = _vehicledata select 4;
  12. _fuel = _vehicledata select 5;
  13. _damage = _vehicledata select 6;
  14. _hitpoints = _vehicledata select 7;
  15.  
  16. _location = getPosATL _arrow;
  17. _dir = getDir _garage;
  18. _worldspace = [_dir,_location];
  19.  
  20. _uid = _worldspace call dayz_objectUID3;
  21. _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _cid, _worldspace, [], [], 1,_uid];
  22. diag_log ("HIVE: WRITE: "+ str(_key));
  23. _key call server_hiveWrite;
  24.  
  25. [_arrow,_uid,_cid,_class,_dir,_location,_player,_colour1,_colour2,_inventory,_fuel,_damage,_hitpoints] spawn {
  26. private ["_object","_uid","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class","_location","_object_para","_activatingPlayer","_colour1","_colour2","_inventory","_fuel","_damage","_hitpoints","_clrinit","_clrinit2","_objWpnTypes","_objWpnQty","_countr"];
  27. _object = _this select 0;
  28. _uid = _this select 1;
  29. _characterID = _this select 2;
  30. _class = _this select 3;
  31. _dir = _this select 4;
  32. _location = _this select 5;
  33. _activatingPlayer = _this select 6;
  34. _colour1 = _this select 7;
  35. _colour2 = _this select 8;
  36. _inventory = _this select 9;
  37. _fuel = _this select 10;
  38. _damage = _this select 11;
  39. _hitpoints = _this select 12;
  40.  
  41. _done = false;
  42. _retry = 0;
  43. while {_retry < 10} do {
  44. sleep 1;
  45. _key = format["CHILD:388:%1:",_uid];
  46. diag_log ("HIVE: WRITE: "+ str(_key));
  47. _result = _key call server_hiveReadWrite;
  48. _outcome = _result select 0;
  49. if (_outcome == "PASS") then {
  50. _oid = _result select 1;
  51. diag_log("CUSTOM: Selected " + str(_oid));
  52. _done = true;
  53. _retry = 100;
  54. } else {
  55. diag_log("CUSTOM: trying again to get id for: " + str(_uid));
  56. _done = false;
  57. _retry = _retry + 1;
  58. };
  59. };
  60. deleteVehicle _object;
  61.  
  62. if(!_done) exitWith { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
  63.  
  64. _object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
  65. _object setpos _location;
  66. _object setDir _dir;
  67. _object setvehiclelock "locked";
  68.  
  69. clearWeaponCargoGlobal _object;
  70. clearMagazineCargoGlobal _object;
  71.  
  72. _object setVariable ["ObjectID", _oid, true];
  73. _object setVariable ["lastUpdate",time];
  74. _object setVariable ["CharacterID",_characterID, true];
  75.  
  76. if (_colour1 != "0") then {
  77. _object setVariable ["Colour",_colour1,true];
  78. _clrinit = format ["#(argb,8,8,3)color(%1)",_colour1];
  79. _object setVehicleInit "this setObjectTexture [0,"+str _clrinit+"];";
  80. };
  81. if (_colour2 != "0") then {
  82. _object setVariable ["Colour2",_colour2,true];
  83. _clrinit2 = format ["#(argb,8,8,3)color(%1)",_colour2];
  84. _object setVehicleInit "this setObjectTexture [1,"+str _clrinit2+"];";
  85. };
  86.  
  87. _objWpnTypes = (_inventory select 0) select 0;
  88. _objWpnQty = (_inventory select 0) select 1;
  89. _countr = 0;
  90. {
  91. if(_x in (DZE_REPLACE_WEAPONS select 0)) then {
  92. _x = (DZE_REPLACE_WEAPONS select 1) select ((DZE_REPLACE_WEAPONS select 0) find _x);
  93. };
  94. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  95. _countr = _countr + 1;
  96. } count _objWpnTypes;
  97.  
  98. _objWpnTypes = (_inventory select 1) select 0;
  99. _objWpnQty = (_inventory select 1) select 1;
  100. _countr = 0;
  101. {
  102. if (_x == "BoltSteel") then { _x = "WoodenArrow" };
  103. if (_x == "ItemTent") then { _x = "ItemTentOld" };
  104. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  105. _countr = _countr + 1;
  106. } count _objWpnTypes;
  107.  
  108. _objWpnTypes = (_inventory select 2) select 0;
  109. _objWpnQty = (_inventory select 2) select 1;
  110. _countr = 0;
  111. {
  112. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  113. _countr = _countr + 1;
  114. } count _objWpnTypes;
  115.  
  116. _object setFuel _fuel;
  117. _object setDamage _damage;
  118.  
  119. {
  120. private ["_selection","_dam"];
  121. _selection = _x select 0;
  122. _dam = _x select 1;
  123. if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
  124. [_object,_selection,_dam] call object_setFixServer;
  125. } forEach _hitpoints;
  126.  
  127. PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
  128. _object call fnc_veh_ResetEH;
  129. PVDZE_veh_Init = _object;
  130. publicVariable "PVDZE_veh_Init";
  131. };
  132.  
  133. _vehiclelist = _garage getVariable ["StoredVehicles",[]];
  134.  
  135. _newlist = [];
  136. {
  137. private ["_data","_toremove"];
  138. _toremove = false;
  139. if ((_x select 1) == _cid) then { _toremove = true; };
  140. if (!_toremove) then {
  141. _data = [(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4),(_x select 5),(_x select 6),(_x select 7)];
  142. _newlist set [count _newlist,_data];
  143. };
  144. } count _vehiclelist;
  145.  
  146. _garage setVariable ["StoredVehicles",_newlist,true];
  147.  
  148. diag_log format["VIRTUAL GARAGE: Player %1 (%2) has spawned a %3 | "+str _newlist+"",(name _player),(getPlayerUID _player),_class];
  149.  
  150. [_garage,"gear",_newlist] spawn server_updateObject;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement