Advertisement
Guest User

JAEM

a guest
Jan 30th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.09 KB | None | 0 0
  1. private ["_date","_year","_month","_day","_hour","_minute","_date1","_key","_objectCount","_dir","_point","_i","_action","_dam","_selection","_wantExplosiveParts","_entity","_worldspace","_damage","_booleans","_rawData","_ObjectID","_class","_CharacterID","_inventory","_hitpoints","_fuel","_id","_objectArray","_script","_result","_outcome","_shutdown","_res"];
  2. [] execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
  3. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  4.  
  5. //ORIGINS need to happen early
  6. [] ExecVM "\z\addons\dayz_server\origins\variables.sqf";
  7.  
  8. waitUntil {!isNil "BIS_MPF_InitDone" && initialized};
  9. if (!isNil "sm_done") exitWith {}; // prevent server_monitor be called twice (bug during login of the first player)
  10. sm_done = false;
  11.  
  12. _legacyStreamingMethod = false; //use old object streaming method, more secure but will be slower and subject to the callExtension return size limitation.
  13.  
  14. dayz_serverIDMonitor = [];
  15. _DZE_VehObjects = [];
  16. PVDZE_EvacChopperFields = [];
  17. dayz_versionNo = getText (configFile >> "CfgMods" >> "DayZ" >> "version");
  18. dayz_hiveVersionNo = getNumber (configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  19. _hiveLoaded = false;
  20. _serverVehicleCounter = [];
  21. _tempMaint = DayZ_WoodenFence + DayZ_WoodenGates;
  22. diag_log "HIVE: Starting";
  23.  
  24. //Set the Time
  25. _key = "CHILD:307:";
  26. _result = _key call server_hiveReadWrite;
  27. _outcome = _result select 0;
  28. if (_outcome == "PASS") then {
  29. _date = _result select 1;
  30. _year = _date select 0;
  31. _month = _date select 1;
  32. _day = _date select 2;
  33. _hour = _date select 3;
  34. _minute = _date select 4;
  35.  
  36. if (dayz_ForcefullmoonNights) then {_date = [2012,8,2,_hour,_minute];};
  37. diag_log ["TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights,"Date given by HiveExt.dll:",_result select 1];
  38. setDate _date;
  39. dayzSetDate = _date;
  40. publicVariable "dayzSetDate";
  41. };
  42.  
  43. //Stream in objects
  44. /* STREAM OBJECTS */
  45. //Send the key
  46. _timeStart = diag_tickTime;
  47.  
  48. for "_i" from 1 to 5 do {
  49. diag_log "HIVE: trying to get objects";
  50. _key = format["CHILD:302:%1:%2:",dayZ_instance, _legacyStreamingMethod];
  51. _result = _key call server_hiveReadWrite;
  52. if (typeName _result == "STRING") then {
  53. _shutdown = format["CHILD:400:%1:",(profileNamespace getVariable "SUPERKEY")];
  54. _res = _shutdown call server_hiveReadWrite;
  55. diag_log ("HIVE: attempt to kill.. HiveExt response:"+str(_res));
  56. } else {
  57. diag_log ("HIVE: found "+str(_result select 1)+" objects" );
  58. _i = 99; // break
  59. };
  60. };
  61. //Define arrays
  62. owner_B1 = [];
  63. owner_B2 = [];
  64. owner_B3 = [];
  65. owner_H1 = [];
  66. owner_H2 = [];
  67. owner_H3 = [];
  68. owner_SG = [];
  69. owner_LG = [];
  70. owner_KING = [];
  71. owner_SH = [];
  72. if (typeName _result == "STRING") exitWith {
  73. diag_log "HIVE: Connection error. Server_monitor.sqf is exiting.";
  74. };
  75.  
  76. diag_log "HIVE: Request sent";
  77. _myArray = [];
  78. _val = 0;
  79. _status = _result select 0; //Process result
  80. _val = _result select 1;
  81. if (_legacyStreamingMethod) then {
  82. if (_status == "ObjectStreamStart") then {
  83. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  84. _hiveLoaded = true;
  85. //Stream Objects
  86. diag_log ("HIVE: Commence Object Streaming...");
  87. for "_i" from 1 to _val do {
  88. _isOrigins = false;
  89. _result = _key call server_hiveReadWriteLarge;
  90. _status = _result select 0;
  91. _myArray set [count _myArray,_result];
  92. };
  93. };
  94. } else {
  95. if (_val > 0) then {
  96. _fileName = _key call server_hiveReadWrite;
  97. _lastFN = profileNamespace getVariable["lastFN",""];
  98. profileNamespace setVariable["lastFN",_fileName];
  99. saveProfileNamespace;
  100. if (_status == "ObjectStreamStart") then {
  101. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  102. _hiveLoaded = true;
  103. _myArray = Call Compile PreProcessFile _fileName;
  104. _key = format["CHILD:302:%1:%2:",_lastFN, _legacyStreamingMethod];
  105. _result = _key call server_hiveReadWrite; //deletes previous object data dump
  106. };
  107. } else {
  108. if (_status == "ObjectStreamStart") then {
  109. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  110. _hiveLoaded = true;
  111. };
  112. };
  113. };
  114.  
  115. diag_log ("HIVE: Streamed " + str(_val) + " objects");
  116.  
  117. // Don't spawn objects if no clients are online (createVehicle fails with Ref to nonnetwork object)
  118. if ((playersNumber west + playersNumber civilian) == 0) exitWith {
  119. diag_log "All clients disconnected. Server_monitor.sqf is exiting.";
  120. };
  121.  
  122. {
  123. private ["_object","_posATL"];
  124. //Parse Array
  125. _action = _x select 0;
  126. _idKey = _x select 1;
  127. _type = _x select 2;
  128. _ownerID = _x select 3;
  129. _worldspace = _x select 4;
  130. _inventory = _x select 5;
  131. _hitPoints = _x select 6;
  132. _fuel = _x select 7;
  133. _damage = _x select 8;
  134. _storageMoney = _x select 9;
  135.  
  136. //set object to be in maintenance mode
  137. _maintenanceMode = false;
  138. _maintenanceModeVars = [];
  139.  
  140. _dir = 90;
  141. _pos = [0,0,0];
  142. _wsDone = false;
  143. _wsCount = count _worldspace;
  144.  
  145. //Vector building
  146. _vector = [[0,0,0],[0,0,0]];
  147. _vecExists = false;
  148. _ownerPUID = "0";
  149.  
  150. if (_wsCount >= 2) then {
  151. _dir = _worldspace select 0;
  152. _posATL = _worldspace select 1;
  153. if (count _posATL == 3) then {
  154. _pos = _posATL;
  155. _wsDone = true;
  156. };
  157. if (_wsCount >= 3) then{
  158. _ws2TN = typename (_worldspace select 2);
  159. _ws3TN = typename (_worldspace select 3);
  160. if (_wsCount == 3) then{
  161. if (_ws2TN == "STRING") then{
  162. _ownerPUID = _worldspace select 2;
  163. } else {
  164. if (_ws2TN == "ARRAY") then{
  165. _vector = _worldspace select 2;
  166. _vecExists = true;
  167. };
  168. };
  169. } else {
  170. if (_wsCount == 4) then{
  171. if (_ws3TN == "STRING") then{
  172. _ownerPUID = _worldspace select 3;
  173. } else {
  174. if (_ws2TN == "STRING") then{
  175. _ownerPUID = _worldspace select 2;
  176. };
  177. };
  178. if (_ws2TN == "ARRAY") then{
  179. _vector = _worldspace select 2;
  180. _vecExists = true;
  181. } else {
  182. if (_ws3TN == "ARRAY") then{
  183. _vector = _worldspace select 3;
  184. _vecExists = true;
  185. };
  186. };
  187. };
  188. };
  189. } else {
  190. _worldspace set [count _worldspace, "0"];
  191. };
  192. };
  193.  
  194. if (!_wsDone) then {
  195. if ((count _posATL) >= 2) then {
  196. _pos = [_posATL select 0,_posATL select 1,0];
  197. diag_log format["MOVED OBJ: %1 of class %2 with worldspace array = %3 to pos: %4",_idKey,_type,_worldspace,_pos];
  198. } else {
  199. diag_log format["MOVED OBJ: %1 of class %2 with worldspace array = %3 to pos: [0,0,0]",_idKey,_type,_worldspace];
  200. };
  201. };
  202.  
  203. //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
  204. /*
  205. if (_type in _tempMaint) then {
  206. //Use hitpoints for Maintenance system and other systems later.
  207. //Enable model swap for a damaged model.
  208. if ("Maintenance" in _hitPoints) then {
  209. _maintenanceModeVars = [_type,_pos];
  210. _type = _type + "_Damaged";
  211. };
  212. //TODO add remove object and readd old fence (hideobject would be nice to use here :-( )
  213. //Pending change to new fence models\Layout
  214. };
  215. */
  216. _nonCollide = _type in DayZ_nonCollide;
  217. //Create it
  218. if (_nonCollide) then {
  219. _object = createVehicle [_type, [0,0,0], [], 0, "NONE"];
  220. } else {
  221. _object = _type createVehicle [0,0,0]; //more than 2x faster than createvehicle array
  222. };
  223. _object setDir _dir;
  224. _object setPosATL _pos;
  225. _object setDamage _damage;
  226. if (_vecExists) then {
  227. _object setVectorDirAndUp _vector;
  228. };
  229. _object enableSimulation false;
  230.  
  231. _doorLocked = _type in DZE_DoorsLocked;
  232. _isPlot = _type == "Plastic_Pole_EP1_DZ";
  233.  
  234. // prevent immediate hive write when vehicle parts are set up
  235. _object setVariable ["lastUpdate",diag_ticktime];
  236. _object setVariable ["ObjectID", _idKey, true];
  237. _object setVariable ["OwnerPUID", _ownerPUID, true];
  238. if (Z_SingleCurrency && {(_type in DZE_MoneyStorageClasses) || (_object isKindOf "AllVehicles")}) then {
  239. _object setVariable [Z_MoneyVariable, _storageMoney, true];
  240. };
  241.  
  242. dayz_serverIDMonitor set [count dayz_serverIDMonitor,_idKey];
  243.  
  244. if (!_wsDone) then {[_object,"position",true] call server_updateObject;};
  245. if (_type == "Base_Fire_DZ") then {_object spawn base_fireMonitor;};
  246.  
  247. _isDZ_Buildable = _object isKindOf "DZ_buildables";
  248. _isTrapItem = _object isKindOf "TrapItems";
  249. _isSafeObject = _type in DayZ_SafeObjects;
  250.  
  251. //Dont add inventory for traps.
  252. if (!_isDZ_Buildable && !_isTrapItem) then {
  253. clearWeaponCargoGlobal _object;
  254. clearMagazineCargoGlobal _object;
  255. clearBackpackCargoGlobal _object;
  256. if( (count _inventory > 0) && !_isPlot && !_doorLocked) then {
  257. if (_type in DZE_LockedStorage || _type in DZE_Origins_Buildings) then {
  258. // Do not send big arrays over network! Only server needs these
  259. _object setVariable ["WeaponCargo",(_inventory select 0),false];
  260. _object setVariable ["MagazineCargo",(_inventory select 1),false];
  261. _object setVariable ["BackpackCargo",(_inventory select 2),false];
  262. } else {
  263. _weaponcargo = _inventory select 0 select 0;
  264. _magcargo = _inventory select 1 select 0;
  265. _backpackcargo = _inventory select 2 select 0;
  266. _weaponqty = _inventory select 0 select 1;
  267. {_object addWeaponCargoGlobal [_x, _weaponqty select _foreachindex];} foreach _weaponcargo;
  268.  
  269. _magqty = _inventory select 1 select 1;
  270. {_object addMagazineCargoGlobal [_x, _magqty select _foreachindex];} foreach _magcargo;
  271.  
  272. _backpackqty = _inventory select 2 select 1;
  273. {_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
  274. };
  275. } else {
  276. if (DZE_permanentPlot && _isPlot) then {
  277. _object setVariable ["plotfriends", _inventory, true];
  278. };
  279. if (DZE_doorManagement && _doorLocked) then {
  280. _object setVariable ["doorfriends", _inventory, true];
  281. };
  282. };
  283. };
  284.  
  285. if (_object isKindOf "AllVehicles") then {
  286. _object setVariable ["CharacterID", _ownerID, true];
  287. if ((typeOf _object) == "HeliHRescue") then {
  288. PVDZE_EvacChopperFields set [count PVDZE_EvacChopperFields, _object];
  289. };
  290. _isAir = _object isKindOf "Air";
  291. {
  292. _selection = _x select 0;
  293. _dam = if (!_isAir && {_selection in dayZ_explosiveParts}) then {(_x select 1) min 0.8;} else {_x select 1;};
  294. _strH = "hit_" + (_selection);
  295. _object setHit[_selection,_dam];
  296. _object setVariable [_strH,_dam,true];
  297. } foreach _hitpoints;
  298. [_object,"damage"] call server_updateObject;
  299.  
  300. _object setFuel _fuel;
  301. if (!_isSafeObject) then {
  302. _DZE_VehObjects set [count _DZE_VehObjects,_object];
  303. _object call fnc_veh_ResetEH;
  304. if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";};
  305. _serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
  306. } else {
  307. _object enableSimulation true;
  308. };
  309. } else {
  310. // Fix for leading zero issues on safe codes after restart
  311. _lockable = getNumber (configFile >> "CfgVehicles" >> _type >> "lockable");
  312. _codeCount = count (toArray _ownerID);
  313. switch (_lockable) do {
  314. case 4: {
  315. switch (_codeCount) do {
  316. case 3: {_ownerID = format["0%1",_ownerID];};
  317. case 2: {_ownerID = format["00%1",_ownerID];};
  318. case 1: {_ownerID = format["000%1",_ownerID];};
  319. };
  320. };
  321. case 3: {
  322. switch (_codeCount) do {
  323. case 2: {_ownerID = format["0%1",_ownerID];};
  324. case 1: {_ownerID = format["00%1",_ownerID];};
  325. };
  326. };
  327. };
  328. _object setVariable ["CharacterID", _ownerID, true];
  329. if (_isDZ_Buildable || {(_isSafeObject && !_isTrapItem)}) then {
  330. _object setVariable["memDir",_dir,true];
  331. if (DZE_GodModeBase && {!(_type in DZE_GodModeBaseExclude)}) then {
  332. _object addEventHandler ["HandleDamage",{false}];
  333. } else {
  334. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  335. };
  336. _object setVariable ["OEMPos",_pos,true]; // used for inplace upgrades and lock/unlock of safe
  337. } else {
  338. _object enableSimulation true;
  339. };
  340. if (_isDZ_Buildable || {_isTrapItem}) then {
  341. //Use inventory for owner/clan info and traps armed state
  342. {
  343. _xTypeName = typeName _x;
  344. switch (_xTypeName) do {
  345. case "ARRAY": {
  346. _x1 = _x select 1;
  347. switch (_x select 0) do {
  348. case "ownerArray" : { _object setVariable ["ownerArray", _x1, true]; };
  349. case "clanArray" : { _object setVariable ["clanArray", _x1, true]; };
  350. case "armed" : { _object setVariable ["armed", _x1, true]; };
  351. case "padlockCombination" : { _object setVariable ["dayz_padlockCombination", _x1, false]; };
  352. case "BuildLock" : { _object setVariable ["BuildLock", _x1, true]; };
  353. };
  354. };
  355. case "STRING": {_object setVariable ["ownerArray", [_x], true]; };
  356. case "BOOLEAN": {_object setVariable ["armed", _x, true]};
  357. };
  358. } foreach _inventory;
  359.  
  360. if (_maintenanceMode) then {
  361. _object setVariable ["Maintenance", true, true];
  362. _object setVariable ["MaintenanceVars", _maintenanceModeVars];
  363. };
  364. };
  365. };
  366. if(_type in DZE_Origins_Buildings) then {
  367. //origins get owner UID from worldspace
  368. _originowner = _worldspace select 4;
  369. diag_log format["Origins Object: %1 - %2", _type,_originowner];
  370. _object setVariable ["CanBeUpdated",false, true];
  371. {
  372.  
  373. _object setVariable ["OwnerUID",_originowner, true];
  374. _object setVariable ["OwnerName",(_x select 1), true];
  375. } count _hitPoints;
  376. _ownerUID = _object getVariable ["OwnerUID","0"];
  377. switch(_type) do {
  378. case "Uroven1DrevenaBudka" : { owner_B1 set [count owner_B1, _ownerUID];};
  379. case "Uroven2KladaDomek" : { owner_B2 set [count owner_B2, _ownerUID];};
  380. case "Uroven3DrevenyDomek" : { owner_B3 set [count owner_B3, _ownerUID];};
  381. case "Uroven1VelkaBudka" : { owner_H1 set [count owner_H1, _ownerUID];};
  382. case "Uroven2MalyDomek" : { owner_H2 set [count owner_H2, _ownerUID];};
  383. case "Uroven3VelkyDomek" : { owner_H3 set [count owner_H3, _ownerUID];};
  384. case "malaGaraz" : { owner_SG set [count owner_SG, _ownerUID];};
  385. case "velkaGaraz" : { owner_LG set [count owner_LG, _ownerUID];};
  386. case "kingramida" : { owner_KING set [count owner_KING, _ownerUID];};
  387. case "krepost" : { owner_SH set [count owner_SH, _ownerUID];};
  388. };
  389. if((_pos select 2) < 0.25) then {
  390. _object setVectorUp surfaceNormal position _object;
  391. };
  392. _object setVectorUp surfaceNormal position _object;
  393. };
  394. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object]; //Monitor the object
  395. } forEach _myArray;
  396.  
  397. //enable simulation on vehicles after all buildables are spawned
  398. {
  399. _x enableSimulation true;
  400. _x setVelocity [0,0,1];
  401. } forEach _DZE_VehObjects;
  402.  
  403. diag_log format["HIVE: BENCHMARK - Server_monitor.sqf finished streaming %1 objects in %2 seconds (unscheduled)",_val,diag_tickTime - _timeStart];
  404.  
  405. // # END OF STREAMING #
  406. if (dayz_townGenerator) then {
  407. call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_plantSpawner.sqf"; // Draw the pseudo random seeds
  408. };
  409. #ifndef OBJECT_DEBUG
  410. object_debug = false;
  411. #else
  412. object_debug = true;
  413. #endif
  414. [] execFSM "\z\addons\dayz_server\system\server_vehicleSync.fsm";
  415. [] execVM "\z\addons\dayz_server\system\scheduler\sched_init.sqf"; // launch the new task scheduler
  416.  
  417. createCenter civilian;
  418.  
  419. actualSpawnMarkerCount = 0;
  420. // count valid spawn markers, since different maps have different amounts
  421. for "_i" from 0 to 10 do {
  422. if ((getMarkerPos format["spawn%1",_i]) distance [0,0,0] > 0) then {
  423. actualSpawnMarkerCount = actualSpawnMarkerCount + 1;
  424. } else {
  425. _i = 11; // exit since we did not find any further markers
  426. };
  427. };
  428. diag_log format["Total Number of spawn locations %1", actualSpawnMarkerCount];
  429.  
  430. if (isDedicated) then {endLoadingScreen;};
  431. [] call compile preprocessFileLineNumbers "\z\addons\dayz_server\DZAI\init\dzai_initserver.sqf";
  432. [] ExecVM "\z\addons\dayz_server\WAI\init.sqf";
  433. [] ExecVM "\z\addons\dayz_server\DZMS\DZMSInit.sqf";
  434. allowConnection = true;
  435. sm_done = true;
  436. publicVariable "sm_done";
  437.  
  438. if (isServer && (isNil "EvacServerPreload")) then {
  439. publicVariable "PVDZE_EvacChopperFields";
  440.  
  441. ON_fnc_evacChopperFieldsUpdate = {
  442. private ["_action","_targetField"];
  443. _action = _this select 0;
  444. _targetField = _this select 1;
  445.  
  446. if (_action == "add") then {
  447. PVDZE_EvacChopperFields = PVDZE_EvacChopperFields + [_targetField];
  448. };
  449.  
  450. if (_action == "rem") then {
  451. PVDZE_EvacChopperFields = PVDZE_EvacChopperFields - [_targetField];
  452. };
  453.  
  454. publicVariable "PVDZE_EvacChopperFields";
  455. };
  456.  
  457. "PVDZE_EvacChopperFieldsUpdate" addPublicVariableEventHandler {(_this select 1) spawn ON_fnc_evacChopperFieldsUpdate};
  458.  
  459. EvacServerPreload = true;
  460. };
  461.  
  462. // Trap loop
  463. [] spawn {
  464. private ["_array","_array2","_array3","_script","_armed"];
  465. _array = str dayz_traps;
  466. _array2 = str dayz_traps_active;
  467. _array3 = str dayz_traps_trigger;
  468.  
  469. while {1 == 1} do {
  470. if ((str dayz_traps != _array) || (str dayz_traps_active != _array2) || (str dayz_traps_trigger != _array3)) then {
  471. _array = str dayz_traps;
  472. _array2 = str dayz_traps_active;
  473. _array3 = str dayz_traps_trigger;
  474. //diag_log "DEBUG: traps";
  475. //diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps];
  476. //diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active];
  477. //diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger];
  478. //diag_log "DEBUG: end traps";
  479. };
  480.  
  481. {
  482. if (isNull _x) then {
  483. dayz_traps = dayz_traps - [_x];
  484. _armed = false;
  485. _script = {};
  486. } else {
  487. _armed = _x getVariable ["armed", false];
  488. _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
  489. };
  490.  
  491. if (_armed) then {
  492. if !(_x in dayz_traps_active) then {["arm", _x] call _script;};
  493. } else {
  494. if (_x in dayz_traps_active) then {["disarm", _x] call _script;};
  495. };
  496. uiSleep 0.01;
  497. } forEach dayz_traps;
  498. uiSleep 1;
  499. };
  500. };
  501.  
  502. //Points of interest
  503. //[] execVM "\z\addons\dayz_server\compile\server_spawnInfectedCamps.sqf"; //Adds random spawned camps in the woods with corpses and loot tents (negatively impacts FPS)
  504. [] execVM "\z\addons\dayz_server\compile\server_spawnCarePackages.sqf";
  505. [] execVM "\z\addons\dayz_server\compile\server_spawnCrashSites.sqf";
  506.  
  507. if (dayz_townGenerator) then {execVM "\z\addons\dayz_server\system\lit_fireplaces.sqf";};
  508.  
  509. "PVDZ_sec_atp" addPublicVariableEventHandler {
  510. _x = _this select 1;
  511. switch (1==1) do {
  512. case (typeName _x == "STRING") : { // just some logs from the client
  513. diag_log _x;
  514. };
  515. case (count _x == 2) : { // wrong side
  516. diag_log format["P1ayer %1 reports possible 'side' hack. Server may be compromised!",(_x select 1) call fa_plr2Str];
  517. };
  518. default { // player hit
  519. _unit = _x select 0;
  520. _source = _x select 1;
  521. if (!isNull _source) then {
  522. diag_log format ["P1ayer %1 hit by %2 %3 from %4 meters in %5 for %6 damage",
  523. _unit call fa_plr2Str, if (!isPlayer _source && alive _source) then {"AI"} else {_source call fa_plr2Str}, _x select 2, _x select 3, _x select 4, _x select 5];
  524. };
  525. };
  526. };
  527. };
  528.  
  529. "PVDZ_objgather_Knockdown" addPublicVariableEventHandler {
  530. _tree = (_this select 1) select 0;
  531. _player = (_this select 1) select 1;
  532. _dis = _player distance _tree;
  533. _name = if (alive _player) then {name _player} else {"DeadPlayer"};
  534. _uid = getPlayerUID _player;
  535. _treeModel = _tree call fn_getModelName;
  536.  
  537. if (_dis < 30 && (_treeModel in dayz_trees or (_treeModel in dayz_plant)) && (_uid != "")) then {
  538. _tree setDamage 1;
  539. dayz_choppedTrees set [count dayz_choppedTrees,_tree];
  540. diag_log format["Server setDamage on tree or plant %1 chopped down by %2(%3)",_treeModel,_name,_uid];
  541. };
  542. };
  543.  
  544. // preload server traders menu data into cache
  545. if !(DZE_ConfigTrader) then {
  546. {
  547. // get tids
  548. _traderData = call compile format["menu_%1;",_x];
  549. if (!isNil "_traderData") then {
  550. {
  551. _traderid = _x select 1;
  552. _retrader = [];
  553.  
  554. _key = format["CHILD:399:%1:",_traderid];
  555. _data = "HiveEXT" callExtension _key;
  556. _result = call compile format["%1",_data];
  557. _status = _result select 0;
  558.  
  559. if (_status == "ObjectStreamStart") then {
  560. _val = _result select 1;
  561. call compile format["ServerTcache_%1 = [];",_traderid];
  562. for "_i" from 1 to _val do {
  563. _data = "HiveEXT" callExtension _key;
  564. _result = call compile format ["%1",_data];
  565. call compile format["ServerTcache_%1 set [count ServerTcache_%1,%2]",_traderid,_result];
  566. _retrader set [count _retrader,_result];
  567. };
  568. };
  569. } forEach (_traderData select 0);
  570. };
  571. } forEach serverTraders;
  572. };
  573.  
  574. if (_hiveLoaded) then {
  575. _serverVehicleCounter spawn {
  576. // spawn_vehicles
  577. // Get all buildings and roads only once. Very taxing, but only on first startup
  578. _serverVehicleCounter = _this;
  579. _vehiclesToUpdate = [];
  580. _startTime = diag_tickTime;
  581. _buildingList = [];
  582. _cfgLootFile = missionConfigFile >> "CfgLoot" >> "Buildings";
  583. {
  584. if (isClass (_cfgLootFile >> typeOf _x)) then {
  585. _buildingList set [count _buildingList,_x];
  586. };
  587. } count (getMarkerPos "center" nearObjects ["building",((getMarkerSize "center") select 1)]);
  588. _roadList = getMarkerPos "center" nearRoads ((getMarkerSize "center") select 1);
  589.  
  590. _vehLimit = MaxVehicleLimit - (count _serverVehicleCounter);
  591. if (_vehLimit > 0) then {
  592. diag_log ("HIVE: Spawning # of Vehicles: " + str(_vehLimit));
  593. for "_x" from 1 to _vehLimit do {call spawn_vehicles;};
  594. } else {
  595. diag_log "HIVE: Vehicle Spawn limit reached!";
  596. _vehLimit = 0;
  597. };
  598.  
  599. if (dayz_townGenerator) then {
  600. // Vanilla town generator spawns debris locally on each client
  601. MaxDynamicDebris = 0;
  602. } else {
  603. // Epoch global dynamic debris
  604. diag_log ("HIVE: Spawning # of Debris: " + str(MaxDynamicDebris));
  605. for "_x" from 1 to MaxDynamicDebris do {call spawn_roadblocks;};
  606. };
  607.  
  608. diag_log ("HIVE: Spawning # of Ammo Boxes: " + str(MaxAmmoBoxes));
  609. for "_x" from 1 to MaxAmmoBoxes do {call spawn_ammosupply;};
  610.  
  611. diag_log ("HIVE: Spawning # of Veins: " + str(MaxMineVeins));
  612. for "_x" from 1 to MaxMineVeins do {call spawn_mineveins;};
  613.  
  614. diag_log format["HIVE: BENCHMARK - Server finished spawning %1 DynamicVehicles, %2 Debris, %3 SupplyCrates and %4 MineVeins in %5 seconds (scheduled)",_vehLimit,MaxDynamicDebris,MaxAmmoBoxes,MaxMineVeins,diag_tickTime - _startTime];
  615.  
  616. //Update gear last after all dynamic vehicles are created to save random loot to database (low priority)
  617. {[_x,"gear"] call server_updateObject} count _vehiclesToUpdate;
  618. };
  619. };
  620. [] ExecVM "\z\addons\dayz_server\custom\Loot.sqf";
  621. [] ExecVM "\z\addons\dayz_server\custom\safeZoneVehicleUnlocker.sqf";
  622. [] spawn server_spawnEvents;
  623. /* //Causes issues with changing clothes
  624. _debugMarkerPosition = [(respawn_west_original select 0),(respawn_west_original select 1),1];
  625. _vehicle_0 = createVehicle ["DebugBox_DZ", _debugMarkerPosition, [], 0, "CAN_COLLIDE"];
  626. _vehicle_0 setPos _debugMarkerPosition;
  627. _vehicle_0 setVariable ["ObjectID","1",true];
  628. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement