Jump to content

Recommended Posts

Overview

    Clean up all dead, dropped stuff, ruins, craters around desired point or entire map and  remove empty groups.
    You need to define at least one parameter position, marker or object.

	Parameter(s):
		0 (Required):
			STRING 	- marker name, or
			ARRAY 	- position in format [x,y,z] or
			OBJECT 	- trigger or any object
		1 (Optional): NUMMBER - Radius for dead stuff search around param 0, if not supplied, 500m will be automatically selected.
		2 (Optional): NUMMBER - Min distance from object to any player. Preventing  player to see disappearing of the object, if not supplied, 300m will be automatically selected.
		3 (Optional): NUMMBER - Vehicle damage above which almost wrecked vehicles without crew will be selected to remove it. If not supplied such vehicles stays in game. Value between 0.1 and 0.9
		4 (Optional): BOOLEAN - Ability to handle with empty groups - true/false. If not supplied false will be selected (disabled)
		5 (Optional): NUMMBER - Sleep time in sec between search if not defined 5 min will be automatically selected.

	Returns: Nothing


    To prevent remove some object you need to set an "dnt_remove_me" variable on it using:

     this setVariable ["dnt_remove_me",true,false]

You can adjust default functionality by passing desired parameters.

Can be called for one area, many areas  using multiple instances, or for entire map at once.


Download

Google Drive

Armaholic

Usage

Place the script in mission root/scripts directory.
Best method is to compile it into a function specially if more instances needed.
Usage is also commented at the top of the file.

 

init.sqf :

	/*Example for whole map:
	
	Constantly search entire map with 10min interval.
	Objects in player range (100m) will be skipped.
	Almost wrecked vehicles without crew stays in game.
	*/
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			[worldSize/2,worldSize/2,0],
			worldSize/2,
			100,
			1200
		] spawn fnc_cleanup;
	};

 

init.sqf :

	/*Example for marker:
	
	Constantly search entire marker area with 5min interval.
	Objects in player range (300m) will be skipped.
	*/
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			"marker0",
			((getMarkerSize "marker0") call BIS_fnc_greatestNum)
		] spawn fnc_cleanup;
	};

 

init.sqf :

	/*Example for object:
	
	Constantly search entire trigger area with 10min interval.
	Almost wrecked empty vehicles with damage > 0.8  will be removed.
	Objects in player range (500m) will be skipped. 
	Empty groups will be removed.
	*/
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			_myTrigger,
			((triggerArea _myTrigger) call BIS_fnc_greatestNum),
			500,
			0.8,
			true,
			1200
		] spawn fnc_cleanup;
	};

 

cleanup.sqf

Spoiler

	/*

	Author: DaVidoSS
	name: CleanUp
	ver.: 1.3
	Description:
	Clean up all dead, dropped stuff, ruins, craters around desired point or entire map and remove empty groups. 
	You need to define at least one parameter position, marker or object.
	To prevent remove some object you need to set an "dnt_remove_me" variable on it using:
	this setVariable ["dnt_remove_me",true,false];
	

	Parameter(s):
		0 (Required):
			STRING 	- marker name, or
			ARRAY 	- position in format [x,y,z] or
			OBJECT 	- trigger or any object
		1 (Optional): NUMMBER - Radius for dead stuff search around param 0, if not supplied, 500m will be automatically selected.
		2 (Optional): NUMMBER - Min distance from object to any player. Preventing  player to see disappearing of the object, if not supplied, 300m will be automatically selected.
		3 (Optional): NUMMBER - Vehicle damage above which almost wrecked vehicles without crew will be selected to remove it. If not supplied such vehicles stays in game. Value between 0.1 and 0.9
		4 (Optional): BOOLEAN - Ability to handle with empty groups - true/false. If not supplied false will be selected (disabled)
		5 (Optional): NUMMBER - Sleep time in sec between search if not defined 5 min will be automatically selected.

	Returns: Nothing

	
	usage examples:
	
	Example for whole map:
	
	Constantly search entire map with 10min interval.
	Objects in player range (100m) will be skipped.
	Almost wrecked vehicles without crew stays in game.
	
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			[worldSize/2,worldSize/2,0],
			worldSize/2,
			100,
			1200
		] spawn fnc_cleanup;
	};

	
	Example for marker:
	
	Constantly search entire marker area with 5min interval.
	Objects in player range (300m) will be skipped.
	
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			"marker0",
			((getMarkerSize "marker0") call BIS_fnc_greatestNum)
		] spawn fnc_cleanup;
	};

		
	Example for object:
	
	Constantly search entire trigger area with 10min interval.
	Almost wrecked empty vehicles with damage > 0.8  will be removed.
	Objects in player range (500m) will be skipped. 
	Empty groups will be removed.
	
	if (isServer) then {
	
		fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
		
		null = [
			_myTrigger,
			((triggerArea _myTrigger) call BIS_fnc_greatestNum),
			500,
			0.8,
			true,
			1200
		] spawn fnc_cleanup;
	};

	
	*/
	
	if (!isServer) exitWith {diag_log "** CleanUP: This is no server/host  EXITING!! **"};
	scriptName "CleanUp";
	params [ ["_anchor", [], [[],"",objNull]], ["_radius", 500, [0]], ["_avoidseeing", 300, [0]], ["_damVeh",nil,[0]], ["_groups", false, [true]], ["_sleep", 600, [0]]];
	private _fnc_checkForPlayers = {
		params [["_object", objNull, [objNull, grpNull]],["_area", 0, [0]]];
		private _stdOut = false;
		private _players = allUnits select {isPlayer _x && {!(_x isKindOf "HeadlessClient_F")}};
		if ((typeName _object) isEqualTo "GROUP") exitWith {(_stdOut)};
		private _pos = (getPos _object);
		{if ((_pos distance _x) < _area) exitWith {_stdOut = true}} forEach _players;
		(_stdOut)
	};
	while {true} do {
		if ((typeName _anchor) == "STRING") then {_anchor = (getMarkerPos _anchor)};
		if ((typeName _anchor) == "OBJECT") then {_anchor = (getPos _anchor)};		
		private _szrot = (allMissionObjects "WeaponHolder")+(allMissionObjects "GroundWeaponHolder")+
		(allMissionObjects "WeaponHolderSimulated")+(allMissionObjects "Ruins")+(allMissionObjects "#crater")+(allDead);
		if !(isNil "_damVeh") then {_szrot = _szrot + (vehicles select { (damage _x > _damVeh || {!canMove _x}) && {(count (crew _x)) isEqualTo 0}})};
		if (_groups) then {_szrot = _szrot + allGroups};
		{if ((typeName _x) isEqualTo "GROUP") then {if ((count (units _x)) isEqualTo 0) then {deleteGroup _x}} else {
		if !([_x, _avoidseeing] call _fnc_checkForPlayers) then {if (isNil {_x getVariable "dnt_remove_me"}) then {
		if ((position _x) inArea [_anchor, _radius, _radius, 360, false, -1]) then {deleteVehicle _x}}}}} forEach _szrot;
		sleep _sleep;
	};

 


 
Changelog

12/25/15
First release.

01/04/16
Version 1.0

 

* Possibility to adjust functionality.
* You can now define objects to delete and define damage threshold for vehicles.
* removing empty groups

 

02/17/16
Version 1.1

 

Added :

* Set persistence for certain object.
 
13/01/17
Version 1.2
*Changed usage of BIS_fnc_inTrigger to inAreaArray command
*Set lazy evaluation for conditions

 

03.01.2018

Version  1.3

Changed usage to more user friendly way.

Added player in area check

 

Known Issues
None knew for now.

Legal
You are allowed to change what you want in this script.

  • Like 3

Share this post


Link to post
Share on other sites

Hey davidoss always looking for a cleanup script with good flexibility (: a damaged vehicles without crew gets deleted from your script but how much damage. Does your script have the ability to delete only heavily damaged vehicles or every vehicle that is damaged with no crew get deleted after a set time. Can you adjust the damage level in the mission like min damage 0.1 -.03 ; moderate damage 0.3- 0.6 severely damaged 0.7 -1. I would like to keep min and moderate damage vehicles on the mission. Can this be done with your script.

Where in your script can you set or adjust the delete time for damaged vehicles.

Share this post


Link to post
Share on other sites

Update to version 1.0 Final
 
Changelog

12/25/15
First release.

01/04/16
Version 1.0 Final

new:

* Possibility to adjust functionality.
* You can now define objects to delete and define damage threshold for vehicles.
* removing empty groups
 

Share this post


Link to post
Share on other sites

Typo line 120 & 219:

 

allMissionObjects "GroundWeaponHoder"

 

Should be GroundWeaponHolder.

Share this post


Link to post
Share on other sites

I have updated our archive as well with the version where you fixed the typo :)

news_download_a3_3.png

CleanUp script v1.0 final

** Armaholic now supports authors with donation button/links. If you have those please contact me!

Share this post


Link to post
Share on other sites

What about if I want to leave/exclude certain objects/containers for example a suitcase (intel) and an CSAT Ammo Crate from being cleaned up. Will this allow something like that?

Share this post


Link to post
Share on other sites

Thanks and sorry

I would not know what you have to be sorry about at all. Keep up the good work!  :cheers:

Share this post


Link to post
Share on other sites

What about if I want to leave/exclude certain objects/containers for example a suitcase (intel) and an CSAT Ammo Crate from being cleaned up. Will this allow something like that?

Something like that will be not removed by this script.

Share this post


Link to post
Share on other sites

I am trying to use this for the whole map.

 

I put the cleanup.sqf in my mission folder

 

I put the code in my init.sqf

if (isServer) then {

fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";

    [] spawn {

        while {true} do {        
            
            [] call fnc_cleanup;

        sleep 500;
        };
    };
};


I even put a trigger and or a gamelogic with this [] call fnc_cleanup;

 

 

I am still getting an error no script scripts\cleanup.sqf  not found.

Share this post


Link to post
Share on other sites

I can get the trigger method working  but how can I get the 

//or for whole map [] call fnc_cleanup;

Share this post


Link to post
Share on other sites

Oh do I need to put the cleanup.sqf into a script folder inside my main mission folder.

Test mission for cleanup.

mission folder.

Mission.sqf

Init.sqf - []call fnc_cleanup;

Scripts folder - (inside your cleanup.sqf)

I just have the cleanup.sqf inside the main mission folder.

Share this post


Link to post
Share on other sites

You can put the script where you want. Edit the path to fit correct path where the script are.

fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";
fnc_cleanup = compileFinal preprocessFileLineNumbers "cleanup.sqf";
fnc_cleanup = compileFinal preprocessFileLineNumbers "functions\cleanup.sqf";
fnc_cleanup = compileFinal preprocessFileLineNumbers "cleanup\cleanup.sqf";

Share this post


Link to post
Share on other sites

Let me get this straight.

If I put this in my mission init.sqf

fnc_cleanup = compileFinal preprocessFileLineNumbers "scripts\cleanup.sqf";

I then have to put your cleanup.sqf into a scripts folder inside the main mission folder and if I want it to be used for the whole map then I need to add this code to the mission init.sqf []call fnc_cleanup; as well.

I don't have to use a trigger or game logic. Sorry I am a little confused with all the options (: avibird

Share this post


Link to post
Share on other sites

For whole map

init.sqf

if (isServer) then {

fnc_cleanup = compileFinal preprocessFileLineNumbers "cleanup.sqf";


[] spawn {

    while {true} do { 

     [] call fnc_cleanup;

     sleep 500;
    };
 };
};

cleanup.sqf inside mission root directory where init.sqf.

Share this post


Link to post
Share on other sites

@ davidoss works very nice. Sorry I was have a hard time with the setup it was really very simple :) 

 

If I could give you some feed back.  I love the damaged vehicles damage threshold options. I don't know if you had it in your script before I asked for it on the third post of this thread but very cool for those mission when you need to capture vehicles for your own use or missions where the number of vehicles are limited by design.

 

I don't know if you are done with updates on this project but if not. time distance and abandoned options would be very nice and more people would use this script for sure.

 

1.Different times for deleting dead bodies vehicles weapons ect.

2.The delete function should be on hold if a player is not X meters away

3. Abandoned vehicles should be added to get deleted if X time with no crew inside.

 

Thank for the script and help getting it to work. I will do more testing on my CTI project I am working on to see if it meets my needs. Avibird 

Share this post


Link to post
Share on other sites

Hello i have a question about this script. Im making a mission where i want to avoid deleting certain dead units, is there a way to tell the script not to delete these?

 

Thanks for any answer.

Share this post


Link to post
Share on other sites

Update to version 1.1 Final
 
Changelog

12/25/15
First release.

01/04/16
Version 1.0 Final

* Possibility to adjust functionality.
* You can now define objects to delete and define damage threshold for vehicles.
* removing empty groups

 

02/17/16
Version 1.1 Final

 

* Set persistence for certain object.
 
To prevent remove of certain objects put in object init: 
this setVariable ["dnt_remove_me",true,false];
  • Like 1

Share this post


Link to post
Share on other sites

Wow this is amazing. thanks Davidoss. Really appreciate your work, have a awesome day.

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

×