Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- purge = {
- if(!isNull(_this)) then {
- _this enableSimulation false;
- _this removeAllMPEventHandlers "mpkilled";
- _this removeAllMPEventHandlers "mphit";
- _this removeAllMPEventHandlers "mprespawn";
- _this removeAllEventHandlers "FiredNear";
- _this removeAllEventHandlers "HandleDamage";
- _this removeAllEventHandlers "Killed";
- _this removeAllEventHandlers "Fired";
- _this removeAllEventHandlers "GetOut";
- _this removeAllEventHandlers "GetIn";
- _this removeAllEventHandlers "Local";
- clearVehicleInit _this;
- deleteVehicle _this;
- deleteGroup (group _this);
- _this = nil;
- };
- };
- if (isServer) then {
- [] spawn
- {
- waitUntil {!(isNil "sm_done")};
- diag_log ["LinkCleaning CLEANUP Initialized"];
- _lastlootcheck = diag_tickTime;
- _lastZombieClean = diag_tickTime;
- _lastGroupClean = diag_tickTime;
- _lastGullMod = diag_tickTime;
- _lastFixFps = diag_tickTime;
- while {true} do {
- if ((diag_tickTime - _lastlootcheck) > 180) then
- {
- _lastlootcheck = diag_tickTime;
- private ["_delQty","_nearby","_keep","_qty","_lootpiles","_ammobox"];
- _ammobox = ["USLaunchersBox","RULaunchersBox","USSpecialWeapons_EP1","USVehicleBox"];
- _lootpiles = allMissionObjects "ReammoBox";
- _delQty = 0;
- {
- _keep = (_x getVariable ["permaLoot",false]) || (typeOf _x in _ammobox);
- if (!_keep) then {
- _nearby = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase","AllVehicles"], 130]);
- if (_nearby==0) then {
- deleteVehicle _x;
- sleep 0.025;
- _delQty = _delQty + 1;
- };
- };
- sleep 0.001;
- } forEach _missionObjs;
- if (_delQty > 0) then {
- _qty = count _lootpiles;
- diag_log (format["LinkCleaning: Deleted %1 Loot Piles out of %2",_delQty,_qty]);
- };
- };
- if ((diag_tickTime - _lastFixFps) > 180) then
- {
- _lastFixFps = diag_tickTime;
- _allstartlk = ((allMissionObjects "WeaponHolder")+(allMissionObjects "Sound_Flies")+(allDead)+([0,0,0] nearEntities ['CAAnimalBase', 10000000]));
- _countlk = count _allstartlk;
- diag_log format["LinkCleaning: Start cleaning objects - %1",_countlk];
- {
- if (!isNull _x) then
- {
- if (_x in vehicles) then {deletevehicle _x;};
- _nearbylk1 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 450]);
- _keeplk = _x getVariable ["permaLoot",false];
- if ((_nearbylk1 == 0) && (!_keeplk) && !(_x in alldead)) then
- {
- deleteVehicle _x;
- };
- _nearbylk2 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 25]);
- if ((_nearbylk2 == 0) && (_x in alldead) && (_x isKindOf "zZombie_Base")) then
- {
- deleteVehicle _x;
- };
- if ((_nearbylk2 == 0) && (_x isKindOf "CAAnimalBase")) then {deleteVehicle _x;};
- };
- } foreach _allstartlk;
- _countlktwo = count ((allMissionObjects "WeaponHolder")+(allMissionObjects "Sound_Flies")+(allDead)+([0,0,0] nearEntities ['CAAnimalBase', 10000000]));
- diag_log format["LinkCleaning: Stop cleaning objects - %1",_countlktwo];
- };
- if ((diag_tickTime - _lastZombieClean) > 180) then {
- _lastZombieClean = diag_tickTime;
- {
- if (local _x) then {
- private ["_pos","_delrndzed","_qty","_randomzeds","_nearby"];
- _randomzeds = entities "zZombie_Base";
- _delrndzed = 0;
- _x call purge;
- sleep 0.025;
- _delrndzed = _delrndzed + 1;
- } else {
- if (!alive _x) then {
- _pos = getPosATL _x;
- if (count _pos > 0) then {
- _nearby = {(isPlayer _x) and (alive _x)} count (_pos nearEntities [["CAManBase","AllVehicles"], 130]);
- if (_nearby==0) then {
- _x call purge;
- sleep 0.025;
- _delrndzed = _delrndzed + 1;
- };
- };
- };
- };
- sleep 0.001;
- } forEach _randomzeds;
- if (_delrndzed > 0) then {
- _qty = count_randomzeds;
- diag_log (format["LinkCleaning: Deleted %1 Zombies out of %2",_delrndzed,_qty]);
- };
- if ((diag_tickTime - _lastGroupClean) > 360) then {
- _lastGroupClean = diag_tickTime;
- //Player Groups Cleanup
- if (count units _x==0) then {
- deleteGroup _x;
- _x = nil;
- };
- } forEach allGroups;
- if ((diag_tickTime - _lastGullMod) > 180) then {
- _lastGullMod = diag_tickTime;
- _x call purge;
- } forEach entities "Seagull";
- sleep 5;
- };
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement