Prop_physics Remover

Can someone make a script that (on server startup)
removes all [Prop_Physics] from the map?

I don’t know why you want it, but here.

[lua] hook.Add(“InitPostEntity”,“abracadabra”,function() for k, v in pairs(ents.GetAll()) do if v:GetClass() == “prop_physics” then v:Remove() end end)[/lua]

Would this go in autorun/server in my Server Files?

Yes.

Didn’t work. :saddowns:

Make sure its in a lua file. Make sure it ends in .lua.

It’s in the autorun as Propremover.lua

you asked the same question on the help thread and got the exact same answer!

you could just run this in the console:
“ent_remove_all prop_physics”

But he wants it to occur on server start up.

shared.lua


timer.Create( "PropRemover", 10, 0, function()
		RunConsoleCommand("ent_remove_all prop_physics" )
end )


Yes?

You could add that command to autorun :o

ent commands are blocked in RunConsoleCommand. And that code would give a “bad argument #1 to RunConsoleCommand”

ent_* command are all sv_cheats 1 anyway

Flapjack you’re a very experienced coder, is there anything wrong with what I suggested above?

Nothing wrong with it. Would be faster to use ipairs.

[editline]10:53PM[/editline]

[lua]local remove = {“prop_physics” , “prop_physics_multiplayer” , “prop_physics_respawnable”}

hook.Add(“InitPostEntity” , “Delay” , function()
for k , v in ipairs(ents.GetAll()) do
if table.HasValue(remove , v:GetClass()) then
v:Remove()
end
end
end )

hook.Add(“OnEntityCreated” , “DeleteAfterSpawn” , function(ent)
if table.HasValue(remove , v:GetClass()) then
v:Remove()
end
end )
[/lua]