Jump to content
  • 0

Clean Up Script


Hooty

Question

19 answers to this question

Recommended Posts

  • 0

Here's what I used on 1.0.5.1, not sure if it works fully on 1.0.6.1, but give it a try.

if (isServer) then {
	cleanUnit = {
		if !(isNull _this) then {
			_group = group _this;
			_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;
			_objectID 	= _this getVariable ['ObjectID','0'];
			_objectUID 	= _this getVariable ['ObjectUID','0'];
			if ((parseNumber _objectID != 0)&&(parseNumber _objectUID != 0)) then {[_objectID,_objectUID,objNull] spawn server_deleteObj;};
			deleteVehicle _this;
			if ((count (units _group) == 0)&&(!isNull _group)) then {
				deleteGroup _group;
			};
		};
	};
	[] spawn {
		//Not needed if running epoch
		while {1 == 1} do {
			_deletedGRP = 0;
			{
				if ((count (units _x) == 0)&&(!isNull _x)) then {
					_deletedGRP = _deletedGRP + 1;
					deleteGroup _x;
				};
			} forEach allGroups;
			if (_deletedGRP > 0) then {diag_log format ["Deleted %1 empty group(s).", _deletedGRP];};
			uiSleep (60*2);
		};
	};
	[] spawn {
		while {1 == 1} do {
			uiSleep (60*15);
			_clutter = ["wreck","crater","craterlong","PartWoodPile","Land_Fire"];
			_objectlist = [];
			{_objectlist = _objectlist + allMissionObjects _x} count _clutter;
			_objectsX = _objectlist + alldead;
			_deletedZOM = 0;
			_deletedPLR = 0;
			_deletedCLT = 0;
			_deletedANI = 0;
			_deletedINV = 0;
			_deletedVEH = 0;
			_deletedSEA = 0;
			_deletedFLY = 0;
			_deletedBOX = 0;
			_deletedGRP = 0;
			{
				if !(isNull _x) then {
					_players2 = {isPlayer _x} count (getPos _x nearEntities [["CAManBase"], 200]);
					if (_x in _clutter) then {
						deleteVehicle _x;
						_deletedCLT = _deletedCLT + 1;
					};
					if ((_players2 < 2) && (_x isKindOf "zZombie_Base")) then {
						_x call cleanUnit;
						_deletedZOM = _deletedZOM + 1;
					};
					if ((_players2 == 0) && (_x isKindOf "CAAnimalBase") && (typeOf _x != "DZ_fin") && (typeOf _x != "DZ_pastor")) then {
						_x call cleanUnit;
						_deletedANI = _deletedANI + 1;
					};
				};
			} forEach _objectsX;
			//Not needed if running epoch
			{
				if !(isNull _x) then {
					if ((_x in alldead) && (_x isKindOf "CAManBase")) then {
						_deathTime = _x getVariable ["processedDeath",0];
						if (_deathTime != 0) then {
							if ((diag_tickTime - _deathTime) >= (60*30)) then {
								_x call cleanUnit;
								_deletedPLR = _deletedPLR + 1;
							};
						} else {_x setVariable ["processedDeath",diag_tickTime]};
					};
					_modeldex = typeOf _x;
					if (_modeldex == "Survivor1_DZ") then {
						_x call cleanUnit;
						_deletedINV = _deletedINV + 1;
					};
				};
			} forEach allDead;
			{
				if !(isNull _x) then {
					_x call cleanUnit;
					_deletedSEA = _deletedSEA + 1;
				};
			} forEach allMissionObjects "Seagull";
			{
				if !(isNull _x) then {
					deleteVehicle _x;
					_deletedFLY = _deletedFLY + 1;
				};
			} forEach allMissionObjects "Sound_Flies";
			{
				if !(isNull _x) then {
					if (!(_x isKindOf "AIR")&&!(_x isKindOf "Ship")&&!(_x isKindOf "LandVehicle")) then {
						if (((count ((getWeaponCargo _x) select 1))+(count ((getMagazineCargo _x) select 1))) > 80) then {
							_issf = (typeOf _x) in ["VaultStorage","USBasicAmmunitionBox","StorageShed_DZ"];
							_ismb = _x getVariable ["permaLoot",false];
							if ((!_issf)&&(!_ismb)) then {
								if !(owner _object in [0,1]) then {
									{if (owner _object == owner _x) exitWith {_unit = _x}} forEach playableUnits;
								} else {_unit = 'server'};
								_log = format ["Hackbox (?): %2 deleted @ %1 SPAWNED BY: %3",mapGridPosition (getPos _x),typeOf _x,name _unit];
								diag_log (_log);
								
								_x call cleanUnit;
								_deletedBOX = _deletedBOX + 1;
								_x = nil;
							};
						};
					};
				};
			} forEach allMissionObjects "All";
			//Not needed if running epoch
			_vehicles = [];
			{_vehicles = _vehicles + allMissionObjects _x;} count (['Air','Ship','LandVehicle']);
			{
				if !(isNull _x) then {
					if (((damage _x)>0.9)&&!(_x isKindOf "MAN")) then {
						_x call cleanUnit;
						_deletedVEH = _deletedVEH + 1;
					};
				};
			} forEach _vehicles;
			diag_log format ["Deleted %1 hack box(es).", _deletedBOX];
			diag_log format ["Deleted %1 blown up vehicle(s).", _deletedVEH];
			diag_log format ["Deleted %1 clutter item(s).",_deletedCLT];
			diag_log format ["Deleted %1 dead player(s). (100m radius check)",_deletedPLR];
			diag_log format ["Deleted %1 invisible dead player(s).",_deletedINV];
			diag_log format ["Deleted %1 dead zombie(s). (100m radius check)",_deletedZOM];
			diag_log format ["Deleted %1 dead animal(s). (100m radius check)",_deletedANI];
			diag_log format ["Deleted %1 fly sound(s).", _deletedFLY];
			diag_log format ["Deleted %1 seagull(s).", _deletedSEA];
			uiSleep (60*1.5);
		};
	};
};
diag_log ("Server Cleanup Complete!");

 

Link to comment
Share on other sites

  • 0
17 hours ago, DieTanx said:

Check this out

Thanks I have all kinds of sql events running. I was talking about something like this from my 1051 server but it does not work for 1061

cleanup.sqf

Spoiler

YRUNpurge = {
    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;
    };
};

objectDelete = {
    _objectID     = _this getVariable ['ObjectID','0'];
    _objectUID     = _this getVariable ['ObjectUID','0'];
    if (isNil '_objectID') exitWith {};
    if (isNil '_objectUID') exitWith {};
    PVDZE_obj_Delete = [_objectID,_objectUID,player];
    publicVariableServer 'PVDZE_obj_Delete';
    if !(isNull _this) then {deleteVehicle _this};
};

if (isServer) then {
    [] spawn {
        private["_lastbikeClean","_lastLootClean","_lastZombieClean","_lastGroupClean","_lastSeagullClean","_countCleaned","_countTotal","_lootPiles","_seagulls","_zombies","_nearby","_pos","_keep","_ammobox","_lastvehiclecleanup","_lastservercleancheck"];
        waitUntil {!(isNil "sm_done");};
        diag_log text "CLEANUP: Initialized...";

        _lastZombieClean = diag_tickTime;
        _lastGroupClean = diag_tickTime;
        _lastSeagullClean = diag_tickTime;
        _lastvehiclecleanup = diag_tickTime;
        _lastservercleancheck = diag_tickTime;
        _lastbikeClean = diag_tickTime;

        while {true} do {
        
            if ((diag_tickTime - _lastbikeClean) > 120) then {
                _lastbikeClean = diag_tickTime;
                _bikes = entities 'MMT_Civ';
                _deleted = 0;
                {
                    _obj = _x;
                    if(!isNull _obj)then
                    {
                        _count = {isPlayer _x} count (_obj nearEntities 100);
                        if(_count == 0)then
                        {
                            _deleted = _deleted + 1;deleteVehicle _obj;
                        };
                    };
                } forEach _bikes;
            };
        
            if ((diag_tickTime - _lastZombieClean) > 120) then {
                _lastZombieClean = diag_tickTime;
                _zombies = entities "zZombie_Base";
                _countTotal = count _zombies;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (local _x) then {
                            _x call YRUNpurge;
                            _countCleaned = _countCleaned + 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 YRUNpurge;
                                        _countCleaned = _countCleaned + 1;
                                    };
                                };
                            };
                        };
                    };
                    sleep 0.001;
                } forEach _zombies;
            };
            
            if (((diag_tickTime - _lastvehiclecleanup) > 120)) then
            {
            _lastvehiclecleanup = diag_tickTime;
            private ["_YRUNVC","_vehs","_garage"];
                _YRUNVC = 0;
                _vehs = [];
                {
                    _garage = (getPosATL _x) nearObjects ["Land_sara_hasic_zbroj",7];
                    if !((count _garage) > 1) then {
                        if (((damage _x)>0.99)&&!(_x isKindOf "MAN")&&!(_x isKindOf "CAAnimalBase")&&!(_x isKindOf "zZombie_Base")&&!(_x isKindOf "static")&&!(_x isKindOf "building")) then {
                            if (typeOf _x != "SHEEP") then {
                                _x spawn objectDelete;
                                _YRUNVC = _YRUNVC + 1;
                                _vehs = _vehs + [typeOf _x];
                            };
                        };
                    };
                } forEach (vehicles);
            };
            
            if (((diag_tickTime - _lastservercleancheck) > 180)) then
            {
            _lastservercleancheck = diag_tickTime;
            private ["_itemclasses","_itemlist","_itemCount"];
            _itemclasses =
                [
                    "GraveCrossHelmet_EP1","GraveCrossHelmet_DZ","wreck","crater","craterlong","PartWoodPile",
                    "SeaGull","Rabbit","WildBoar","Cow","Goat","Sheep","Bird","wire_cat1",
                    "CAAnimalBase","Sound_Flies"
                ];
                {
                    _itemlist     = allMissionObjects _x;
                    _itemCount     = (count _itemlist);
                    {
                        if ((typeOf _x != "DZ_fin")||(typeOf _x != "DZ_pastor")||(typeOf _x != "SHEEP")) then {
                            _x spawn objectDelete;
                        };
                    } forEach (allMissionObjects _x);
                } forEach _itemclasses;
            };

            if ((diag_tickTime - _lastGroupClean) > 120) then {
                _lastGroupClean = diag_tickTime;
                _countTotal = count allGroups;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (count units _x == 0) then {
                            deleteGroup _x;
                            _x = nil;
                            _countCleaned = _countCleaned + 1;
                        };
                    };
                    sleep 0.001;
                } forEach allGroups;
            };

            if ((diag_tickTime - _lastSeagullClean) > 120) then {
                _lastSeagullClean = diag_tickTime;
                _seagulls = entities "Seagull";
                _countTotal = count _seagulls;
                _countCleaned = 0;
                {
                    _x call YRUNpurge;
                    _countCleaned = _countCleaned + 1;
                    sleep 0.001;
                } forEach _seagulls;
            };

            sleep 1;
        };
    };
};

 

Link to comment
Share on other sites

  • 0

I have plenty of sql events working but need something instant I have it working now thanks to a friend of mine. 

Here it is I call it yRunCleanup.sqf change to whatever you like

Spoiler

YRUNpurge = {
    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;
    };
};
 
objectDelete = {
 
    _objectID     = _this getVariable ['ObjectID','0'];
    _objectUID     = _this getVariable ['ObjectUID','0'];
    if (isNil '_objectID') exitWith {};
    if (isNil '_objectUID') exitWith {};
 
 
    [_objectID,_objectUID,player] call server_deleteObj;
 
 
    if !(isNull _this) then {deleteVehicle _this};
 
};
 
 
if (isServer) then {
    [] spawn {
        private["_lastbikeClean","_lastLootClean","_lastZombieClean","_lastGroupClean","_lastSeagullClean","_countCleaned","_countTotal","_lootPiles","_seagulls","_zombies","_nearby","_pos","_keep","_ammobox","_lastvehiclecleanup","_lastservercleancheck"];
        waitUntil {!(isNil "sm_done");};
        diag_log text "CLEANUP: Initialized...";
 
        _lastZombieClean = diag_tickTime;
        _lastGroupClean = diag_tickTime;
        _lastSeagullClean = diag_tickTime;
        _lastvehiclecleanup = diag_tickTime;
        _lastservercleancheck = diag_tickTime;
        _lastbikeClean = diag_tickTime;
 
        while {true} do {
       
            if ((diag_tickTime - _lastbikeClean) > 120) then {
                _lastbikeClean = diag_tickTime;
                _bikes = entities 'MMT_Civ';
                _deleted = 0;
                {
                    _obj = _x;
                    if(!isNull _obj)then
                    {
                        _count = {isPlayer _x} count (_obj nearEntities 100);
                        if(_count == 0)then
                        {
                            _deleted = _deleted + 1;deleteVehicle _obj;
                        };
                    };
                } forEach _bikes;
            };
       
            if ((diag_tickTime - _lastZombieClean) > 120) then {
                _lastZombieClean = diag_tickTime;
                _zombies = entities "zZombie_Base";
                _countTotal = count _zombies;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (local _x) then {
                            _x call YRUNpurge;
                            _countCleaned = _countCleaned + 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 YRUNpurge;
                                        _countCleaned = _countCleaned + 1;
                                    };
                                };
                            };
                        };
                    };
                    sleep 0.001;
                } forEach _zombies;
            };
           
            if (((diag_tickTime - _lastvehiclecleanup) > 120)) then
            {
            _lastvehiclecleanup = diag_tickTime;
            private ["_YRUNVC","_vehs","_garage"];
                _YRUNVC = 0;
                _vehs = [];
                {
                    _garage = (getPosATL _x) nearObjects ["Land_sara_hasic_zbroj",7];
                    if !((count _garage) > 1) then {
                        if (((damage _x)>0.99)&&!(_x isKindOf "MAN")&&!(_x isKindOf "CAAnimalBase")&&!(_x isKindOf "zZombie_Base")&&!(_x isKindOf "static")&&!(_x isKindOf "building")) then {
                            if (typeOf _x != "SHEEP") then {
                                _x spawn objectDelete;
                                _YRUNVC = _YRUNVC + 1;
                                _vehs = _vehs + [typeOf _x];
                            };
                        };
                    };
                } forEach (vehicles);
            };
           
            if (((diag_tickTime - _lastservercleancheck) > 180)) then
            {
            _lastservercleancheck = diag_tickTime;
            private ["_itemclasses","_itemlist","_itemCount"];
            _itemclasses =
                [
                    "GraveCrossHelmet_EP1","GraveCrossHelmet_DZ","wreck","crater","craterlong","PartWoodPile",
                    "SeaGull","Rabbit","WildBoar","Cow","Goat","Sheep","Bird","wire_cat1",
                    "CAAnimalBase","Sound_Flies"
                ];
                {
                    _itemlist     = allMissionObjects _x;
                    _itemCount     = (count _itemlist);
                    {
                        if ((typeOf _x != "DZ_fin")||(typeOf _x != "DZ_pastor")||(typeOf _x != "SHEEP")) then {
                            _x spawn objectDelete;
                        };
                    } forEach (allMissionObjects _x);
                } forEach _itemclasses;
            };
 
            if ((diag_tickTime - _lastGroupClean) > 120) then {
                _lastGroupClean = diag_tickTime;
                _countTotal = count allGroups;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (count units _x == 0) then {
                            deleteGroup _x;
                            _x = nil;
                            _countCleaned = _countCleaned + 1;
                        };
                    };
                    sleep 0.001;
                } forEach allGroups;
            };
 
            if ((diag_tickTime - _lastSeagullClean) > 120) then {
                _lastSeagullClean = diag_tickTime;
                _seagulls = entities "Seagull";
                _countTotal = count _seagulls;
                _countCleaned = 0;
                {
                    _x call YRUNpurge;
                    _countCleaned = _countCleaned + 1;
                    sleep 0.001;
                } forEach _seagulls;
            };
 
            sleep 1;
        };
    };
};

Call it in your dayz_sever/server_functions at the bottom like 

Spoiler

[] execVM "\z\addons\dayz_server\init\yRunCleanup.sqf"

This gets rid of blown up vehicles, graves, dead bodies, etc every 120 seconds. Helps with my server fps.

Link to comment
Share on other sites

  • 0
On 4/30/2017 at 0:18 PM, DAmNRelentless said:

I would be careful with deleting dead so fast. I hear the humanity is stored on it until the player respawns. And some players are leaving when they day and don't create a new character.

Just deletes the dead body not anything to do with database.

Link to comment
Share on other sites

  • 0
On 4/30/2017 at 0:07 PM, Hooty said:

I have plenty of sql events working but need something instant I have it working now thanks to a friend of mine. 

Here it is I call it yRunCleanup.sqf change to whatever you like

  Reveal hidden contents

YRUNpurge = {
    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;
    };
};
 
objectDelete = {
 
    _objectID     = _this getVariable ['ObjectID','0'];
    _objectUID     = _this getVariable ['ObjectUID','0'];
    if (isNil '_objectID') exitWith {};
    if (isNil '_objectUID') exitWith {};
 
 
    [_objectID,_objectUID,player] call server_deleteObj;
 
 
    if !(isNull _this) then {deleteVehicle _this};
 
};
 
 
if (isServer) then {
    [] spawn {
        private["_lastbikeClean","_lastLootClean","_lastZombieClean","_lastGroupClean","_lastSeagullClean","_countCleaned","_countTotal","_lootPiles","_seagulls","_zombies","_nearby","_pos","_keep","_ammobox","_lastvehiclecleanup","_lastservercleancheck"];
        waitUntil {!(isNil "sm_done");};
        diag_log text "CLEANUP: Initialized...";
 
        _lastZombieClean = diag_tickTime;
        _lastGroupClean = diag_tickTime;
        _lastSeagullClean = diag_tickTime;
        _lastvehiclecleanup = diag_tickTime;
        _lastservercleancheck = diag_tickTime;
        _lastbikeClean = diag_tickTime;
 
        while {true} do {
       
            if ((diag_tickTime - _lastbikeClean) > 120) then {
                _lastbikeClean = diag_tickTime;
                _bikes = entities 'MMT_Civ';
                _deleted = 0;
                {
                    _obj = _x;
                    if(!isNull _obj)then
                    {
                        _count = {isPlayer _x} count (_obj nearEntities 100);
                        if(_count == 0)then
                        {
                            _deleted = _deleted + 1;deleteVehicle _obj;
                        };
                    };
                } forEach _bikes;
            };
       
            if ((diag_tickTime - _lastZombieClean) > 120) then {
                _lastZombieClean = diag_tickTime;
                _zombies = entities "zZombie_Base";
                _countTotal = count _zombies;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (local _x) then {
                            _x call YRUNpurge;
                            _countCleaned = _countCleaned + 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 YRUNpurge;
                                        _countCleaned = _countCleaned + 1;
                                    };
                                };
                            };
                        };
                    };
                    sleep 0.001;
                } forEach _zombies;
            };
           
            if (((diag_tickTime - _lastvehiclecleanup) > 120)) then
            {
            _lastvehiclecleanup = diag_tickTime;
            private ["_YRUNVC","_vehs","_garage"];
                _YRUNVC = 0;
                _vehs = [];
                {
                    _garage = (getPosATL _x) nearObjects ["Land_sara_hasic_zbroj",7];
                    if !((count _garage) > 1) then {
                        if (((damage _x)>0.99)&&!(_x isKindOf "MAN")&&!(_x isKindOf "CAAnimalBase")&&!(_x isKindOf "zZombie_Base")&&!(_x isKindOf "static")&&!(_x isKindOf "building")) then {
                            if (typeOf _x != "SHEEP") then {
                                _x spawn objectDelete;
                                _YRUNVC = _YRUNVC + 1;
                                _vehs = _vehs + [typeOf _x];
                            };
                        };
                    };
                } forEach (vehicles);
            };
           
            if (((diag_tickTime - _lastservercleancheck) > 180)) then
            {
            _lastservercleancheck = diag_tickTime;
            private ["_itemclasses","_itemlist","_itemCount"];
            _itemclasses =
                [
                    "GraveCrossHelmet_EP1","GraveCrossHelmet_DZ","wreck","crater","craterlong","PartWoodPile",
                    "SeaGull","Rabbit","WildBoar","Cow","Goat","Sheep","Bird","wire_cat1",
                    "CAAnimalBase","Sound_Flies"
                ];
                {
                    _itemlist     = allMissionObjects _x;
                    _itemCount     = (count _itemlist);
                    {
                        if ((typeOf _x != "DZ_fin")||(typeOf _x != "DZ_pastor")||(typeOf _x != "SHEEP")) then {
                            _x spawn objectDelete;
                        };
                    } forEach (allMissionObjects _x);
                } forEach _itemclasses;
            };
 
            if ((diag_tickTime - _lastGroupClean) > 120) then {
                _lastGroupClean = diag_tickTime;
                _countTotal = count allGroups;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (count units _x == 0) then {
                            deleteGroup _x;
                            _x = nil;
                            _countCleaned = _countCleaned + 1;
                        };
                    };
                    sleep 0.001;
                } forEach allGroups;
            };
 
            if ((diag_tickTime - _lastSeagullClean) > 120) then {
                _lastSeagullClean = diag_tickTime;
                _seagulls = entities "Seagull";
                _countTotal = count _seagulls;
                _countCleaned = 0;
                {
                    _x call YRUNpurge;
                    _countCleaned = _countCleaned + 1;
                    sleep 0.001;
                } forEach _seagulls;
            };
 
            sleep 1;
        };
    };
};

Call it in your dayz_sever/server_functions at the bottom like 

  Reveal hidden contents

[] execVM "\z\addons\dayz_server\init\yRunCleanup.sqf"

This gets rid of blown up vehicles, graves, dead bodies, etc every 120 seconds. Helps with my server fps.

Awesome!

 

Have you had issues with dead bodies clean up to quick before players collect gear again?

Link to comment
Share on other sites

  • 0
1 minute ago, DieTanx said:

Awesome!

 

Have you had issues with dead bodies clean up to quick before players collect gear again?

Yes I did I increased the timer on the cleans. From 120 = 2 mins to 300 = 5 mins. Not a problem since. I think 5 mins is plenty of time to get back to your dead body. I also have a lot of spawn selects to get there faster as well. 

Link to comment
Share on other sites

  • 0
6 minutes ago, Hooty said:

Yes I did I increased the timer on the cleans. From 120 = 2 mins to 300 = 5 mins. Not a problem since. I think 5 mins is plenty of time to get back to your dead body. I also have a lot of spawn selects to get there faster as well. 

Adding this in tonight!

Working amazing so far on test server, cant wait to see it while server pop is high in morning. 

 

Link to comment
Share on other sites

  • 0
On 2017-4-30 at 2:07 PM, Hooty said:

I have plenty of sql events working but need something instant I have it working now thanks to a friend of mine. 

Here it is I call it yRunCleanup.sqf change to whatever you like

  Reveal hidden contents

YRUNpurge = {
    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;
    };
};
 
objectDelete = {
 
    _objectID     = _this getVariable ['ObjectID','0'];
    _objectUID     = _this getVariable ['ObjectUID','0'];
    if (isNil '_objectID') exitWith {};
    if (isNil '_objectUID') exitWith {};
 
 
    [_objectID,_objectUID,player] call server_deleteObj;
 
 
    if !(isNull _this) then {deleteVehicle _this};
 
};
 
 
if (isServer) then {
    [] spawn {
        private["_lastbikeClean","_lastLootClean","_lastZombieClean","_lastGroupClean","_lastSeagullClean","_countCleaned","_countTotal","_lootPiles","_seagulls","_zombies","_nearby","_pos","_keep","_ammobox","_lastvehiclecleanup","_lastservercleancheck"];
        waitUntil {!(isNil "sm_done");};
        diag_log text "CLEANUP: Initialized...";
 
        _lastZombieClean = diag_tickTime;
        _lastGroupClean = diag_tickTime;
        _lastSeagullClean = diag_tickTime;
        _lastvehiclecleanup = diag_tickTime;
        _lastservercleancheck = diag_tickTime;
        _lastbikeClean = diag_tickTime;
 
        while {true} do {
       
            if ((diag_tickTime - _lastbikeClean) > 120) then {
                _lastbikeClean = diag_tickTime;
                _bikes = entities 'MMT_Civ';
                _deleted = 0;
                {
                    _obj = _x;
                    if(!isNull _obj)then
                    {
                        _count = {isPlayer _x} count (_obj nearEntities 100);
                        if(_count == 0)then
                        {
                            _deleted = _deleted + 1;deleteVehicle _obj;
                        };
                    };
                } forEach _bikes;
            };
       
            if ((diag_tickTime - _lastZombieClean) > 120) then {
                _lastZombieClean = diag_tickTime;
                _zombies = entities "zZombie_Base";
                _countTotal = count _zombies;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (local _x) then {
                            _x call YRUNpurge;
                            _countCleaned = _countCleaned + 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 YRUNpurge;
                                        _countCleaned = _countCleaned + 1;
                                    };
                                };
                            };
                        };
                    };
                    sleep 0.001;
                } forEach _zombies;
            };
           
            if (((diag_tickTime - _lastvehiclecleanup) > 120)) then
            {
            _lastvehiclecleanup = diag_tickTime;
            private ["_YRUNVC","_vehs","_garage"];
                _YRUNVC = 0;
                _vehs = [];
                {
                    _garage = (getPosATL _x) nearObjects ["Land_sara_hasic_zbroj",7];
                    if !((count _garage) > 1) then {
                        if (((damage _x)>0.99)&&!(_x isKindOf "MAN")&&!(_x isKindOf "CAAnimalBase")&&!(_x isKindOf "zZombie_Base")&&!(_x isKindOf "static")&&!(_x isKindOf "building")) then {
                            if (typeOf _x != "SHEEP") then {
                                _x spawn objectDelete;
                                _YRUNVC = _YRUNVC + 1;
                                _vehs = _vehs + [typeOf _x];
                            };
                        };
                    };
                } forEach (vehicles);
            };
           
            if (((diag_tickTime - _lastservercleancheck) > 180)) then
            {
            _lastservercleancheck = diag_tickTime;
            private ["_itemclasses","_itemlist","_itemCount"];
            _itemclasses =
                [
                    "GraveCrossHelmet_EP1","GraveCrossHelmet_DZ","wreck","crater","craterlong","PartWoodPile",
                    "SeaGull","Rabbit","WildBoar","Cow","Goat","Sheep","Bird","wire_cat1",
                    "CAAnimalBase","Sound_Flies"
                ];
                {
                    _itemlist     = allMissionObjects _x;
                    _itemCount     = (count _itemlist);
                    {
                        if ((typeOf _x != "DZ_fin")||(typeOf _x != "DZ_pastor")||(typeOf _x != "SHEEP")) then {
                            _x spawn objectDelete;
                        };
                    } forEach (allMissionObjects _x);
                } forEach _itemclasses;
            };
 
            if ((diag_tickTime - _lastGroupClean) > 120) then {
                _lastGroupClean = diag_tickTime;
                _countTotal = count allGroups;
                _countCleaned = 0;
                {
                    if(!(isNull _x)) then {
                        if (count units _x == 0) then {
                            deleteGroup _x;
                            _x = nil;
                            _countCleaned = _countCleaned + 1;
                        };
                    };
                    sleep 0.001;
                } forEach allGroups;
            };
 
            if ((diag_tickTime - _lastSeagullClean) > 120) then {
                _lastSeagullClean = diag_tickTime;
                _seagulls = entities "Seagull";
                _countTotal = count _seagulls;
                _countCleaned = 0;
                {
                    _x call YRUNpurge;
                    _countCleaned = _countCleaned + 1;
                    sleep 0.001;
                } forEach _seagulls;
            };
 
            sleep 1;
        };
    };
};

Call it in your dayz_sever/server_functions at the bottom like 

  Hide contents

[] execVM "\z\addons\dayz_server\init\yRunCleanup.sqf"

This gets rid of blown up vehicles, graves, dead bodies, etc every 120 seconds. Helps with my server fps.

Hello friends, can you tell me if the script affects Ai of Missions Wai and DZMS?

Link to comment
Share on other sites

  • 0
Just now, harcosgoogle said:

@Hooty How to disable PLAYERS Bodies cleanup?

 

Thanks!

check this part.. the script do not clean up the bodys .. just the bones, graves... etc..  thers a file sched_corpses.. or something like this.. who changes bodys by bones or graves after 40minutes (more or less)...  so really its not a problem i think that this script removes the bones... anyway... if u want to remove it.. just delete lines in red:

Spoiler

if (((diag_tickTime - _lastservercleancheck) > 180)) then
            {
            _lastservercleancheck = diag_tickTime;
            private ["_itemclasses","_itemlist","_itemCount"];
            _itemclasses =
                [
                    "GraveCrossHelmet_EP1","GraveCrossHelmet_DZ","wreck","crater","craterlong","PartWoodPile",
                    "SeaGull","Rabbit","WildBoar","Cow","Goat","Sheep","Bird","wire_cat1",
                    "CAAnimalBase","Sound_Flies"
                ];
                {
                    _itemlist     = allMissionObjects _x;
                    _itemCount     = (count _itemlist);
                    {
                        if ((typeOf _x != "DZ_fin")||(typeOf _x != "DZ_pastor")||(typeOf _x != "SHEEP")) then {
                            _x spawn objectDelete;
                        };
                    } forEach (allMissionObjects _x);
                } forEach _itemclasses;
            };

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...