Page MenuHomeFeedback Tracker

deleteVehicle in allmissionobjects wont work after few run
New, NormalPublic

Description

I'm moderating my own Liberation mission server.
and I realized that cleaner in my mission wont work very well.
so I made my own cleaning script for better performance.

I made script scan all objects in map and delete all unusable object like Ruins, Weapon holder, and dead body using allmissionobjects.

this script - specially using allmissionobjects part - wont work after few run(around 4~5 times)

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
Windows server 2016
Category
Scripting
Steps To Reproduce
[] spawn {
    private ["_WeaponHolder","_StaticWeapon","_Ruins"];
    
    sleep 120;

fn_checkDistance ={
	private["_limitDistance","_units","_object","_bool"];
	_limitDistance = _this select 0;
	_units = _this select 1;
	_object = _this select 2;
	_bool = false;
	
	_units = [_units,{((_x distance _object) < _limitDistance) && isPlayer _x}] call BIS_fnc_conditionalSelect;
	if(count(_units) == 0) then {
		_bool = true;
	};
	if(count([] call F_getNearestFob) > 0) then {
		if((_object distance ([] call F_getNearestFob)) < 125) then{
			_bool = true;
		};
	};
	_bool
};
private["_playerUnit"];

while{true} do {
	_playerUnit = (playableUnits + switchableUnits);

	if ((count(_playerUnit)) >= 20) then {
		sleep 100;
	} else {
		sleep 240;
	};

	{
		deleteVehicle _x;
	} forEach allDead;

	{
		if(!(isPlayer _x) && (surfaceIsWater position _x) && ((position _x) select 2) < 1) then {
			deleteVehicle _x;
		};
	} forEach allUnits;

	_WeaponHolder = allMissionObjects "WeaponHolder";
	diag_log format["WeaponHolder : %1", _WeaponHolder];
	{
		if([600,_playerUnit,_x] call fn_checkDistance) then {
			deleteVehicle _x;
		};
	} forEach _WeaponHolder;
	
	{
		if([1200,_playerUnit,_x] call fn_checkDistance) then {
			deleteVehicle _x;
		};
	} forEach allMines;
	
	_Ruins = allMissionObjects "Ruins";
	diag_log format["Ruins : %1", _Ruins];

	{
		if([1200,_playerUnit,_x] call fn_checkDistance) then {
			deleteVehicle _x;
		};
	} forEach _Ruins;
	
	{
		if ((_x distance [0,0,0]) < 1) then {
			deleteVehicle _x;
		};
	} forEach (allMissionObjects "EmptyDetector");

	{
		if (count(units(_x)) == 0) then { 
        		deleteGroup(_x);
		};
	} forEach allGroups;
	
	diag_log "Cleaner Done.";
};
};

Event Timeline

Arizen created this task.Jul 28 2019, 4:51 PM
Arizen updated the task description. (Show Details)Jul 28 2019, 5:03 PM