Advertisement
MGT

servercleanup.sqf

MGT
Sep 3rd, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. purge = {
  2. if(!isNull(_this)) then {
  3. _this enableSimulation false;
  4. _this removeAllMPEventHandlers "mpkilled";
  5. _this removeAllMPEventHandlers "mphit";
  6. _this removeAllMPEventHandlers "mprespawn";
  7. _this removeAllEventHandlers "FiredNear";
  8. _this removeAllEventHandlers "HandleDamage";
  9. _this removeAllEventHandlers "Killed";
  10. _this removeAllEventHandlers "Fired";
  11. _this removeAllEventHandlers "GetOut";
  12. _this removeAllEventHandlers "GetIn";
  13. _this removeAllEventHandlers "Local";
  14. clearVehicleInit _this;
  15. deleteVehicle _this;
  16. deleteGroup (group _this);
  17. _this = nil;
  18. };
  19. };
  20.  
  21. if (isServer) then {
  22. [] spawn
  23. {
  24. waitUntil {!(isNil "sm_done")};
  25. diag_log ["LinkCleaning CLEANUP Initialized"];
  26.  
  27. _lastlootcheck = diag_tickTime;
  28. _lastZombieClean = diag_tickTime;
  29. _lastGroupClean = diag_tickTime;
  30. _lastGullMod = diag_tickTime;
  31. _lastFixFps = diag_tickTime;
  32.  
  33. while {true} do {
  34. if ((diag_tickTime - _lastlootcheck) > 600) then
  35. {
  36. _lastlootcheck = diag_tickTime;
  37. private ["_delQty","_nearby","_keep","_qty","_lootpiles","_ammobox"];
  38.  
  39. _ammobox = ["USLaunchersBox","RULaunchersBox","USSpecialWeapons_EP1","USVehicleBox"];
  40.  
  41. _lootpiles = allMissionObjects "ReammoBox";
  42. _delQty = 0;
  43. {
  44. _keep = (_x getVariable ["permaLoot",false]) || (typeOf _x in _ammobox);
  45. if (!_keep) then {
  46. _nearby = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase","AllVehicles"], 130]);
  47. if (_nearby==0) then {
  48. deleteVehicle _x;
  49. uiSleep 0.025;
  50. _delQty = _delQty + 1;
  51. };
  52. };
  53. uiSleep 0.001;
  54. } forEach _missionObjs;
  55. if (_delQty > 0) then {
  56. _qty = count _lootpiles;
  57. diag_log (format["LinkCleaning: Deleted %1 Loot Piles out of %2",_delQty,_qty]);
  58. };
  59. };
  60.  
  61. if ((diag_tickTime - _lastFixFps) > 600) then
  62. {
  63. _lastFixFps = diag_tickTime;
  64. _allstartlk = ((allMissionObjects "WeaponHolder")+(allMissionObjects "Sound_Flies")+(allDead)+([0,0,0] nearEntities ['CAAnimalBase', 10000000]));
  65. diag_log ("LinkCleaning: Start cleaning");
  66. {
  67. if (!isNull _x) then
  68. {
  69. if (_x in vehicles) then {deletevehicle _x;};
  70. _nearbylk1 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 450]);
  71. _keeplk = _x getVariable ["permaLoot",false];
  72. if ((_nearbylk1 == 0) && (!_keeplk) && !(_x in alldead)) then
  73. {
  74. deleteVehicle _x;
  75. };
  76. _nearbylk2 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 25]);
  77. if ((_nearbylk2 == 0) && (_x in alldead) && (_x isKindOf "zZombie_Base")) then
  78. {
  79. deleteVehicle _x;
  80. };
  81. if ((_nearbylk2 == 0) && (_x isKindOf "CAAnimalBase")) then {deleteVehicle _x;};
  82. };
  83. } foreach _allstartlk;
  84. diag_log ("LinkCleaning: Stop cleaning");
  85. };
  86.  
  87. if ((diag_tickTime - _lastZombieClean) > 600) then {
  88. _lastZombieClean = diag_tickTime;
  89. {
  90. if (local _x) then {
  91. private ["_pos","_delrndzed","_qty","_randomzeds","_nearby"];
  92.  
  93. _randomzeds = entities "zZombie_Base";
  94. _delrndzed = 0;
  95.  
  96. _x call purge;
  97. uiSleep 0.025;
  98. _delrndzed = _delrndzed + 1;
  99. } else {
  100. if (!alive _x) then {
  101. _pos = getPosATL _x;
  102. if (count _pos > 0) then {
  103. _nearby = {(isPlayer _x) and (alive _x)} count (_pos nearEntities [["CAManBase","AllVehicles"], 130]);
  104. if (_nearby==0) then {
  105. _x call purge;
  106. uiSleep 0.025;
  107. _delrndzed = _delrndzed + 1;
  108. };
  109. };
  110. };
  111. };
  112. uiSleep 0.001;
  113. } forEach _randomzeds;
  114. if (_delrndzed > 0) then {
  115. _qty = count_randomzeds;
  116. diag_log (format["LinkCleaning: Deleted %1 Zombies out of %2",_delrndzed,_qty]);
  117. };
  118.  
  119.  
  120. if ((diag_tickTime - _lastGroupClean) > 300) then {
  121. _lastGroupClean = diag_tickTime;
  122. //Player Groups Cleanup
  123. if (count units _x==0) then {
  124. deleteGroup _x;
  125. _x = nil;
  126. };
  127. } forEach allGroups;
  128.  
  129.  
  130. if ((diag_tickTime - _lastGullMod) > 1000) then {
  131. _lastGullMod = diag_tickTime;
  132. _x call purge;
  133. } forEach entities "Seagull";
  134. uiSleep 5;
  135. };
  136. };
  137. };
  138. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement