IsDamageType() and IsFallDamage()

Hello! I have a problem.


function dmg(ent, dmginfo)
if dmginfo:IsFallDamage() then
print("Ok")
end
end
hook.Add( "EntityTakeDamage", "playerhurt", dmg )

This code doesn’t work. I also tryed dmginfo:IsDamageType(DMG_FALL)
But I tryed other functions (dmginfo:GetAttacker( ), dmginfo:SetDamage(), etc) and they work fine.
What’s wrong? My gamemode is TTT.
Thank you.

Thank you. And what about burn damage and explosion damage?

[editline]1st July 2013[/editline]

Also I can’t get fall damage using this hook.

Can anyone help me please?

One way to nullify fall damage (as well as any other kind of damage) is through a EntityShouldTakeDamage hook within a EntityTakeDamage hook.

Here’s a little something I threw together.

[lua]
function FallDmg(ent, inflictor, attacker, amount, dmginfo)
if ent:IsPlayer() then
if dmginfo:IsFallDamage() then
function GM:PlayerShouldTakeDamage(victim, attacker)
return false
end
end
end

hook.Add(“EntityTakeDamage”, “NullifyFallDamage”, FallDmg)
[/lua]

EntityTakeDamage hook now send only 2 arguments I think. Also, as I said, dmginfo:IsFallDamage() doesn’t work for me because of unknown reason.

It doesn’t work for you? What kind of error does it give?

No error at all. See code in the first post. When I get fall damage, no “OK” message in console.

I just tested your original code, and it worked fine for me. This most likely means that you have something else in the rest of your code that’s interfering with the EntityTakeDamage hook, or some other hook that deals with damage. For example, your code wouldn’t work in another one of my gamemodes until I commented out a GM:GetFallDamage hook.

Mind posting the rest? Or is it outrageously long/complex/secret?

Did you test it in TTT gamemode? Code looks like:


function adddmg(ent,dmginfo)
print("hook called")
if dmginfo:GetAttacker( ) and IsValid(dmginfo:GetAttacker( )) and dmginfo:GetAttacker( ):IsPlayer() and ent and IsValid(ent) and ent:IsPlayer() then
print("Debug 1")
if ent:IsSuperAdmin() then
dmginfo:SetDamage(0) --it works
print("Debug 2")
end
--some other things like previous here that work
if dmginfo:IsFallDamage() then
dmginfo:SetDamage(0) --it doesn't work
print("Debug 3")
end
if dmginfo:IsDamageType(DMG_BURN) then
dmginfo:SetDamage(0) --it doesn't work
print("Debug 4")
end
if dmginfo:IsExplosionDamage() then
dmginfo:SetDamage(0) --it doesn't work
print("Debug 5")
end
end
end
hook.Add( "EntityTakeDamage", "playerhurt", adddmg )

[editline]1st July 2013[/editline]

Fixed it. Thank you for help.