Map Cleaner strips a map of the entities that get in the way of roleplay. Once the map has loaded, and again after every map cleanup, the plugin removes the entities created by the map whose class matches one of the patterns of the 'remove_map_classes' config: health and suit chargers, weapons, ammo, health kits and batteries by default. A pattern is an entity class in which * stands for any number of characters, so weapon_* covers every weapon. The 'remove_map_physics' config adds the physics props of the map (prop_physics*) to that and 'remove_map_vehicles' its vehicles (prop_vehicle*, which includes the seats built into the map); both are off by default. A change of these configs applies the next time the map is loaded or cleaned up.

Only entities created by the map are ever removed. Whatever players, the framework or other plugins have spawned is left alone, and so is a weapon of the map that a player has picked up.

The MapCleanerShouldRemove hook decides about single entities: a schema uses it to keep an entity whose class is on the list, or to remove one that is not, which is how fixes for a particular map are made. PostMapClean runs after every pass.

function SCHEMA:MapCleanerShouldRemove(entity, ent_class, matched)
  if ent_class == 'func_button' and entity:GetName() == 'gunstore' then
    return true
  end
end

Summary

Hooks

Removes the unwanted entities of the map once all of its entities have been created.
Removes the unwanted entities again after a map cleanup has put them back.

Methods

Checks whether the plugin is allowed to remove an entity at all.
Checks whether an entity class matches one of the class patterns.
clean()server
Removes the unwanted entities of the map: every entity created by the map for which MapCleaner:should_remove says so.
Returns the class patterns that are currently in effect: the entries of the 'remove_map_classes' config, followed by prop_physics* if 'remove_map_physics' is on and by prop_vehicle* if 'remove_map_vehicles' is on.
Decides whether an entity is to be removed from the map.

Hooks

MapCleaner:InitPostEntity()

server plugins/mapcleaner/plugin/sv_hooks.lua:5

Removes the unwanted entities of the map once all of its entities have been created.

MapCleaner:PostCleanupMap()

server plugins/mapcleaner/plugin/sv_hooks.lua:10

Removes the unwanted entities again after a map cleanup has put them back.

Methods

MapCleaner:can_remove(entity)

server plugins/mapcleaner/plugin/sv_plugin.lua:93

Checks whether the plugin is allowed to remove an entity at all. It is not if the entity was not created by the map, which covers everything that players, the framework and plugins have spawned, if it is a player, or if it is a weapon that somebody carries. Serverside only.

Parameters

  • entity Entity

Returns

  • Boolean

MapCleaner:class_matches(ent_class, patterns)

server plugins/mapcleaner/plugin/sv_plugin.lua:71

Checks whether an entity class matches one of the class patterns. The comparison ignores case. Serverside only.

MapCleaner:class_matches('weapon_smg1', { 'weapon_*' })
-- true

MapCleaner:class_matches('prop_physics', { 'weapon_*', 'item_battery' })
-- false

Parameters

  • ent_class String entity class
  • patterns List<String> optional, defaults to MapCleaner:get_patterns() class patterns in lower case, as MapCleaner:get_patterns returns them; * stands for any number of characters

Returns

  • Boolean

Removes the unwanted entities of the map: every entity created by the map for which MapCleaner:should_remove says so. Runs the PostMapClean hook when done. Serverside only. The plugin calls this once the map has loaded and after every map cleanup.

Returns

  • Number how many entities have been removed

MapCleaner:get_patterns()

server plugins/mapcleaner/plugin/sv_plugin.lua:31

Returns the class patterns that are currently in effect: the entries of the 'remove_map_classes' config, followed by prop_physics* if 'remove_map_physics' is on and by prop_vehicle* if 'remove_map_vehicles' is on. Serverside only.

Returns

  • List<String> class patterns in lower case, * stands for any number of characters

MapCleaner:should_remove(entity, matched)

server plugins/mapcleaner/plugin/sv_plugin.lua:113

Decides whether an entity is to be removed from the map. Entities that the plugin may not remove (see MapCleaner:can_remove) never are; for the others the MapCleanerShouldRemove hook has the last word, and without an answer from it the entity is removed if its class matches. Serverside only.

Parameters

  • entity Entity
  • matched Boolean optional, defaults to nil whether the class of the entity counts as matching; checked against the patterns in effect if nil

Returns

  • Boolean

Defined in