Jump to content
Sign in to follow this  
hellstorm77

Clean up Script

Recommended Posts

I was wondering if anyone has or knows of a clean up script for items what have been left around on the floor

Share this post


Link to post
Share on other sites

All I've been able to find is corpse/wreck cleanup.

Share this post


Link to post
Share on other sites
I was wondering if anyone has or knows of a clean up script for items what have been left around on the floor

You could find the command? I need to know how.

I'm sure it must be very simple, but can not find any command that works.

Help plz :p

Share this post


Link to post
Share on other sites

The Invade & Annex Mission has 2 cleanup scripts running, 1 for Units and 1 for Items you should take a look at them.

EDIT: Ok, looked it up.

clearItems.sqf (from Rareks Invade & Annex)

private ["_itemsToClear","_obj","_rad","_delay"];
_obj = getMarkerPos "respawn_west"; // get spawn - might as well
_rad = 150;  //  radius outwards from center point to clear items.
_delay = 120; // amount of time in-between clean-ups

while {true} do
{
sleep _delay;
debugMessage = "Clearing items from spawn...";
publicVariable "debugMessage";
[color="#FF0000"]_itemsToClear = nearestObjects [_obj,["weaponholder"],_rad];
{
	deleteVehicle _x;
} forEach _itemsToClear;[/color]
debugMessage = "Items cleared.";
publicVariable "debugMessage";
};


I've marked the important bit for you. That should help you.

Share this post


Link to post
Share on other sites
Could anybody recommend a good body removal script for multiplayer?

This is the one from Invade & Annex.

clearBodies.sqf


private ["_canDeleteGroup","_group","_groups","_units"];
while {true} do
{
sleep 60;
debugMessage = "Cleaning dead bodies and deleting groups...";
publicVariable "debugMessage";
{
	deleteVehicle _x;
} forEach allDead;

debugMessage = "Dead bodies deleted.";
publicVariable "debugMessage";

_groups = allGroups;

for "_c" from 0 to ((count _groups) - 1) do
{
	_canDeleteGroup = true;
	_group = (_groups select _c);
	if (!isNull _group) then
	{
		_units = (units _group);
		{
			if (alive _x) then { _canDeleteGroup = false; };
		} forEach _units;
	};
	if (_canDeleteGroup && !isNull _group) then { deleteGroup _group; };
};

debugMessage = "Empty groups deleted.";
publicVariable "debugMessage";
};


Another good one is this one:

cleanup.sqf


private ["_delcode", "_currentworld", "_oldworld", "_newworld", "_notalive"];
_delcode = {
private ["_crew"];
sleep 300;
{
	if (not isNull _x) then {
		if (_x isKindOf "Ship" or _x isKindOf "Air" or _x isKindOf "LandVehicle") then {
			_crew = nearestObjects [_x, ["Man"], 20];
			_crew = _crew + crew _x;
			deleteVehicle _x;
			{
				if (not alive _x) then {deleteVehicle _x};
			} forEach _crew;
		} else {
			deleteVehicle _x;
		};
	};
} forEach _this;
};
_currentworld = [];
while {true} do {
sleep 3;
_oldworld = _currentworld;
_currentworld = + list wholeworld;
_newworld = _oldworld - _currentworld;
_notalive = [];
{
	if (not alive _x) then {_notalive = _notalive + [_x]};
} forEach _newworld;
if (count _notalive > 0) then {_notalive spawn _delcode};
};



NOTE: This one needs you to place a trigger called "wholeworld" down in your mission, set it as big as you want keep in mind that only units in this trigger will be deleted!

I usually have it set as a Rectangle that covers the whole Map.

cheers!

Share this post


Link to post
Share on other sites

nice one, I already got the invade and annex one but it looks like that second one you put deletes the vehicles and everything if they're destroyed which is better. Does it need to be run only on the server?

Share this post


Link to post
Share on other sites
nice one, I already got the invade and annex one but it looks like that second one you put deletes the vehicles and everything if they're destroyed which is better. Does it need to be run only on the server?

Afaik, No. Works both ways but maybe only on the Server would be safer due to JIPs etc.

Share this post


Link to post
Share on other sites

One thing with these mantis, I have a script that places some dead bodies that runs at the start of the mission. Will either of these scripts delete these too or not as I ideally want them to remain there for the mission.

Share this post


Link to post
Share on other sites

You'd probably hae to add another condition to

if (not alive _x) then {_notalive = _notalive + [_x]};
} forEach _newworld;

You need an Array with VarNames that servers as a Blacklist.


private ["_delcode", "_currentworld", "_oldworld", "_newworld", "_notalive"];
[color="#FF0000"]_blacklist[/color] = []

_delcode = {
private ["_crew"];
sleep 300;
{
	if (not isNull _x) then {
		if (_x isKindOf "Ship" or _x isKindOf "Air" or _x isKindOf "LandVehicle") then {
			_crew = nearestObjects [_x, ["Man"], 20];
			_crew = _crew + crew _x;
			deleteVehicle _x;
			{
				if (not alive _x) then {deleteVehicle _x};
			} forEach _crew;
		} else {
			deleteVehicle _x;
		};
	};
} forEach _this;
};
_currentworld = [];
while {true} do {
sleep 3;
_oldworld = _currentworld;
_currentworld = + list wholeworld;
_newworld = _oldworld - _currentworld;
_notalive = [];
{
	if (not alive _x  && _x !in _[color="#FF0000"]blacklist[/color]) then {_notalive = _notalive + [_x]};
} forEach _newworld;
if (count _notalive > 0) then {_notalive spawn _delcode};






try this, not sure if it works as I've just written this on the fly.

cheers

Share this post


Link to post
Share on other sites
You'd probably hae to add another condition to
if (not alive _x) then {_notalive = _notalive + [_x]};
} forEach _newworld;

You need an Array with VarNames that servers as a Blacklist.


private ["_delcode", "_currentworld", "_oldworld", "_newworld", "_notalive"];
[color="#FF0000"]_blacklist[/color] = []

_delcode = {
private ["_crew"];
sleep 300;
{
	if (not isNull _x) then {
		if (_x isKindOf "Ship" or _x isKindOf "Air" or _x isKindOf "LandVehicle") then {
			_crew = nearestObjects [_x, ["Man"], 20];
			_crew = _crew + crew _x;
			deleteVehicle _x;
			{
				if (not alive _x) then {deleteVehicle _x};
			} forEach _crew;
		} else {
			deleteVehicle _x;
		};
	};
} forEach _this;
};
_currentworld = [];
while {true} do {
sleep 3;
_oldworld = _currentworld;
_currentworld = + list wholeworld;
_newworld = _oldworld - _currentworld;
_notalive = [];
{
	if (not alive _x  && _x !in _[color="#FF0000"]blacklist[/color]) then {_notalive = _notalive + [_x]};
} forEach _newworld;
if (count _notalive > 0) then {_notalive spawn _delcode};






try this, not sure if it works as I've just written this on the fly.

cheers

Yeah it doesn't work, I got a script error on the

if (not alive _x && _x !in _blacklist) then {_notalive = _notalive + [_x]};

line.

Share this post


Link to post
Share on other sites

Here's one I found that works good, not sure who made it for credits..

put [] execVM "cleanup.sqf"; in your init.sqf

cleanup.sqf

private ["_delcode", "_currentworld", "_oldworld", "_newworld", "_notalive"];
_delcode = {
private ["_crew"];
sleep 300;
{
	if (not isNull _x) then {
		if (_x isKindOf "Ship" or _x isKindOf "Air" or _x isKindOf "LandVehicle") then {
			_crew = nearestObjects [_x, ["Man"], 20];
			_crew = _crew + crew _x;
			deleteVehicle _x;
			{
				if (not alive _x) then {deleteVehicle _x};
			} forEach _crew;
		} else {
			deleteVehicle _x;
		};
	};
} forEach _this;
};
_currentworld = [];
while {true} do {
sleep 6;
_oldworld = _currentworld;
_currentworld = + list wholeworld;
_newworld = _oldworld - _currentworld;
_notalive = [];
{
	if (not alive _x) then {_notalive = _notalive + [_x]};
} forEach _newworld;
if (count _notalive > 0) then {_notalive spawn _delcode};
};

change the sleep 300 to whatever time in seconds for the bodies to be cleared.

Share this post


Link to post
Share on other sites
if (not alive _x &&[color="#FF0000"] !(_x in _blacklist)[/color]) then {_notalive = _notalive + [_x]};

Share this post


Link to post
Share on other sites

Maybe consider removing weapon holders since players drop their weapons upon death?

Share this post


Link to post
Share on other sites
if (not alive _x &&[color="#FF0000"] !(_x in _blacklist)[/color]) then {_notalive = _notalive + [_x]};

Cheers larrow that fixes the error but this way of doing it doesn't seem to work, it still deletes the units I named in the blacklist.

Share this post


Link to post
Share on other sites

Anyone used the BIS_fnc_GC (Garbage Collection) in Arma 3 yet? I haven't tried it, and wanted to know if anyone had give it a try.

Not sure if it could replace those functions though.

As the description seem to say, is it does wait for no one in a certain radius is present before deleting.

Not sure if it could help.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×