DMS_CleanUp Improvements

It can now take groups as arguments
This commit is contained in:
eraser1 2015-08-29 13:30:26 -05:00
parent f8e48673c1
commit 38292a918e
2 changed files with 58 additions and 24 deletions

View File

@ -4,14 +4,14 @@
Usage:
[
_object1,
_object2,
_objectOrGroup1,
_objectOrGroup2,
...
_objectN
_objectOrGroupN
] call DMS_CleanUp;
Alternative Usage:
_object call DMS_CleanUp;
_objectOrGroup call DMS_CleanUp;
*/
@ -37,41 +37,75 @@ if ([_this,20] call DMS_isPlayerNearbyARRAY) exitWith //<-----Not sure if it's m
};
*/
private "_skippedObjects";
private ["_skippedObjects","_clean"];
_skippedObjects = [];
_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;
};
{
if ((typeName _x) isEqualTo "OBJECT") then {
if !([_x,DMS_CleanUp_PlayerNearLimit] call ExileServer_util_position_isPlayerNearby) then {
_x enableSimulationGlobal false;
_x removeAllMPEventHandlers "mpkilled";
_x removeAllMPEventHandlers "mphit";
_x removeAllMPEventHandlers "mprespawn";
_x removeAllEventHandlers "FiredNear";
_x removeAllEventHandlers "HandleDamage";
_x removeAllEventHandlers "Killed";
_x removeAllEventHandlers "Fired";
_x removeAllEventHandlers "GetOut";
_x removeAllEventHandlers "GetIn";
_x removeAllEventHandlers "Local";
deleteVehicle _x;
} else {
if ((typeName _x) isEqualTo "OBJECT") then
{
if (isNull _x) exitWith {};
if !([_x,DMS_CleanUp_PlayerNearLimit] call ExileServer_util_position_isPlayerNearby) then
{
_x call _clean;
}
else
{
_skippedObjects pushBack _x;
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG CleanUp :: Skipping cleanup for |%1|, player within %2 meters!",_this,DMS_CleanUp_PlayerNearLimit];
diag_log format ["DMS_DEBUG CleanUp :: Skipping cleanup for |%1|, player within %2 meters!",_x,DMS_CleanUp_PlayerNearLimit];
};
};
}
else
{
diag_log format ["DMS ERROR :: Attempted to call DMS_CleanUp on non-object %1 from array %2",_x,_this];
if ((typeName _x) isEqualTo "GROUP") exitWith
{
if (!isNull _x) then
{
// Group cleanup should only be called when mission times out, so no need to check for nearby players
{
_x call _clean;
false;
} count (units _x);
if(local _x)then
{
deleteGroup _x;
}
else
{
[groupOwner _x,"DeleteGroupPlz",[_x]] call ExileServer_system_network_send_to;
};
};
};
diag_log format ["DMS ERROR :: Attempted to call DMS_CleanUp on non- group or object %1 from array %2",_x,_this];
};
false;
} count _this;
if !(_skippedObjects isEqualTo []) then {
if !(_skippedObjects isEqualTo []) then
{
DMS_CleanUpList pushBack [_skippedObjects,diag_tickTime,30];
};

View File

@ -32,7 +32,7 @@ private ["_OK", "_useCustomGear", "_unarmed", "_type", "_customGear", "_unit", "
_OK = params
[
["_group",(createGroup DMS_banditSide),[grpNull]],
["_group",grpNull,[grpNull]],
["_pos",[0,0,0],[[]],[3]],
["_type","random",[""]],
["_difficulty","random",[""]],