remove props by lua

hello , is there a way to remove props via lua in maps?

cause i want to remove some props from a map

//Thx :froggonk:


(User was banned for this post ("Wrong section" - mahalis))

[lua]
for k,v in pairs(ents.GetAll()) do
if ( v:GetClass() == “prop_physics_override” ) then
v:Remove() // Bai
end
end
[/lua]
would delete all prop_physics_override entities.

but how do i select a prop? xD

Lots of different ways.

[lua]
player.GetAll()[1]:GetEyeTrace().Entity:Remove()
[/lua]

Take a look at the wiki for references.

What kind of props do you want to select?

-snip-

prop_physic_multiplayer

and

func_button

[lua]
for k,v in pairs(ents.GetAll()) do
if ( v:GetClass() == “prop_physics_multiplayer” || v:GetClass() == “func_button” ) then
v:Remove() // Bai
end
end
[/lua]

will that remove every buttons and props?

Yes.

where do i put it btw?

lua/server/myfile.lua

didnt work :frowning:

[lua]

local types = { “prop_physics”, “prop_dynamic”, “func_shitdick”, “etc” }

for k,v in pairs( types ) do
for c,d in pairs( ents.FindByClass( v ) ) do
d:Remove()
end
end[/lua]

i made a file in lua/autorun/server/remove.lua with that code but it didnt work :’(

Put it in the GM:InitializePostEntity hook (or whatever it’s named).

[editline]11:17PM[/editline]


local types = { "prop_physics", "prop_dynamic", "prop_vehicle" }

for k,v in pairs( types ) do
  for c,d in pairs( ents.FindByClass( v ) ) do
    d:Remove()
  end
end
hook.Add( "InitPostEntity", "MapStartTrigger", Init_TriggerLogic )

im trying that.

[editline]12:22AM[/editline]

can someone be nice and copy the whole code for me?

//Thx

you need to put it inside a function that you’re hooking.

[lua]
function RemoveShit()
// put the original code here
end
hook.Add( “InitPostEntity”, “fuck my slutty asshole”, RemoveShit )[/lua]

-snip- found it. Env_fire