Advertisement
Dusty_Nuttles

server_monitor.sqf

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