How to make persistent props not removing when cleanup?

When i start server there are some entities and screens that spawn…
When i do server cleanup they dissapier… how to make not to dissapier when cleanup ?

Sorry about bad english skills… Hope you understand what i mean.

What do you mean, screens?

anyway, the best way of doing this is by remaking your own.

Scan every entity then check if the entity is not on a table. If it isn’t, remove it.

There, theres a hit to start you off. When you do make it, make sure its serverside

I mean … when i do cleanup my all perm screens … slotmachine… bank vault dissapier…

Im guessing you havnt made a lua script before.

I would post a script to start you off, but i am not currently on my computer, im sure some kind lad will help you out here.

There may be a better way to do this, but I’d roughly do something like



local EntitiesToSave = {
"prop_physics",
"prop_dynamic" -- whatever the entities are called
}

for k, v in pairs(ents.GetAll()) do
if not table.HasValue(EntitiesToSave, v) then
v:Remove()
end
end


I wouldn’t do that because it’s bad coding practice to choose table.HasValue when you can easily switch to a better method. The reason we don’t use table.HasValue is because as the table you are checking grows in size, table.HasValue decreases in performance.



local EntitiesToSave = {
	prop_physics = true,
	prop_dynamic = true -- whatever the entities are called
}

for k, v in pairs(ents.GetAll()) do
	if not EntitiesToSave[v:GetClass()] then
		v:Remove()
	end
end


We remove the quotes from the table because in a dictionary-style table in Lua you have to.
The difference here is instead of iterating over the table (see table.HasValue’s source) and checking values, we simply implement a table where indexing the string of an entity’s class that we want to keep will return true. Other entities will return nil which evaluates to false. Since indexing a Lua table is O(1), we’re good for tables of any size.