Advertisement
Guest User

server_monitor.sqf

a guest
Jun 1st, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.32 KB | None | 0 0
  1. []execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
  2. dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
  3. dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  4. _script = getText(missionConfigFile >> "onPauseScript");
  5. if ((count playableUnits == 0) and !isDedicated) then {
  6. isSinglePlayer = true;
  7. };
  8. waitUntil{initialized}; //means all the functions are now defined
  9. diag_log "HIVE: Starting";
  10. if (_script != "") then
  11. {
  12. diag_log "MISSION: File Updated";
  13. } else {
  14. while {true} do
  15. {
  16. diag_log "MISSION: File Needs Updating";
  17. sleep 1;
  18. };
  19. };
  20. //Stream in objects
  21. /* STREAM OBJECTS */
  22. //Send the key
  23. _key = format["CHILD:302:%1:",dayZ_instance];
  24. _result = _key call server_hiveReadWrite;
  25. diag_log "HIVE: Request sent";
  26.  
  27. //Process result
  28. _status = _result select 0;
  29.  
  30. _myArray = [];
  31. if (_status == "ObjectStreamStart") then {
  32. _val = _result select 1;
  33. //Stream Objects
  34. diag_log ("HIVE: Commence Object Streaming...");
  35. for "_i" from 1 to _val do {
  36. _result = _key call server_hiveReadWrite;
  37. _status = _result select 0;
  38. _myArray set [count _myArray,_result];
  39. //diag_log ("HIVE: Loop ");
  40. };
  41. //diag_log ("HIVE: Streamed " + str(_val) + " objects");
  42. };
  43.  
  44. _countr = 0;
  45. {
  46.  
  47. //Parse Array
  48. _countr = _countr + 1;
  49.  
  50. _idKey = _x select 1;
  51. _type = _x select 2;
  52. _ownerID = _x select 3;
  53. _worldspace = _x select 4;
  54. _intentory= _x select 5;
  55. _hitPoints= _x select 6;
  56. _fuel = _x select 7;
  57. _damage = _x select 8;
  58. _dir = 0;
  59. _pos = [0,0,0];
  60. _wsDone = false;
  61. if (count _worldspace >= 2) then
  62. {
  63. _dir = _worldspace select 0;
  64. if (count (_worldspace select 1) == 3) then {
  65. _pos = _worldspace select 1;
  66. _wsDone = true;
  67. }
  68. };
  69. if (!_wsDone) then {
  70. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  71. _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  72. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  73. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  74. };
  75.  
  76. if (_damage < 1) then {
  77. diag_log format["OBJ: %1 - %2", _idKey,_type];
  78.  
  79. //Create it
  80. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  81. _object setVariable ["lastUpdate",time];
  82. if (_ownerID == "0") then {_object setVariable ["ObjectID", str(_idKey), true];} else {_object setVariable ["ObjectUID", str(_idKey),true];}; //_object setVariable ["ObjectID", _idKey, true];
  83. _object setVariable ["CharacterID", _ownerID, true];
  84.  
  85. clearWeaponCargoGlobal _object;
  86. clearMagazineCargoGlobal _object;
  87.  
  88. if (_object isKindOf "AN2_DZ") then {
  89.  
  90. _object addWeapon "M240_veh";
  91. _object addMagazine "100Rnd_762x51_M240";
  92. _object addMagazine "100Rnd_762x51_M240";
  93. };
  94.  
  95. if (_object isKindOf "TentStorage") then {
  96. _pos set [2,0];
  97. _object setpos _pos;
  98. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  99. };
  100. _object setdir _dir;
  101. _object setDamage _damage;
  102.  
  103. if (count _intentory > 0) then {
  104. //Add weapons
  105. _objWpnTypes = (_intentory select 0) select 0;
  106. _objWpnQty = (_intentory select 0) select 1;
  107. _countr = 0;
  108. {
  109. if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  110. _isOK = isClass(configFile >> "CfgWeapons" >> _x);
  111. if (_isOK) then {
  112. _block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
  113. if (!_block) then {
  114. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  115. };
  116. };
  117. _countr = _countr + 1;
  118. } forEach _objWpnTypes;
  119.  
  120. //Add Magazines
  121. _objWpnTypes = (_intentory select 1) select 0;
  122. _objWpnQty = (_intentory select 1) select 1;
  123. _countr = 0;
  124. {
  125. if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  126. _isOK = isClass(configFile >> "CfgMagazines" >> _x);
  127. if (_isOK) then {
  128. _block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
  129. if (!_block) then {
  130. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  131. };
  132. };
  133. _countr = _countr + 1;
  134. } forEach _objWpnTypes;
  135. //Add Backpacks
  136. _objWpnTypes = (_intentory select 2) select 0;
  137. _objWpnQty = (_intentory select 2) select 1;
  138. _countr = 0;
  139. {
  140. _isOK = isClass(configFile >> "CfgVehicles" >> _x);
  141. if (_isOK) then {
  142. _block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
  143. if (!_block) then {
  144. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  145. };
  146. };
  147. _countr = _countr + 1;
  148. } forEach _objWpnTypes;
  149. };
  150.  
  151. if (_object isKindOf "AllVehicles") then {
  152. {
  153. _selection = _x select 0;
  154. _dam = _x select 1;
  155. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  156. [_object,_selection,_dam] call object_setFixServer;
  157. } forEach _hitpoints;
  158. _object setvelocity [0,0,1];
  159. _object setFuel _fuel;
  160. _object call fnc_vehicleEventHandler;
  161. };
  162.  
  163. //Monitor the object
  164. //_object enableSimulation false;
  165. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  166. };
  167. } forEach _myArray;
  168.  
  169. // # END OF STREAMING #
  170. //Send the key
  171. _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];
  172. _data = "HiveEXT" callExtension _key;
  173. diag_log("SERVER: Fetching buildings...");
  174. //Process result
  175. _result = call compile format ["%1", _data];
  176. _status = _result select 0;
  177. _bldList = [];
  178. _bldCount = 0;
  179. if (_status == "CustomStreamStart") then {
  180. _val = _result select 1;
  181. for "_i" from 1 to _val do {
  182. _data = "HiveEXT" callExtension _key;
  183. _result = call compile format ["%1",_data];
  184. _pos = call compile (_result select 1);
  185. _dir = _pos select 0;
  186. _pos = _pos select 1;
  187. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  188. _building setDir _dir;
  189. _bldCount = _bldCount + 1;
  190. };
  191. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  192. };
  193. //Set the Time
  194. //Send request
  195. _key = "CHILD:307:";
  196. _result = _key call server_hiveReadWrite;
  197. _outcome = _result select 0;
  198. if(_outcome == "PASS") then {
  199. _date = _result select 1;
  200. if(isDedicated) then {
  201. //["dayzSetDate",_date] call broadcastRpcCallAll;
  202. setDate _date;
  203. dayzSetDate = _date;
  204. publicVariable "dayzSetDate";
  205. };
  206. diag_log ("HIVE: Local Time set to " + str(_date));
  207. };
  208.  
  209. createCenter civilian;
  210. if (isDedicated) then {
  211. endLoadingScreen;
  212. };
  213.  
  214. if (isDedicated) then {
  215. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  216. };
  217. allowConnection = true;
  218. // [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
  219. nul = [3, 4, (50 * 60), (15 * 60), 0.75, 'center', 4000, true, false] spawn server_spawnCrashSite;
  220. for "_x" from 1 to 6 do {
  221. _id = [] spawn spawn_carePackages;
  222. }; //Spawn care packages
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement