Advertisement
Guest User

Untitled

a guest
Jul 10th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.24 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. // ####Copy START
  10. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - START
  11. call build_baseBuilding_arrays;
  12. // ### BASE BUILDING 1.2 ### SERVER SIDE BUILD ARRAYS - END
  13. // ####Copy END
  14. diag_log "HIVE: Starting";
  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. //Stream in objects
  26. /* STREAM OBJECTS */
  27. //Send the key
  28. _key = format["CHILD:302:%1:",dayZ_instance];
  29. _result = _key call server_hiveReadWrite;
  30. diag_log "HIVE: Request sent";
  31.  
  32. //Process result
  33. _status = _result select 0;
  34.  
  35. _myArray = [];
  36. if (_status == "ObjectStreamStart") then {
  37. _val = _result select 1;
  38. //Stream Objects
  39. diag_log ("HIVE: Commence Object Streaming...");
  40. for "_i" from 1 to _val do {
  41. _result = _key call server_hiveReadWrite;
  42. _status = _result select 0;
  43. _myArray set [count _myArray,_result];
  44. //diag_log ("HIVE: Loop ");
  45. };
  46. //diag_log ("HIVE: Streamed " + str(_val) + " objects");
  47. };
  48.  
  49. _countr = 0;
  50. {
  51.  
  52. //Parse Array
  53. _countr = _countr + 1;
  54.  
  55. _idKey = _x select 1;
  56. _type = _x select 2;
  57. _ownerID = _x select 3;
  58. _worldspace = _x select 4;
  59. _intentory= _x select 5;
  60. _hitPoints= _x select 6;
  61. _fuel = _x select 7;
  62. _damage = _x select 8;
  63. _dir = 0;
  64. _pos = [0,0,0];
  65. _wsDone = false;
  66. if (count _worldspace >= 2) then
  67. {
  68. _dir = _worldspace select 0;
  69. if (count (_worldspace select 1) == 3) then {
  70. _pos = _worldspace select 1;
  71. _wsDone = true;
  72. }
  73. };
  74. if (!_wsDone) then {
  75. if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
  76. _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  77. if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
  78. diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
  79. };
  80.  
  81. if (_damage < 1) then {
  82. diag_log format["OBJ: %1 - %2", _idKey,_type];
  83.  
  84. //Create it
  85. _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
  86. _object setVariable ["lastUpdate",time];
  87. if (_ownerID == "0") then {_object setVariable ["ObjectID", str(_idKey), true];} else {_object setVariable ["ObjectUID", str(_idKey),true];}; //_object setVariable ["ObjectID", _idKey, true];
  88. _object setVariable ["CharacterID", _ownerID, true];
  89.  
  90. clearWeaponCargoGlobal _object;
  91. clearMagazineCargoGlobal _object;
  92.  
  93. //## AIR VEHICLES
  94. //AN2 add M240
  95. if (_object isKindOf "AN2_DZ") then {
  96. _object addWeapon "M240_veh";
  97. _object addMagazine "100Rnd_762x51_M240";
  98. _object addMagazine "100Rnd_762x51_M240";
  99. };
  100.  
  101. //UH1Y remove weapons
  102. if (_object isKindOf "UH1Y") then {
  103. _object removeWeapon "M134";
  104. _object removeWeapon "FFARLauncher_14";
  105. _object addWeapon "M240_veh";
  106. _object addMagazine "100Rnd_762x51_M240";
  107. _object addWeapon "M240_veh";
  108. _object addMagazine "100Rnd_762x51_M240";
  109. _object removeMagazine "2000Rnd_762x51_M134";
  110. _object removeMagazine "4000Rnd_762x51_M134";
  111. _object removeMagazine "14Rnd_FFAR";
  112. _object removeMagazine "14Rnd_FFAR";
  113. };
  114.  
  115. //A10 add bombs
  116. if (_object isKindOf "A10") then {
  117. _object addWeapon "HeliBombLauncher";
  118. _object addMagazine "2Rnd_FAB_250";
  119. };
  120.  
  121. //## LAND VEHICLES
  122. //T90 remove weapons add M240
  123. if (_object isKindOf "T90") then {
  124. _object addWeapon "M240_veh";
  125. _object addMagazine "100Rnd_762x51_M240";
  126. _object addMagazine "100Rnd_762x51_M240";
  127. };
  128.  
  129. //BTR90_HQ remove weapons
  130. if (_object isKindOf "BTR90_HQ") then {
  131. _object addWeapon "TruckHorn";
  132. _object removeWeapon "PKT";
  133. _object removeMagazine "100Rnd_762x54_PK";
  134. _object removeMagazine "100Rnd_762x54_PK";
  135. _object removeMagazine "100Rnd_762x54_PK";
  136. _object removeMagazine "100Rnd_762x54_PK";
  137. };
  138.  
  139. if (_object isKindOf "TentStorage") then {
  140. _pos set [2,0];
  141. _object setpos _pos;
  142. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  143. };
  144. _object setdir _dir;
  145. _object setDamage _damage;
  146. // ####Copy START
  147. // ##### BASE BUILDING 1.2 Server Side ##### - START
  148. // This sets objects to appear properly once server restarts
  149. //the following is happening on every server restart
  150. _code = _fuel * 1000; //it is necessary cause we get only the converted fuel variable from the database, so we got to calculate back to code format
  151. _object setVariable ["Code", _code,true]; //set Code to the Object
  152. _object setVariable ["Classname", _type,true]; //set Classname to the Object
  153. _object setVariable ["ObjectID", _idKey,true]; //set ObjectID to the Object
  154. _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true]; //set ObjectUID to the Object
  155. if ((_object isKindOf "Static") && !(_object isKindOf "TentStorage")) then {
  156. _object setpos [(getposATL _object select 0),(getposATL _object select 1), 0];
  157. };
  158. //Set Variable
  159. if (_object isKindOf "Infostand_2_EP1" && !(_object isKindOf "Infostand_1_EP1")) then {
  160. _object setVariable ["Code", _code, true]; //changed to _code instead of _worldspace call dayz_objectUID2
  161. };
  162.  
  163.  
  164. // Set whether or not buildable is destructable
  165. if (typeOf(_object) in allbuildables_class) then {
  166. diag_log ("SERVER: in allbuildables_class:" + typeOf(_object) + " !");
  167. for "_i" from 0 to ((count allbuildables) - 1) do
  168. {
  169. _classname = (allbuildables select _i) select _i - _i + 1;
  170. _result = [_classname,typeOf(_object)] call BIS_fnc_areEqual;
  171. if (_result) then {
  172. _requirements = (allbuildables select _i) select _i - _i + 2;
  173.  
  174. _isDestructable = _requirements select 13;
  175. diag_log ("SERVER: " + typeOf(_object) + " _isDestructable = " + str(_isDestructable));
  176. if (!_isDestructable) then {
  177. diag_log("Spawned: " + typeOf(_object) + " Handle Damage False");
  178. _object addEventHandler ["HandleDamage", {false}];
  179. };
  180. };
  181. };
  182. //gateKeypad = _object addaction ["Defuse", "\z\addons\dayz_server\compile\enterCode.sqf"];
  183. };
  184. // ##### BASE BUILDING 1.2 Server Side ##### - END
  185. // This sets objects to appear properly once server restarts
  186. // ###COPY END
  187.  
  188. if (count _intentory > 0) then {
  189. //Add weapons
  190. _objWpnTypes = (_intentory select 0) select 0;
  191. _objWpnQty = (_intentory select 0) select 1;
  192. _countr = 0;
  193. {
  194. if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
  195. _isOK = isClass(configFile >> "CfgWeapons" >> _x);
  196. if (_isOK) then {
  197. _block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
  198. if (!_block) then {
  199. _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
  200. };
  201. };
  202. _countr = _countr + 1;
  203. } forEach _objWpnTypes;
  204.  
  205. //Add Magazines
  206. _objWpnTypes = (_intentory select 1) select 0;
  207. _objWpnQty = (_intentory select 1) select 1;
  208. _countr = 0;
  209. {
  210. if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
  211. _isOK = isClass(configFile >> "CfgMagazines" >> _x);
  212. if (_isOK) then {
  213. _block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
  214. if (!_block) then {
  215. _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
  216. };
  217. };
  218. _countr = _countr + 1;
  219. } forEach _objWpnTypes;
  220. //Add Backpacks
  221. _objWpnTypes = (_intentory select 2) select 0;
  222. _objWpnQty = (_intentory select 2) select 1;
  223. _countr = 0;
  224. {
  225. _isOK = isClass(configFile >> "CfgVehicles" >> _x);
  226. if (_isOK) then {
  227. _block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
  228. if (!_block) then {
  229. _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
  230. };
  231. };
  232. _countr = _countr + 1;
  233. } forEach _objWpnTypes;
  234. };
  235.  
  236. if (_object isKindOf "AllVehicles") then {
  237. {
  238. _selection = _x select 0;
  239. _dam = _x select 1;
  240. if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
  241. [_object,_selection,_dam] call object_setFixServer;
  242. } forEach _hitpoints;
  243. _object setvelocity [0,0,1];
  244. _object setFuel _fuel;
  245. _object call fnc_vehicleEventHandler;
  246. };
  247. //Monitor the object
  248. //_object enableSimulation false;
  249. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
  250. };
  251. } forEach _myArray;
  252.  
  253. // # END OF STREAMING #
  254. //Send the key
  255. _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];
  256. _data = "HiveEXT" callExtension _key;
  257. diag_log("SERVER: Fetching buildings...");
  258. //Process result
  259. _result = call compile format ["%1", _data];
  260. _status = _result select 0;
  261. _bldList = [];
  262. _bldCount = 0;
  263. if (_status == "CustomStreamStart") then {
  264. _val = _result select 1;
  265. for "_i" from 1 to _val do {
  266. _data = "HiveEXT" callExtension _key;
  267. _result = call compile format ["%1",_data];
  268. _pos = call compile (_result select 1);
  269. _dir = _pos select 0;
  270. _pos = _pos select 1;
  271. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  272. _building setDir _dir;
  273. _bldCount = _bldCount + 1;
  274. };
  275. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  276. };
  277. //Send the key
  278. _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];
  279. _data = "HiveEXT" callExtension _key;
  280. diag_log("SERVER: Fetching buildings...");
  281. //Process result
  282. _result = call compile format ["%1", _data];
  283. _status = _result select 0;
  284. _bldList = [];
  285. _bldCount = 0;
  286. if (_status == "CustomStreamStart") then {
  287. _val = _result select 1;
  288. for "_i" from 1 to _val do {
  289. _data = "HiveEXT" callExtension _key;
  290. _result = call compile format ["%1",_data];
  291. _pos = call compile (_result select 1);
  292. _dir = _pos select 0;
  293. _pos = _pos select 1;
  294. _building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
  295. _building setDir _dir;
  296. _bldCount = _bldCount + 1;
  297. };
  298. diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
  299. };
  300. //Set the Time
  301. //Send request
  302. _key = "CHILD:307:";
  303. _result = _key call server_hiveReadWrite;
  304. _outcome = _result select 0;
  305. if(_outcome == "PASS") then {
  306. _date = [2012,8,31,(_result select 1) select 3, (_result select 1) select 4];
  307. if(isDedicated) then {
  308. //["dayzSetDate",_date] call broadcastRpcCallAll;
  309. setDate _date;
  310. dayzSetDate = _date;
  311. publicVariable "dayzSetDate";
  312. };
  313. diag_log ("HIVE: Local Time set to " + str(_date));
  314. };
  315.  
  316. createCenter civilian;
  317. if (isDedicated) then {
  318. endLoadingScreen;
  319. };
  320.  
  321. if (isDedicated) then {
  322. _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
  323. };
  324. allowConnection = true;
  325. // [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, _useStatic, _preWaypoint, _crashDamage]
  326. nul = [
  327. 10, //Number of the guaranteed Loot-Piles at the Crashside
  328. 4, //Number of the random Loot-Piles at the Crashside 3+(1,2,3 or 4)
  329. 1800, //Fixed-Time (in seconds) between each start of a new Chopper
  330. 1200, //Random time (in seconds) added between each start of a new Chopper
  331. 0.5, //Spawnchance of the Heli (1 will spawn all possible Choppers, 0.5 only 50% of them)
  332. 'center', //Center-Marker for the Random-Crashpoints, for Chernarus this is a point near Stary
  333. 5500, //Radius in Meters from the Center-Marker in which the Choppers can crash and get waypoints
  334. true, //Should the spawned crashsite burn (at night) & have smoke?
  335. false, //Should the flames & smoke fade after a while?
  336. false, //Use the Static-Crashpoint-Function? If true, you have to add Coordinates into server_spawnCrashSite.sqf
  337. 1, //Amount of Random-Waypoints the Heli gets before he flys to his Point-Of-Crash (using Static-Crashpoint-Coordinates if its enabled)
  338. 0.0001 //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)
  339. ] spawn server_spawnCrashSite;
  340. for "_x" from 1 to 6 do {
  341. _id = [] spawn spawn_carePackages;
  342. }; //Spawn care packages
  343. for "_x" from 1 to 20 do {
  344. _id = [] spawn spawn_wrecks;
  345. }; //Spawn wrecks
  346. execVM "\z\addons\dayz_server\system\tsw.sqf";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement