Npc Killer

Why wont this remove any npc maker and or npc zombies etc?

[lua]
ent:Remove(“npc_maker”)
ent:Remove(“npc_zombie”)
ent:Remove(“npc_template_maker”)
ent:Remove(“npc_maker_template”)
[/lua]

maybe something like [lua]
for k, v in pairs(ents.GetAll()) do
if v:GetClass == “npc_maker” then
v:Remove()
end
end[/lua]

Why won’t it work? Because you are calling a method on the entity represented by the variable ent. This will ask the entity to remove itself and is a method that doesn’t take any arguments.

**[Entity.Remove

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Entity.Remove)**

tried

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

for k, v in pairs(ents.GetAll()) do
if v:GetClass == “npc_template_maker” then
v:Remove()
end
end

for k, v in pairs(ents.GetAll()) do
if v:GetClass == “npc_zombie” then
v:Remove()
end
end

for k, v in pairs(ents.GetAll()) do
if v:GetClass == “npc_maker_template” then
v:Remove()
end
end

[/lua] doesnt work.

GetClass()

you need a () near all the GetClass stuff

[editline]05:05PM[/editline]

[lua]local remove = {“npc_maker”, “npc_template_maker”, “npc_zombie”, “npc_maker_template”}
for k, v in pairs(ents.GetAll()) do
if table.HasValue(remove, v:GetClass()) then
v:Remove()
end
end[/lua]

You also can and should combine them :
[lua]for k, v in pairs(ents.GetAll()) do
if v:GetClass() == “npc_maker” or v:GetClass() == “npc_template_maker” or v:GetClass() == “npc_zombie” or v:GetClass() == “npc_maker_template” then
v:Remove()
end
end
[/lua]

Error :S

lua\autorun
pckiller.lua:3: function arguments expected near ‘==’

Code?

[lua] local remove = {“npc_maker”, “npc_template_maker”, “npc_zombie”, “npc_maker_template”}
for k, v in pairs(ents.GetAll()) do
if v:GetClass() == “npc_maker” or v:GetClass() == “npc_template_maker” or v:GetClass() == “npc_zombie” or v:GetClass() == “npc_maker_template” then
v:Remove()
end
end [/lua]

Looks fine fine put it in the /server/ folder.