How to remove a handful of different point entities on map start?
5 replies, posted
Hello,
I would like to have an autorun script that removes different point entities (ie. env_fire, env_blood, etc) on map load/start.
Can anyone help me with the script?
Thank you.
[lua]
local kill = {"env_fire","env_blood"} //Add entity classes here
hook.Add("InitPostEntity","RemoveSomePointEntities",function()
for k,v in pairs(kill) do
local ents = ents.FindByClass(v)
for i = 1,#ents do
ents[i]:Remove()
end
end
end)
[/lua]
Thank you!
Can I also remove by property name?
[QUOTE=-X-;36431307]Thank you!
Can I also remove by property name?[/QUOTE]
By that, do you mean an object that has a name set for it, or, say, this object has this property set to true?
[QUOTE=skullorz;36431521]By that, do you mean an object that has a name set for it, or, say, this object has this property set to true?[/QUOTE]
The object has a name set.
Thank you.
[lua]
local killents = {"env_fire","env_blood"} //Add entity classes here
local killnames = {"ent1","ent2"} //Fill in names here
hook.Add("InitPostEntity","RemoveSomePointEntities",function()
for k,v in pairs(killents) do
local enttable = ents.FindByClass(v)
for i = 1,#enttable do
enttable[i]:Remove()
end
end
for k,v in pairs(killnames) do
local enttable = ents.FindByName(v)
for i = 1,#enttable do
enttable[i]:Remove()
end
end
end)
[/lua]
Sorry for not tabbing it, I wrote from the browser.
Sorry, you need to Log In to post a reply to this thread.