2015-08-28 21:52:56 +00:00
|
|
|
/*
|
2015-09-05 03:40:00 +00:00
|
|
|
DMS_fnc_CleanUp
|
2015-08-28 21:52:56 +00:00
|
|
|
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-09-05 03:40:00 +00:00
|
|
|
] call DMS_fnc_CleanUp;
|
2015-08-28 21:52:56 +00:00
|
|
|
|
|
|
|
Alternative Usage:
|
2015-09-05 03:40:00 +00:00
|
|
|
_objectOrGroup call DMS_fnc_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
|
|
|
{
|
|
|
|
_this = [_this];
|
|
|
|
};
|
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 =
|
|
|
|
{
|
2015-10-04 03:32:42 +00:00
|
|
|
{
|
|
|
|
detach _x;
|
|
|
|
_x call _clean;
|
|
|
|
} forEach (attachedObjects _x);
|
2015-08-29 18:30:26 +00:00
|
|
|
_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 {};
|
|
|
|
|
2015-09-05 06:03:20 +00:00
|
|
|
if !([_x,DMS_CleanUp_PlayerNearLimit] call DMS_fnc_IsPlayerNearby) then
|
2015-08-29 18:30:26 +00:00
|
|
|
{
|
|
|
|
_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;
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach (units _x);
|
2015-08-29 18:30:26 +00:00
|
|
|
|
|
|
|
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];
|
|
|
|
};
|
2015-09-05 03:40:00 +00:00
|
|
|
_x call DMS_fnc_CleanUp;
|
2015-08-31 07:52:46 +00:00
|
|
|
};
|
2015-09-05 03:40:00 +00:00
|
|
|
diag_log format ["DMS ERROR :: Attempted to call DMS_fnc_CleanUp on non- group or object %1 from array %2",_x,_this];
|
2015-08-28 05:27:02 +00:00
|
|
|
};
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach _this;
|
2015-08-28 22:52:58 +00:00
|
|
|
|
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];
|
|
|
|
};
|