How to use game.CleanUpMap "Extra Filters" with entities inserted into table?
2 replies, posted
I currently have a setup system where when a certain entity is spawned (in this case a car), it gets inserted into a table called garageCars (not ExtraFilters, which is seen in my code below) with table.insert. I don't want them to be cleaned up when game.CleanUpMap is called. Here is my code for anyone that is interested:
--Top of script:
local ExtraFilters = {"prop_vehicle_airboat", "prop_dynamic", "info_spawn_vehicle", "info_vehicle_spawn", "trigger_checkpoint", "scoreboard_draw", "ent_scoreboard"} --I would like to put the "garageCars" table into here, but that dosen't work.
--Somewhere in the middle:
game.CleanUpMap(false, ExtraFilters )
--I want to add a table to the ExtraFilters table so that it knows not to clean up some of the entities (which were added to the table).
Any help would be greatly appreciated!
<3
That simply isn't how CleanupMap works. It only takes a list of entity classes, not actual entities. You can add the class names of all the relevant cars to ExtraFilters, but then it also would not clean up any such cars that exist but weren't spawned by the garage. Something like that would go as follows:
local ExtraFilters = {"prop_vehicle_airboat", "prop_dynamic", "info_spawn_vehicle", "info_vehicle_spawn", "trigger_checkpoint", "scoreboard_draw", "ent_scoreboard"}
for k, v in pairs(garageCars) do
if (!v:IsValid()) then continue end
table.insert(ExtraFilters, v:GetClass())
end
game.CleanUpMap(false, ExtraFilters)
Any other solution would involve devising a method of saving each car and then respawning them properly after the cleanup has completed. That's probably what @Kevlon was getting at with his post as you'd ideally use those two hooks.
Sorry, you need to Log In to post a reply to this thread.