I have this:
if CLIENT then
local ragdoll = ClientsideRagdoll( "models/Gibs/Fast_Zombie_Legs.mdl" )
ragdoll:SetNoDraw( false )
ragdoll:DrawShadow( true )
ragdoll:SetPos(t:GetPos())
end
Being called in this:
hook.Add( "EntityTakeDamage", "ddlNewHealthArmorSystems", function( t, dmg )
It doesn't seem to be doing anything.
I haven't written a code to remove it yet, so I know I'm currently collecting garbage but I'll fix that soon.
I think EntityTakeDamage is SERVER only... so that's probably why.
So what happened is, the default engine's methods of splitting a zombie after blast damage is not good enough for me on higher zombie levels in the gamemode I'm trying to create. Because of this, I tried to write my own script to split the zombies.
That whole thing starts with
if dmg:IsDamageType(DMG_BLAST) then
local rand1 = math.random(1,t:Health())
local rand2 = math.random(1,dmg:GetDamage())
if rand1 < rand2 then
So what's a good way where I can guarantee when a zombie splits, because all of my code is working flawlessly right now, that a legs ragdoll will be created?
You're correct, EntityTakeDamage is serverside so you'd have to network it to clients. Here's some example serverside code:
util.AddNetworkString("ZombieSplit")
hook.Add("EntityTakeDamage", "ZombieSplitNetwork", function(ent, dmg)
if ent is zombie then
net.Start("ZombieSplit")
net.WriteEntity(ent)
net.Broadcast()
end
end)
This needs to be modified to properly check if the entity is a zombie (use GetClass).
Thanks! So... can I do the code I originally posted in the receive hook? (Should I receive in think?)
It shouldn't, another thing I left out that would be important is to set a flag on the zombie that you've split it, so you don't end up networking it multiple times.
Sorry, you need to Log In to post a reply to this thread.