Advertisement
Guest User

Untitled

a guest
May 23rd, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.58 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. _object setFuel _fuel 1;
  181. _object setVelocity [0,0,1];
  182. };
  183.  
  184. //Monitor the object
  185. //_object enableSimulation false;
  186. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  187. };
  188. } forEach _myArray;
  189.  
  190. // # END OF STREAMING #
  191.  
  192. // Spawn Buildings
  193. //Send the key
  194. _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];
  195. _data = "HiveEXT" callExtension _key;
  196. diag_log("SERVER: Fetching buildings...");
  197.  
  198. //Process result
  199. _result = call compile format ["%1", _data];
  200. _status = _result select 0;
  201.  
  202. _bldList = [];
  203. _bldCount = 0;
  204. if (_status == "CustomStreamStart") then {
  205. _val = _result select 1;
  206. for "_i" from 1 to _val do {
  207. _data = "HiveEXT" callExtension _key;
  208. _result = call compile format ["%1",_data];
  209.  
  210. _pos = call compile (_result select 1);
  211. _dir = _pos select 0;
  212. _pos = _pos select 1;
  213.  
  214. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  215. _building setDir _dir;
  216. _bldCount = _bldCount + 1;
  217. };
  218. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  219. };
  220.  
  221. //Set the Time
  222. //Send request
  223. _key = "CHILD:307:";
  224. _result = _key call server_hiveReadWrite;
  225. _outcome = _result select 0;
  226. if(_outcome == "PASS") then {
  227. _date = [2012,8,31,(_result select 1) select 3, (_result select 1) select 4];
  228. if(isDedicated) then {
  229. //["dayzSetDate",_date] call broadcastRpcCallAll;
  230. setDate _date;
  231. dayzSetDate = _date;
  232. publicVariable "dayzSetDate";
  233. };
  234.  
  235. diag_log ("HIVE: Local Time set to " + str(_date));
  236. };
  237.  
  238. createCenter civilian;
  239. if (isDedicated) then {
  240. endLoadingScreen;
  241. };
  242.  
  243. if (isDedicated) then {
  244. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  245. };
  246.  
  247. allowConnection = true;
  248.  
  249. // [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, _useStatic, _preWaypoint, _crashDamage]
  250. nul = [
  251. 7, //Number of the guaranteed Loot-Piles at the Crashside
  252. 14, //Number of the random Loot-Piles at the Crashside 3+(1,2,3 or 4)
  253. 300, //Fixed-Time (in seconds) between each start of a new Chopper
  254. 50, //Random time (in seconds) added between each start of a new Chopper
  255. 1, //Spawnchance of the Heli (1 will spawn all possible Choppers, 0.5 only 50% of them)
  256. 'center', //Center-Marker for the Random-Crashpoints, for Chernarus this is a point near Stary
  257. 6000, //Radius in Meters from the Center-Marker in which the Choppers can crash and get waypoints
  258. true, //Should the spawned crashsite burn (at night) & have smoke?
  259. false, //Should the flames & smoke fade after a while?
  260. false, //Use the Static-Crashpoint-Function? If true, you have to add Coordinates into server_spawnCrashSite.sqf
  261. 5, //Amount of Random-Waypoints the Heli gets before he flys to his Point-Of-Crash (using Static-Crashpoint-Coordinates if its enabled)
  262. 0.0002 //Amount of Damage the Heli has to get while in-air to explode before the POC. (0.0001 = Insta-Explode when any damage//bullethit, 1 = Only Explode when completly damaged)
  263. ] spawn server_spawnCrashSite;
  264. // [_guaranteedLoot, _randomizedLoot, _frequency, _variance(DONOTUSE), _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, waypoints, damage]
  265. nul = [7, 5, 300, 0, 0.99, 'center', 4000, true, false, true, 5, 1]spawn server_spawnC130CrashSite;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement