Advertisement
Guest User

server_monitor.sqf

a guest
Jan 28th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. []execVM "\z\addons\dayz_server\system\s_fps.sqf";
  2. dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
  3. dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  4. diag_log("SERVER VERSION: Bliss v4.2");
  5. if ((count playableUnits == 0) and !isDedicated) then {
  6. isSinglePlayer = true;
  7. };
  8. waitUntil{initialized};
  9. //Send the key
  10. //Send the key
  11. _key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
  12. _data = "HiveEXT" callExtension _key;
  13. diag_log("SERVER: Fetching messages...");
  14. //Process result
  15. _result = call compile format ["%1", _data];
  16. _status = _result select 0;
  17. msgList = [];
  18. _msgCount = 0;
  19. if (_status == "CustomStreamStart") then {
  20. _val = _result select 1;
  21. for "_i" from 1 to _val do {
  22. _data = "HiveEXT" callExtension _key;
  23. _result = call compile format ["%1",_data];
  24. _status = _result select 0;
  25. msgList set [count msgList, _result];
  26. _msgCount = _msgCount + 1;
  27. };
  28. diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
  29. };
  30. //Send the key
  31. //Send the key
  32. _key = format["CHILD:302:%1:", dayZ_instance];
  33. _data = "HiveEXT" callExtension _key;
  34. diag_log("SERVER: Fetching objects...");
  35. //Process result
  36. _result = call compile format ["%1", _data];
  37. _status = _result select 0;
  38. _objList = [];
  39. _objCount = 0;
  40. if (_status == "ObjectStreamStart") then {
  41. _val = _result select 1;
  42. for "_i" from 1 to _val do {
  43. _data = "HiveEXT" callExtension _key;
  44. _result = call compile format ["%1",_data];
  45. _status = _result select 0;
  46. _objList set [count _objList, _result];
  47. _objCount = _objCount + 1;
  48. };
  49. diag_log ("SERVER: Fetched " + str(_objCount) + " objects!");
  50. };
  51. //Spawn objects
  52. _countr = 0;
  53. {
  54. //Parse individual vehicle row
  55. _countr = _countr + 1;
  56. _idKey = _x select 1;
  57. _type = _x select 2;
  58. _ownerID = _x select 3;
  59.  
  60. _worldspace = _x select 4;
  61. _dir = 0;
  62. _pos = [0,0,0];
  63. _wsDone = false;
  64. if (count _worldspace >= 2) then
  65. {
  66. _dir = _worldspace select 0;
  67. if (count (_worldspace select 1) == 3) then {
  68. _pos = _worldspace select 1;
  69. _wsDone = true;
  70. }
  71. };
  72. if (!_wsDone) then {
  73. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  74. _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  75. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  76. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  77. };
  78.  
  79. _intentory= _x select 5;
  80. _hitPoints= _x select 6;
  81. _fuel = _x select 7;
  82. _damage = _x select 8;
  83.  
  84. if (_damage < 1) then {
  85. diag_log("Spawned: " + str(_idKey) + " " + _type);
  86.  
  87. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  88. _object setVariable ["lastUpdate",time];
  89. // Don't set objects for deployables to ensure proper inventory updates
  90. if (_ownerID == "0") then {
  91. _object setVariable ["ObjectID", str(_idKey), true];
  92. } else {
  93. _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
  94. };
  95. _object setVariable ["CharacterID", _ownerID, true];
  96.  
  97. clearWeaponCargoGlobal _object;
  98. clearMagazineCargoGlobal _object;
  99.  
  100. if (_object isKindOf "TentStorage") then {
  101. _pos set [2,0];
  102. _object setpos _pos;
  103. };
  104. _object setdir _dir;
  105. _object setDamage _damage;
  106.  
  107. if (count _intentory > 0) then {
  108. //Add weapons
  109. _objWpnTypes = (_intentory select 0) select 0;
  110. _objWpnQty = (_intentory select 0) select 1;
  111. _countr = 0;
  112. {
  113. _isOK = isClass(configFile >> "CfgWeapons" >> _x);
  114. if (_isOK) then {
  115. _block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
  116. if (!_block) then {
  117. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  118. };
  119. };
  120. _countr = _countr + 1;
  121. } forEach _objWpnTypes;
  122.  
  123. //Add Magazines
  124. _objWpnTypes = (_intentory select 1) select 0;
  125. _objWpnQty = (_intentory select 1) select 1;
  126. _countr = 0;
  127. {
  128. _isOK = isClass(configFile >> "CfgMagazines" >> _x);
  129. if (_isOK) then {
  130. _block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
  131. if (!_block) then {
  132. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  133. };
  134. };
  135. _countr = _countr + 1;
  136. } forEach _objWpnTypes;
  137. //Add Backpacks
  138. _objWpnTypes = (_intentory select 2) select 0;
  139. _objWpnQty = (_intentory select 2) select 1;
  140. _countr = 0;
  141. {
  142. _isOK = isClass(configFile >> "CfgVehicles" >> _x);
  143. if (_isOK) then {
  144. _block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
  145. if (!_block) then {
  146. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  147. };
  148. };
  149. _countr = _countr + 1;
  150. } forEach _objWpnTypes;
  151. };
  152.  
  153. if (_object isKindOf "AllVehicles") then {
  154. {
  155. _selection = _x select 0;
  156. _dam = _x select 1;
  157. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  158. [_object,_selection,_dam] call object_setFixServer;
  159. } forEach _hitpoints;
  160. _object setvelocity [0,0,1];
  161. _object setFuel _fuel;
  162. if (getDammage _object == 1) then {
  163. _position = ([(getPosATL _object),0,100,10,0,500,0] call BIS_fnc_findSafePos);
  164. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  165. _object setPosATL _position;
  166. };
  167. _object call fnc_vehicleEventHandler;
  168. };
  169. //Monitor the object
  170. //_object enableSimulation false;
  171. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  172. };
  173. } forEach _objList;
  174. //Send the key
  175. _key = format["CHILD:999:select b.class_name, ib.worldspace from instance_building ib join building b on ib.building_id = b.id where ib.instance_id = ?:[%1]:", dayZ_instance];
  176. _data = "HiveEXT" callExtension _key;
  177. diag_log("SERVER: Fetching buildings...");
  178. //Process result
  179. _result = call compile format ["%1", _data];
  180. _status = _result select 0;
  181. _bldList = [];
  182. _bldCount = 0;
  183. if (_status == "CustomStreamStart") then {
  184. _val = _result select 1;
  185. for "_i" from 1 to _val do {
  186. _data = "HiveEXT" callExtension _key;
  187. _result = call compile format ["%1",_data];
  188. _pos = call compile (_result select 1);
  189. _dir = _pos select 0;
  190. _pos = _pos select 1;
  191. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  192. _building setDir _dir;
  193. _bldCount = _bldCount + 1;
  194. };
  195. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  196. };
  197. //Set the Time
  198. _key = "CHILD:307:";
  199. _result = [_key] call server_hiveReadWrite;
  200. _outcome = _result select 0;
  201. if (_outcome == "PASS") then {
  202. _date = _result select 1;
  203. if (isDedicated) then {
  204. setDate _date;
  205. dayzSetDate = _date;
  206. publicVariable "dayzSetDate";
  207. };
  208. diag_log("HIVE: Local Time set to " + str(_date));
  209. };
  210.  
  211. createCenter civilian;
  212. if (isDedicated) then {
  213. endLoadingScreen;
  214. };
  215. hiveInUse = false;
  216. if (isDedicated) then {
  217. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  218. };
  219. allowConnection = true;
  220. for "_x" from 1 to 20 do {
  221. _id = [] spawn spawn_wrecks;
  222. }; //Spawn wrecks
  223. for "_x" from 1 to 20 do {
  224. _id = [] spawn spawn_wrecks;
  225. }; //Spawn wrecks
  226. for "_x" from 1 to 6 do {
  227. _id = [] spawn spawn_carePackages;
  228. }; //Spawn care packages
  229. for "_x" from 1 to 20 do {
  230. _id = [] spawn spawn_wrecks;
  231. }; //Spawn wrecks
  232. for "_x" from 1 to 5 do {
  233. _id = [] spawn spawn_heliCrash;
  234. }; //Spawn heli crash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement