Hello. I was trying to get a autorun script to work. Basically it checks if a ragdoll has been damaged, and if so, create an emitter blood effect. The problem is that it gives me an error related to the DamageInfo, and i cant figure out what is wrong.
Code:
local NPCsHitEffects = {
["npc_citizen"] = "bloodimpact",
["npc_combine"] = "bloodimpact",
["npc_antlion"] = "AntlionGib",
["npc_crow"] = "Sparks",
Default = "bloodimpact",
}
function RagdollEffect( Entity, Inflictor, Attacker, Amount, DamageInfo)
if (!string.find(Entity:GetClass(), "npc_") && !Entity:IsNPC() ) then return false; end
local Effect = EffectData()
local Origin = DamageInfo:GetDamagePosition()
Effect:SetOrigin( Origin )
Effect:SetScale( 1 )
if (NPCsHitEffects[Entity:GetClass()]) then
util.Effect( NPCsHitEffects[Entity:GetClass()], Effect )
else
util.Effect( NPCsHitEffects.Default, Effect )
end
end
hook.Add("EntityTakeDamage", "Ragdoll Effect", RagdollEffect)
Thanks!