I’ve made a poison zombie torso but the problem is when you kill it or it kills you it says “Poison Zombie” not “Poison Zombie Torso” and I don’t know how to fix this in this case?
Here’s my code
local nextName
local tbNPCs = {}
hook.Add("PlayerSpawnNPC","npc_poisonzombie_torso_spawn",function(pl,name,wepName) nextName = name end)
hook.Add("PlayerSpawnedNPC","npc_poisonzombie_torso_model",function(pl,npc)
if(!nextName) then return end
if(tbNPCs[nextName]) then npc:SetModel(tbNPCs[nextName]) end
nextName = nil
end)
local function AddNPC(category,name,class,model,keyvalues,skin)
list.Set("NPC","npc_poisonzombie_torso",{Name = name,Class = class,Skin = skin,Model = model,Category = category,KeyValues = keyvalues})
tbNPCs["npc_poisonzombie_torso"] = model
end
AddNPC("Zombies + Enemy Aliens","Poison Zombie Torso","npc_poisonzombie","models/zombie/poison_torso.mdl",{["crabcount"] = 3},4)
hook.Add( "OnEntityCreated", "npc_poisonzombie_torso_fx", function( ent )
if ent:IsNPC() then
timer.Simple( 0, function() if ent:IsValid() and ent:GetClass() == "npc_poisonzombie" and ent:GetModel() == "models/zombie/poison_torso.mdl" then ent:SetSkin(3) ent:SetCollisionBounds(Vector(-4,-4,0), Vector(4,4,27)) ent:SetSequence(1) ent:SetName("Poison Zombie Torso") end end )
end
end)
hook.Add("OnNPCKilled", "npc_poisonzombie_torso_death", function(victim, Inflictor, killer)
if victim:GetName() == "Poison Zombie Torso" then
victim:SetModel("models/zombie/poison_torso.mdl")
victim:SetSkin(4)
end
end)
I’ve tried putting language.Add(“Poison Zombie Torso”) in the OnEntityCreated part but it doesn’t work