• Reducing fall damage
    11 replies, posted
[CODE]local function ReduceFallDamage(ent, dmginfo) if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(5) end end[/CODE] So this for my pointshop and it reduces fall damage, but it does it so much that I take 0 damage at all does anyone know hoe to make me take damage still at a certain height
[QUOTE=crazymankills;42340429][CODE]local function ReduceFallDamage(ent, dmginfo) if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(5) end end[/CODE] So this for my pointshop and it reduces fall damage, but it does it so much that I take 0 damage at all does anyone know hoe to make me take damage still at a certain height[/QUOTE] Depending on what gamemode you're doing this for, there might be a different way they check for fall damage. Post what the gamemode is.
Have you remembered to add the hook? Try this: [CODE]local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldReduceFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0.5) end end hook.Add("EntityTakeDamage", "ReduceFallDamage", ReduceFallDamage)[/CODE]
[QUOTE=Fortune11709;42340839]Have you remembered to add the hook? Try this: [CODE]local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldReduceFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0.5) end end hook.Add("EntityTakeDamage", "ReduceFallDamage", ReduceFallDamage)[/CODE][/QUOTE] Just a quick question, If I make the scale 0 does the player take no damage? just curious thanks.
[QUOTE=kpjVideo;42341069]Just a quick question, If I make the scale 0 does the player take no damage? just curious thanks.[/QUOTE] I think it does. I am pretty sure 5 means it does [I]5 times[/I] as much damage, not 5 times less. I would think 0.2 would scale it down.
Scale does this: SetDamage( GetDamage( ) * amount ) So if you scale by 5, you are actually multiplying it by 5. So, if you want to reduce it, you'd multiply by a value between 0 and 1, such as .5, .25, etc
I have the hook.add but when I fall it does not reduce the fall damage at all
Try this: [CODE]local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0.2) end end[/CODE]
[QUOTE=Fortune11709;42341718]Try this: [CODE]local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0.2) end end[/CODE][/QUOTE] You forgot to add hook [CODE]local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0.2) end end hook.Add("EntityTakeDamage", "ReduceFallDamage", ReduceFallDamage)[/CODE]
[QUOTE=Fortune11709;42341139]I think it does. I am pretty sure 5 means it does [I]5 times[/I] as much damage, not 5 times less. I would think 0.2 would scale it down.[/QUOTE] I tried adding [code] local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo) if ent:IsPlayer() and ent.ShouldReduceFallDamage and dmginfo:IsFallDamage() then dmginfo:ScaleDamage(0) end end hook.Add("EntityTakeDamage", "ReduceFallDamage", ReduceFallDamage) [/code] to a TTT swep but when I have it in-hand or use it I still take full damage.
Isn't this what GM:GetFallDamage() is for?
Here's how to properly do fall damage, as stated by Luni: [lua]function GM:GetFallDamage ( Player, fallSpeed ) // // People connecting should not take fall damage // -- if ( !Player:IsFullyConnected( ) ) then return 0; end -- Custom function, but you should probably code something like this in. // // Admins in admin mode should not take damage // -- if ( Player:IsAdmin( ) ) then return 0; end -- Recoded function, admin mode must be active for this to be enabled, otherwise it's not fair for regular players // // Otherwise, we derive fall damage based on the speed at which they fell // return math.Clamp( fallSpeed / 8, 10, 200 ); end[/lua]
Sorry, you need to Log In to post a reply to this thread.