A lua question

I want the “NORMAL” classic zombie corpses to when i shoot it will go away after 4 seconds. Here is my code. BUT it doesn’t seem to work since i dont know if model/zombie/classic.mdl is the right one i tried it but it didn’t work SO it may have something to do with the code…

timer.Create(“timer2”,4,0,function()
for k,v in pairs(ents.GetAll()) do
if ValidEntity(v) && v:GetClass() == “prop_physics” && v:GetModel() == “models\Zombie\Classic.mdl” then
v:Remove()
end
end
end)

  1. I think you should do models/zombie/classic.mdl
    But I can’t tell you exactly whats wrong there. But try what I said.

Please use the [noparse][lua][/noparse] tags.

Its class is a prop_ragdoll, not a prop_physics.

The path is correct, and its not case-sensitive.

You will get more help in Questions subform.
Please use lua tags when posing code.

Hm still aint working…

[lua]
if v:GetClass() == “npc_zombie” then
– do stuff
end
[/lua]

Are you trying to remove clientside (the default death ragdolls) or serverside ones?
The code needs to be executed on either side accordingly.

timer.Create(“timer2”,4,0,function()
for k,v in pairs(ents.GetAll()) do
if ValidEntity(v) && v:GetClass() == “prop_ragdoll” && v:GetModel() == “models/Zombie/Classic.mdl” then
v:Remove()
end
end
end)

and how do i put that in there :<

You don’t because the code he gave you doesn’t really make sense.

I assume you are just trying to get rid of the default corpses created on death, which are only created on the client.
Those can’t be fetched using ents.GetAll(), but theres a different method on retrieving them.

[lua]
for k,v in pairs(player.GetAll()) do
if (v:GetRagdollEntity():GetModel() == “models/player/Classic.mdl”) then
v:GetRagdollEntity():Remove()
end
end
[/lua]

Oops typed the wrong thing.

I updated my code.

Timer Error: [gamemodes\mygamemode\gamemode\init.lua:86] attempt to index a nil value

timer.Create(“timer2”,4,0,function()
for k,v in pairs(player.GetAll()) do
if (v:GetRagdollEntity():GetModel() == “models/Zombie/Classic.mdl”) then
v:GetRagdollEntity():Remove()
end
end
end)

:<

That’s the Serverside Lua file, you gotta execute the code Clientside.

and how do i do that?

Fuck ignore this I fail @ reading.

[lua]
hook.Add(“OnEntityCreated”,“remove zombies”,function(ent)

if ((SERVER and ent:GetClass() == "prop_ragdoll") or (CLIENT and ent:GetClass() == "class C_ClientRagdoll")) then
    if (ent:GetModel() == "models/zombie/classic.mdl") then
        ent:Remove()
    end
end         

end)
[/lua]
Put the file in lua/autorun