Garry's Mod Wiki

Revision Difference

game.CleanUpMap#528308

<function name="CleanUpMap" parent="game" type="libraryfunc"> <description> If called serverside it will remove ALL entities which were not created by the map(not players or weapons held by players). If called serverside it will remove **ALL** entities which were not created by the map (not players or weapons held by players). On the client it will remove decals, sounds, gibs, dead NPCs, and entities created via <page>ents.CreateClientProp</page>. This function calls <page>GM:PreCleanupMap</page> before cleaning up the map and <page>GM:PostCleanupMap</page> after cleaning up the map. <bug issue="1142">Calling this in a <page>ENTITY:StartTouch</page> or <page>ENTITY:Touch</page> hook will crash the game.</bug> <bug issue="2874">Calling this destroys all BASS streams.</bug> <bug issue="3637">This can crash when removing _firesmoke entities.</bug>⤶ <bug issue="3637">This can crash when removing _firesmoke entities. **You can use the example below to workaround this issue.**</bug>⤶ </description> <realm>Shared</realm> <args> <arg name="dontSendToClients" type="boolean" default="false">If set to true, don't run this functions on all clients.</arg> <arg name="ExtraFilters" type="table" default="{}">Entity classes not to reset during cleanup.</arg> <arg name="dontSendToClients" type="boolean" default="false">If set to `true`, don't run this functions on all clients.</arg> <arg name="extraFilters" type="table" default="{}">Entity classes not to reset during cleanup.</arg> </args> </function> ⤶ <example>⤶ <description>Quick fix for issue [#3637](https://github.com/Facepunch/garrysmod-issues/issues/3637) (from [Garry's Mod Github](https://github.com/Facepunch/garrysmod-issues/issues/3637#issuecomment-702478260)).</description>⤶ <code>game.CleanUpMap( false, { "env_fire", "entityflame", "_firesmoke" } )</code>⤶ </example>