EntityTakeDamage problem cant track the attacker ?



function hl2c_EntDmg( victim, dmg )
	if victim:IsNPC() and victim:IsValid() and dmg:GetAttacker():IsPlayer() then
		print("Victim: "..victim:GetClass().." took dmg: "..dmg:GetDamage().." attacker: "..dmg:GetAttacker().."")
	end
end
hook.Add("EntityTakeDamage", "hl2c_EntityTakeDamage", hl2c_EntDmg)


I am trying to get the attacker like shooting npc_alyx with crossbow, rpg, combineballs and grenades.
It always give me an error message I though the ulib does it but it is coming from the original lua modules.



[ERROR] gamemodes/half-life-2-campaign/gamemode/init.lua:678: attempt to concatenate a userdata value
  1. v - gamemodes/half-life-2-campaign/gamemode/init.lua:678
    2. unknown - lua/includes/modules/hook.lua:84


Please someone help me. I am trying to block damage by players.

You’re trying to concat a entity value in a string value.


.." attacker: "..dmg:GetAttacker().."")

Replace this with:


.." attacker: "..dmg:GetAttacker():GetName())

Ye I know I found the solution in a couple of minutes but thanks for the answer :smiley: :smiley: