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: Usage:
[ [
_object1, _objectOrGroup1,
_object2, _objectOrGroup2,
... ...
_objectN _objectOrGroupN
] call DMS_CleanUp; ] call DMS_CleanUp;
Alternative Usage: 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 = []; _skippedObjects = [];
_clean =
{ {
if ((typeName _x) isEqualTo "OBJECT") then { _this enableSimulationGlobal false;
if !([_x,DMS_CleanUp_PlayerNearLimit] call ExileServer_util_position_isPlayerNearby) then { _this removeAllMPEventHandlers "mpkilled";
_x enableSimulationGlobal false; _this removeAllMPEventHandlers "mphit";
_x removeAllMPEventHandlers "mpkilled"; _this removeAllMPEventHandlers "mprespawn";
_x removeAllMPEventHandlers "mphit"; _this removeAllEventHandlers "FiredNear";
_x removeAllMPEventHandlers "mprespawn"; _this removeAllEventHandlers "HandleDamage";
_x removeAllEventHandlers "FiredNear"; _this removeAllEventHandlers "Killed";
_x removeAllEventHandlers "HandleDamage"; _this removeAllEventHandlers "Fired";
_x removeAllEventHandlers "Killed"; _this removeAllEventHandlers "GetOut";
_x removeAllEventHandlers "Fired"; _this removeAllEventHandlers "GetIn";
_x removeAllEventHandlers "GetOut"; _this removeAllEventHandlers "Local";
_x removeAllEventHandlers "GetIn"; deleteVehicle _this;
_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; _skippedObjects pushBack _x;
if (DMS_DEBUG) then 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 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; false;
} count _this; } count _this;
if !(_skippedObjects isEqualTo []) then {
if !(_skippedObjects isEqualTo []) then
{
DMS_CleanUpList pushBack [_skippedObjects,diag_tickTime,30]; DMS_CleanUpList pushBack [_skippedObjects,diag_tickTime,30];
}; };

View File

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