Headcrabless zombies

Hey guys I need a normal zombie for my server.

I have tried 2 addons which are ment to do it but one is only
client side and the other creates a custom entity which is much
laggier then the original zombie and can only be killed by
players weapons not props, if a prop is shot at it it will just
go straight through it, as well as it not giving cash when it is
killed in DarkRP which is easily fixed with about 5 lines of
code in its on death function while any other npc would work by default.

All it would need to do is remove the headcrabs model from the
normal zombie and stop the headcrab from spawning if the zombie
isn’t killed with a headshot.

Guys you could just make the script at “http://www.garrysmod.org/downloads/?a=view&id=73501” make clients download and use the materials instead of the default ones, I dont know how to overide materials though so I can’t do it my self.

Edit:it works if you install it on the client but if you put it on the server it will just remove all headcrabs from map but still leave the models on the normal zombies you just need to somehow make the clients download and use the file which basically tells the engine not to draw the models texture

Come on guys, I really need this for my server. I would do it my self but I am not sure how to make clients overide the default model and I need to do some more work on my rp map for the server.

If you look in the model viewer, the visible headcrab is controlled through a body group.

So, I think,

zombie:SetBodygroup( 1, 0 )

Where zombie is your zombie npc.

I think the headcrab would still spawn however :gonk:

Don’t worry about that tepholman I all ready have a way to get rid
of headcrabs that spawn after the zombie is killed on my server.
I will try that tomorrow kogitsune it is getting late here.

Guys can you see anything wrong with my code it seems to work but is there a way to make it only call once per zombie?
Or does it not matter if I call it over and over on the same npc.
The code is run on both the client and server.


local function RemoveCrabsModel()
    local zombies = table.Add( table.Add( table.Add( ents.FindByClass( "npc_zombie" ) )))

    for _, zombies in pairs( zombies ) do
                        
        zombies:SetBodygroup( 1, 0 )
    end
end
hook.Add( "Think", "No_Crabs_Models", RemoveCrabsModel )

Give your iterator a different name, it’s conflicting with your zombies table I think

Also, why the three table.Add’s?

[lua]local function RemoveCrabsModel()
for _, z in pairs( ents.FindByClass( “npc_zombie” ) ) do
z:SetBodygroup( 1, 0 )
end
end
hook.Add( “Think”, “No_Crabs_Models”, RemoveCrabsModel )[/lua]

Something like that should work

Edit: Although, I don’t think you need to call it every tick, that might lag the server somewhat. Try calling it whenever a player spawns an NPC, and just setting the bodygroup of that zombie

Is that what you mean by iterator and the table.add’s?
Yeah I don’t want it to run every tick, I was just testing it like this then I will add it into the npc spawn function.



local function RemoveCrabsModel()
    local Zombies = table.Add( ents.FindByClass( "npc_zombie" ) )

    for _, zombies in pairs( Zombies ) do
                        
        zombies:SetBodygroup( 1, 0 )
    end
end
hook.Add( "Think", "No_Crabs_Models", RemoveCrabsModel )


[lua]
local function Hide( npc )
if npc:IsNPC( ) and npc:GetClass( ) == “npc_zombie” then
timer.Simple( .5, pcall, npc.SetBodygroup, npc, 1, 0 )
end
end

hook.Add( “OnEntityCreated”, “NoHeadcrabs.OnEntityCreated”, Hide )
[/lua]

Thanks kogitsune :smiley: