SHOW:
|
|
- or go back to the newest paste.
1 | purge = { | |
2 | if(!isNull(_this)) then { | |
3 | _this enableSimulation false; | |
4 | _this removeAllMPEventHandlers "mpkilled"; | |
5 | _this removeAllMPEventHandlers "mphit"; | |
6 | _this removeAllMPEventHandlers "mprespawn"; | |
7 | _this removeAllEventHandlers "FiredNear"; | |
8 | _this removeAllEventHandlers "HandleDamage"; | |
9 | _this removeAllEventHandlers "Killed"; | |
10 | _this removeAllEventHandlers "Fired"; | |
11 | _this removeAllEventHandlers "GetOut"; | |
12 | _this removeAllEventHandlers "GetIn"; | |
13 | _this removeAllEventHandlers "Local"; | |
14 | clearVehicleInit _this; | |
15 | deleteVehicle _this; | |
16 | deleteGroup (group _this); | |
17 | _this = nil; | |
18 | }; | |
19 | }; | |
20 | ||
21 | if (isServer) then { | |
22 | [] spawn | |
23 | { | |
24 | waitUntil {!(isNil "sm_done")}; | |
25 | diag_log ["LinkCleaning CLEANUP Initialized"]; | |
26 | ||
27 | _lastlootcheck = diag_tickTime; | |
28 | _lastZombieClean = diag_tickTime; | |
29 | _lastGroupClean = diag_tickTime; | |
30 | _lastGullMod = diag_tickTime; | |
31 | _lastFixFps = diag_tickTime; | |
32 | ||
33 | while {true} do { | |
34 | if ((diag_tickTime - _lastlootcheck) > 180) then | |
35 | { | |
36 | _lastlootcheck = diag_tickTime; | |
37 | private ["_delQty","_nearby","_keep","_qty","_lootpiles","_ammobox"]; | |
38 | ||
39 | _ammobox = ["USLaunchersBox","RULaunchersBox","USSpecialWeapons_EP1","USVehicleBox"]; | |
40 | ||
41 | _lootpiles = allMissionObjects "ReammoBox"; | |
42 | _delQty = 0; | |
43 | { | |
44 | _keep = (_x getVariable ["permaLoot",false]) || (typeOf _x in _ammobox); | |
45 | if (!_keep) then { | |
46 | _nearby = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase","AllVehicles"], 130]); | |
47 | if (_nearby==0) then { | |
48 | deleteVehicle _x; | |
49 | sleep 0.025; | |
50 | _delQty = _delQty + 1; | |
51 | }; | |
52 | }; | |
53 | sleep 0.001; | |
54 | } forEach _missionObjs; | |
55 | if (_delQty > 0) then { | |
56 | _qty = count _lootpiles; | |
57 | diag_log (format["LinkCleaning: Deleted %1 Loot Piles out of %2",_delQty,_qty]); | |
58 | }; | |
59 | }; | |
60 | ||
61 | if ((diag_tickTime - _lastFixFps) > 180) then | |
62 | { | |
63 | _lastFixFps = diag_tickTime; | |
64 | _allstartlk = ((allMissionObjects "WeaponHolder")+(allMissionObjects "Sound_Flies")+(allDead)+([0,0,0] nearEntities ['CAAnimalBase', 10000000])); | |
65 | _countlk = count _allstartlk; | |
66 | - | diag_log format["LinkCleaning: Stop cleaning objects - %1",_countlk]; |
66 | + | diag_log format["LinkCleaning: Start cleaning objects - %1",_countlk]; |
67 | { | |
68 | if (!isNull _x) then | |
69 | { | |
70 | if (_x in vehicles) then {deletevehicle _x;}; | |
71 | _nearbylk1 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 450]); | |
72 | _keeplk = _x getVariable ["permaLoot",false]; | |
73 | if ((_nearbylk1 == 0) && (!_keeplk) && !(_x in alldead)) then | |
74 | { | |
75 | deleteVehicle _x; | |
76 | }; | |
77 | _nearbylk2 = {(isPlayer _x) and (alive _x)} count (_x nearEntities [["CAManBase"], 25]); | |
78 | if ((_nearbylk2 == 0) && (_x in alldead) && (_x isKindOf "zZombie_Base")) then | |
79 | { | |
80 | deleteVehicle _x; | |
81 | }; | |
82 | if ((_nearbylk2 == 0) && (_x isKindOf "CAAnimalBase")) then {deleteVehicle _x;}; | |
83 | }; | |
84 | } foreach _allstartlk; | |
85 | _countlktwo = count ((allMissionObjects "WeaponHolder")+(allMissionObjects "Sound_Flies")+(allDead)+([0,0,0] nearEntities ['CAAnimalBase', 10000000])); | |
86 | diag_log format["LinkCleaning: Stop cleaning objects - %1",_countlktwo]; | |
87 | }; | |
88 | ||
89 | if ((diag_tickTime - _lastZombieClean) > 180) then { | |
90 | _lastZombieClean = diag_tickTime; | |
91 | { | |
92 | if (local _x) then { | |
93 | private ["_pos","_delrndzed","_qty","_randomzeds","_nearby"]; | |
94 | ||
95 | _randomzeds = entities "zZombie_Base"; | |
96 | _delrndzed = 0; | |
97 | ||
98 | _x call purge; | |
99 | sleep 0.025; | |
100 | _delrndzed = _delrndzed + 1; | |
101 | } else { | |
102 | if (!alive _x) then { | |
103 | _pos = getPosATL _x; | |
104 | if (count _pos > 0) then { | |
105 | _nearby = {(isPlayer _x) and (alive _x)} count (_pos nearEntities [["CAManBase","AllVehicles"], 130]); | |
106 | if (_nearby==0) then { | |
107 | _x call purge; | |
108 | sleep 0.025; | |
109 | _delrndzed = _delrndzed + 1; | |
110 | }; | |
111 | }; | |
112 | }; | |
113 | }; | |
114 | sleep 0.001; | |
115 | } forEach _randomzeds; | |
116 | if (_delrndzed > 0) then { | |
117 | _qty = count_randomzeds; | |
118 | diag_log (format["LinkCleaning: Deleted %1 Zombies out of %2",_delrndzed,_qty]); | |
119 | }; | |
120 | ||
121 | ||
122 | if ((diag_tickTime - _lastGroupClean) > 360) then { | |
123 | _lastGroupClean = diag_tickTime; | |
124 | //Player Groups Cleanup | |
125 | if (count units _x==0) then { | |
126 | deleteGroup _x; | |
127 | _x = nil; | |
128 | }; | |
129 | } forEach allGroups; | |
130 | ||
131 | ||
132 | if ((diag_tickTime - _lastGullMod) > 180) then { | |
133 | _lastGullMod = diag_tickTime; | |
134 | _x call purge; | |
135 | } forEach entities "Seagull"; | |
136 | sleep 5; | |
137 | }; | |
138 | }; | |
139 | }; | |
140 | }; |