Advertisement
Guest User

dayz_server/system/server_monitor.sqf

a guest
Sep 10th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.10 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.  
  5. dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  6.  
  7. _script = getText(missionConfigFile >> "onPauseScript");
  8.  
  9. if ((count playableUnits == 0) and !isDedicated) then {
  10.  
  11. isSinglePlayer = true;
  12.  
  13. };
  14.  
  15. waitUntil{initialized}; //means all the functions are now defined
  16.  
  17. //Oil Rig and Aircraft Carrier
  18.  
  19. _Oilrig = objNull;
  20.  
  21. _Oilrig = createVehicle ["oilrig_base", [10020.368, 1342.6135, -0.043106049], [], 0, "CAN_COLLIDE"];
  22.  
  23. _Oilrig setPos [10020.368, 1342.6135, -0.043106049];
  24.  
  25. _AircraftCarrier = objNull;
  26.  
  27. _AircraftCarrier = createVehicle ["GLT_LHD", [6674.4897, 1949.7725, -0.20630595], [], 0, "CAN_COLLIDE"];
  28.  
  29. _AircraftCarrier setPos [6674.4897, 1949.7725, -0.20630595];
  30.  
  31. //Spawn Bases
  32.  
  33. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\ChernoChurch.sqf";
  34.  
  35. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\DevilsCastle.sqf";
  36.  
  37. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Khelm.sqf";
  38.  
  39. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Polana.sqf";
  40.  
  41. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Bambi.sqf";
  42.  
  43. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\ChernoRoadblock.sqf";
  44.  
  45. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Graveyard_1.sqf";
  46.  
  47. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Graveyard_2.sqf";
  48.  
  49. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Prison.sqf";
  50.  
  51. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Scrapyard.sqf";
  52.  
  53. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\PeodbaDam.sqf";
  54.  
  55. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Nohrt_Cherno.sqf";
  56.  
  57. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Nohrt_Dubrocka.sqf";
  58.  
  59. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\Nohrt_Forrest.sqf";
  60.  
  61. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\ChernExtra11.sqf";
  62.  
  63. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\FavoldCas.sqf";
  64.  
  65. call compile preProcessFileLineNumbers "\z\addons\dayz_server\objects\SurvivorCamps.sqf";
  66.  
  67. //Custom Bases
  68.  
  69. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\otmel_village.sqf";
  70.  
  71. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\skalisty_castle.sqf";
  72.  
  73. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\skalisty_bridge.sqf";
  74.  
  75. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\recamp.sqf";
  76.  
  77. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\novylug.sqf";
  78.  
  79. call compile preProcessFileLineNumbers "\z\addons\dayz_server\custom\objects\mamu_poi3.sqf";
  80.  
  81. //Stream in objects
  82.  
  83. /* STREAM OBJECTS */
  84.  
  85. //Send the key
  86.  
  87. _key = format["CHILD:302:%1:",dayZ_instance];
  88.  
  89. _result = _key call server_hiveReadWrite;
  90.  
  91. diag_log "HIVE: Request sent";
  92.  
  93.  
  94.  
  95. //Process result
  96.  
  97. _status = _result select 0;
  98.  
  99.  
  100.  
  101. _myArray = [];
  102.  
  103. if (_status == "ObjectStreamStart") then {
  104.  
  105. _val = _result select 1;
  106.  
  107. //Stream Objects
  108.  
  109. diag_log ("HIVE: Commence Object Streaming...");
  110.  
  111. for "_i" from 1 to _val do {
  112.  
  113. _result = _key call server_hiveReadWrite;
  114.  
  115. _status = _result select 0;
  116.  
  117. _myArray set [count _myArray,_result];
  118.  
  119. //diag_log ("HIVE: Loop ");
  120.  
  121. };
  122.  
  123. //diag_log ("HIVE: Streamed " + str(_val) + " objects");
  124.  
  125. };
  126.  
  127.  
  128.  
  129. _countr = 0;
  130.  
  131. {
  132.  
  133.  
  134.  
  135. //Parse Array
  136.  
  137. _countr = _countr + 1;
  138.  
  139.  
  140.  
  141. _idKey = _x select 1;
  142.  
  143. _type = _x select 2;
  144.  
  145. _ownerID = _x select 3;
  146.  
  147. _worldspace = _x select 4;
  148.  
  149. _intentory= _x select 5;
  150.  
  151. _hitPoints= _x select 6;
  152.  
  153. _fuel = _x select 7;
  154.  
  155. _damage = _x select 8;
  156.  
  157. _dir = 0;
  158.  
  159. _pos = [0,0,0];
  160.  
  161. _wsDone = false;
  162.  
  163. if (count _worldspace >= 2) then
  164.  
  165. {
  166.  
  167. _dir = _worldspace select 0;
  168.  
  169. if (count (_worldspace select 1) == 3) then {
  170.  
  171. _pos = _worldspace select 1;
  172.  
  173. _wsDone = true;
  174.  
  175. }
  176.  
  177. };
  178.  
  179. if (!_wsDone) then {
  180.  
  181. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  182.  
  183. _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  184.  
  185. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  186.  
  187. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  188.  
  189. };
  190.  
  191.  
  192.  
  193. if (_damage < 1) then {
  194.  
  195. diag_log format["OBJ: %1 - %2", _idKey,_type];
  196.  
  197.  
  198.  
  199. //Create it
  200.  
  201. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  202.  
  203. _object setVariable ["lastUpdate",time];
  204.  
  205. _object setVariable ["ObjectID", _idKey, true];
  206.  
  207. _object setVariable ["CharacterID", _ownerID, true];
  208.  
  209.  
  210.  
  211. clearWeaponCargoGlobal _object;
  212.  
  213. clearMagazineCargoGlobal _object;
  214.  
  215. // AN2 Bi-plane M240
  216.  
  217. if (_entity isKindOf "AN2_DZ") then {
  218.  
  219. _entity addWeapon "M240_veh";
  220.  
  221. _entity addMagazine "100Rnd_762x51_M240";
  222.  
  223. _entity addMagazine "100Rnd_762x51_M240";
  224.  
  225. _entity addMagazine "100Rnd_762x51_M240";
  226.  
  227. };
  228.  
  229. // AN2 Bi-plane M240
  230.  
  231. if (_object isKindOf "TentStorage") then {
  232.  
  233. _pos set [2,0];
  234.  
  235. _object setpos _pos;
  236.  
  237. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  238.  
  239. };
  240.  
  241. _object setdir _dir;
  242.  
  243. _object setDamage _damage;
  244.  
  245.  
  246.  
  247. if (count _intentory > 0) then {
  248.  
  249. //Add weapons
  250.  
  251. _objWpnTypes = (_intentory select 0) select 0;
  252.  
  253. _objWpnQty = (_intentory select 0) select 1;
  254.  
  255. _countr = 0;
  256.  
  257. {
  258.  
  259. if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  260.  
  261. _isOK = isClass(configFile >> "CfgWeapons" >> _x);
  262.  
  263. if (_isOK) then {
  264.  
  265. _block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
  266.  
  267. if (!_block) then {
  268.  
  269. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  270.  
  271. };
  272.  
  273. };
  274.  
  275. _countr = _countr + 1;
  276.  
  277. } forEach _objWpnTypes;
  278.  
  279.  
  280.  
  281. //Add Magazines
  282.  
  283. _objWpnTypes = (_intentory select 1) select 0;
  284.  
  285. _objWpnQty = (_intentory select 1) select 1;
  286.  
  287. _countr = 0;
  288.  
  289. {
  290.  
  291. if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  292.  
  293. _isOK = isClass(configFile >> "CfgMagazines" >> _x);
  294.  
  295. if (_isOK) then {
  296.  
  297. _block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
  298.  
  299. if (!_block) then {
  300.  
  301. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  302.  
  303. };
  304.  
  305. };
  306.  
  307. _countr = _countr + 1;
  308.  
  309. } forEach _objWpnTypes;
  310.  
  311. //Add Backpacks
  312.  
  313. _objWpnTypes = (_intentory select 2) select 0;
  314.  
  315. _objWpnQty = (_intentory select 2) select 1;
  316.  
  317. _countr = 0;
  318.  
  319. {
  320.  
  321. _isOK = isClass(configFile >> "CfgVehicles" >> _x);
  322.  
  323. if (_isOK) then {
  324.  
  325. _block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
  326.  
  327. if (!_block) then {
  328.  
  329. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  330.  
  331. };
  332.  
  333. };
  334.  
  335. _countr = _countr + 1;
  336.  
  337. } forEach _objWpnTypes;
  338.  
  339. };
  340.  
  341.  
  342.  
  343. if (_object isKindOf "AllVehicles") then {
  344.  
  345. {
  346.  
  347. _selection = _x select 0;
  348.  
  349. _dam = _x select 1;
  350.  
  351. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  352.  
  353. [_object,_selection,_dam] call object_setFixServer;
  354.  
  355. } forEach _hitpoints;
  356.  
  357. _object setvelocity [0,0,1];
  358.  
  359. _object setFuel _fuel;
  360.  
  361. _object call fnc_vehicleEventHandler;
  362.  
  363. };
  364.  
  365. //Monitor the object
  366.  
  367. //_object enableSimulation false;
  368.  
  369. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  370.  
  371. };
  372.  
  373. } forEach _myArray;
  374.  
  375.  
  376.  
  377. // # END OF STREAMING #
  378.  
  379. //Set the Time
  380.  
  381. //Send request
  382.  
  383. _key = "CHILD:307:";
  384.  
  385. _result = _key call server_hiveReadWrite;
  386.  
  387. _outcome = _result select 0;
  388.  
  389. if(_outcome == "PASS") then {
  390.  
  391. _date = _result select 1;
  392.  
  393. if(isDedicated) then {
  394.  
  395. //["dayzSetDate",_date] call broadcastRpcCallAll;
  396.  
  397. setDate _date;
  398.  
  399. dayzSetDate = _date;
  400.  
  401. publicVariable "dayzSetDate";
  402.  
  403. };
  404.  
  405. diag_log ("HIVE: Local Time set to " + str(_date));
  406.  
  407. };
  408.  
  409.  
  410.  
  411. createCenter civilian;
  412.  
  413. if (isDedicated) then {
  414.  
  415. endLoadingScreen;
  416.  
  417. };
  418.  
  419.  
  420.  
  421. if (isDedicated) then {
  422.  
  423. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  424.  
  425. };
  426.  
  427. call compile preprocessFileLineNumbers "\z\addons\dayz_server\DZAI\init\dzai_initserver.sqf";
  428.  
  429. allowConnection = true;
  430.  
  431. // [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
  432.  
  433. nul = [3, 4, (50 * 60), (15 * 60), 0.75, 'center', 4000, true, false] spawn server_spawnCrashSite;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement