2015-08-28 21:52:56 +00:00
|
|
|
/*
|
|
|
|
DMS_CleanUp
|
|
|
|
Created by eraser1
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
[
|
2015-08-29 18:30:26 +00:00
|
|
|
_objectOrGroup1,
|
|
|
|
_objectOrGroup2,
|
2015-08-28 21:52:56 +00:00
|
|
|
...
|
2015-08-29 18:30:26 +00:00
|
|
|
_objectOrGroupN
|
2015-08-28 21:52:56 +00:00
|
|
|
] call DMS_CleanUp;
|
|
|
|
|
|
|
|
Alternative Usage:
|
2015-08-29 18:30:26 +00:00
|
|
|
_objectOrGroup call DMS_CleanUp;
|
2015-08-28 21:52:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-08-27 07:44:23 +00:00
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
2015-08-28 21:52:56 +00:00
|
|
|
diag_log ("DMS_DEBUG CleanUp :: CLEANING UP: "+str _this);
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
2015-08-28 21:52:56 +00:00
|
|
|
|
2015-08-30 00:33:32 +00:00
|
|
|
if !((typeName _this) == "ARRAY") then
|
2015-08-27 07:44:23 +00:00
|
|
|
{
|
2015-08-28 21:52:56 +00:00
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log ("DMS_DEBUG CleanUp :: Converting single object into array: "+str _this);
|
|
|
|
};
|
2015-08-27 07:44:23 +00:00
|
|
|
_this = [_this];
|
|
|
|
};
|
2015-08-28 21:52:56 +00:00
|
|
|
|
|
|
|
|
2015-08-28 05:27:02 +00:00
|
|
|
/*
|
|
|
|
if ([_this,20] call DMS_isPlayerNearbyARRAY) exitWith //<-----Not sure if it's more/less efficient
|
2015-08-27 07:44:23 +00:00
|
|
|
{
|
|
|
|
[30, DMS_CleanUp, _this, false] call ExileServer_system_thread_addTask;
|
|
|
|
};
|
2015-08-28 05:27:02 +00:00
|
|
|
*/
|
2015-08-28 21:52:56 +00:00
|
|
|
|
2015-08-29 18:30:26 +00:00
|
|
|
private ["_skippedObjects","_clean"];
|
2015-08-28 22:52:58 +00:00
|
|
|
|
|
|
|
_skippedObjects = [];
|
|
|
|
|
2015-08-29 18:30:26 +00:00
|
|
|
_clean =
|
|
|
|
{
|
|
|
|
_this enableSimulationGlobal 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";
|
|
|
|
deleteVehicle _this;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-08-27 07:44:23 +00:00
|
|
|
{
|
2015-08-30 00:33:32 +00:00
|
|
|
if ((typeName _x) == "OBJECT") then
|
2015-08-29 18:30:26 +00:00
|
|
|
{
|
|
|
|
if (isNull _x) exitWith {};
|
|
|
|
|
|
|
|
if !([_x,DMS_CleanUp_PlayerNearLimit] call ExileServer_util_position_isPlayerNearby) then
|
|
|
|
{
|
|
|
|
_x call _clean;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-28 22:52:58 +00:00
|
|
|
_skippedObjects pushBack _x;
|
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
2015-08-29 18:30:26 +00:00
|
|
|
diag_log format ["DMS_DEBUG CleanUp :: Skipping cleanup for |%1|, player within %2 meters!",_x,DMS_CleanUp_PlayerNearLimit];
|
2015-08-28 22:52:58 +00:00
|
|
|
};
|
2015-08-28 21:52:56 +00:00
|
|
|
};
|
2015-08-28 22:52:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-30 00:33:32 +00:00
|
|
|
if ((typeName _x) == "GROUP") exitWith
|
2015-08-29 18:30:26 +00:00
|
|
|
{
|
|
|
|
if (!isNull _x) then
|
|
|
|
{
|
2015-08-31 04:51:06 +00:00
|
|
|
// Group cleanup should only be called when it has to be deleted regardless, so no need to check for nearby players
|
2015-08-29 18:30:26 +00:00
|
|
|
{
|
|
|
|
_x call _clean;
|
|
|
|
false;
|
|
|
|
} count (units _x);
|
|
|
|
|
|
|
|
if(local _x)then
|
|
|
|
{
|
|
|
|
deleteGroup _x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[groupOwner _x,"DeleteGroupPlz",[_x]] call ExileServer_system_network_send_to;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-08-31 07:52:46 +00:00
|
|
|
if ((typeName _x) == "ARRAY") exitWith
|
|
|
|
{
|
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS_DEBUG CleanUp :: Doing recursive call for ARRAY: %1",_x];
|
|
|
|
};
|
|
|
|
_x call DMS_CleanUp;
|
|
|
|
};
|
2015-08-29 18:30:26 +00:00
|
|
|
diag_log format ["DMS ERROR :: Attempted to call DMS_CleanUp on non- group or object %1 from array %2",_x,_this];
|
2015-08-28 05:27:02 +00:00
|
|
|
};
|
2015-08-28 22:52:58 +00:00
|
|
|
|
2015-08-27 07:44:23 +00:00
|
|
|
false;
|
2015-08-28 22:52:58 +00:00
|
|
|
} count _this;
|
|
|
|
|
2015-08-29 18:30:26 +00:00
|
|
|
|
|
|
|
if !(_skippedObjects isEqualTo []) then
|
|
|
|
{
|
2015-08-28 22:52:58 +00:00
|
|
|
DMS_CleanUpList pushBack [_skippedObjects,diag_tickTime,30];
|
|
|
|
};
|