• EntityTakeDamage problem cant track the attacker ?
    2 replies, posted
[CODE] 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) [/CODE] 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. [CODE] [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 [/CODE] Please someone help me. I am trying to block damage by players.
You're trying to concat a entity value in a string value. [CODE].." attacker: "..dmg:GetAttacker().."")[/CODE] Replace this with: [CODE].." attacker: "..dmg:GetAttacker():GetName())[/CODE]
[QUOTE=Gedo789;49893821]You're trying to concat a entity value in a string value. [CODE].." attacker: "..dmg:GetAttacker().."")[/CODE] Replace this with: [CODE].." attacker: "..dmg:GetAttacker():GetName())[/CODE][/QUOTE] Ye I know I found the solution in a couple of minutes but thanks for the answer :D :D
Sorry, you need to Log In to post a reply to this thread.