Reducing fall damage


local function ReduceFallDamage(ent, dmginfo)
      if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then
         dmginfo:ScaleDamage(5)
      end
   end

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

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:


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)

Just a quick question, If I make the scale 0 does the player take no damage? just curious thanks.

I think it does. I am pretty sure 5 means it does 5 times 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:


local function ReduceFallDamage(ent, inflictor, attacker, amount, dmginfo)
      if ent:IsPlayer() and ent.ShouldRecieveFallDamage and dmginfo:IsFallDamage() then
         dmginfo:ScaleDamage(0.2)
      end
   end

You forgot to add hook


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)

I tried adding



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)


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]