game.CleanUpMap
game.CleanUpMap( boolean dontSendToClients = false, table extraFilters = {}, function callback = nil )
Description
If called serverside it will remove ALL entities which were not created by the map (not players or weapons held by players).
It won't remove Entities who have the EFL_KEEP_ON_RECREATE_ENTITIES Flag set.
On the client it will remove decals, sounds, gibs, dead NPCs, and entities created via ents.CreateClientProp.
This function calls GM:PreCleanupMap before cleaning up the map and GM:PostCleanupMap after cleaning up the map.
Beware of calling this function in hooks that may be called on map clean up (such as ENTITY:StartTouch) to avoid infinite loops.
This can crash when removing
Issue Tracker: 3637
_firesmoke
entities. You can use the example below to workaround this issue.Issue Tracker: 3637
Arguments
3 function callback = nil
If set, delays the map cleanup until the end of a server tick, allowing bypassing the entity limit on maps with large amounts of them. Otherwise the entities will not be cleaned up until the end of the server tick.
The callback function will be called after the map cleanup has been performed.
Example
Quick fix for issue #3637 (from Garry's Mod Github).