Damage drop off & Kill display

Hello amigos!

Im making a PUBG Hud. Im almost finished but i need to do some finishing touches.
One thing that i need is whenever the player gets damage it’s gets a drop off. Like this:

http://www.youtube.com/watch?v=3n_BZK12Vzw&t=1m17s

And whenever a player is under a certain amount of health for example 50% or 25% the bar will get Red. Im using RoundedBoxes for the healthbar.

The second thing is the kill display. I was working on it but i couldn’t get it to work.
It’s whenever a player kills a other player it displays this:

I hope you can get me a step further by helping me out and giving me some tips that i could use making this all work.
Thank you for your time.

Maybe provide code??? We cannot help you much without your code.

Also, what do you mean by damage drop off? Do you mean the blood on the screen?

To make the bar red after it reaches a certain percentage, just create an if statement checking if

Entity:Health is lower than a percentage of the player’s

Entity:GetMaxHealth.

To make a kill display, grab the number of frags the player has using

Player:Frags and then draw it on their screen using

draw.DrawText. If you want, you can use the surface library instead of the draw library.

damage drop off
garrysmod/gamemodes/base/gamemode/player.lua


function GM:ScalePlayerDamage( ply, hitgroup, dmginfo)
	
	local attacker = dmginfo:GetAttacker()
	
	local usedgun = attacker:GetActiveWeapon():GetClass()
	local caliber = attacker:GetActiveWeapon():GetPrimaryAmmoType() -- alternative method, use ammo types to create universal weapon damage fall off
																	-- instead of individual weapon damage fall off graphs
	if IsValid(attacker) and IsValid(ply) then
			
		local attackpos = attacker:GetPos()
		local victimpos = ply:GetPos()
		local range = attackpos:Distance(victimpos)
		local metre = (512 / 9.75) -- conversion from hammer units to metres (512 units = 9.75m)
		if usedgun == ("cw_l115") then -- a weapon damage fall off graph for the l115 gun
			
			local effrange = (100 * metre) -- range at which damage falls off, straight line graph from max damage to 3 times max damage
			local maxrange = (200 * metre) -- range at which gun is ineffective greatly, 3 times less damage
			local maxdmg = 550 -- make sure its the same as the weapons damage
			
			if range > maxrange then
				local falloff = 0.3
				dmginfo:ScaleDamage(falloff)
			elseif range > effrange then
				local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range))
				dmginfo:ScaleDamage(falloff/maxdmg)
			elseif range > 0 then
				dmginfo:ScaleDamage(1)
		elseif usedgun == ("cw_ak47") then -- weapon fall off for the ak47
			
			local effrange = (50 * metre)
			local maxrange = (70 * metre)
			local maxdmg = 190
			
			if range > maxrange then
				local falloff = 0.3
				dmginfo:ScaleDamage(falloff)
			elseif range > effrange then
				local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range))
				dmginfo:ScaleDamage(falloff/maxdmg)
			elseif range > 0 then
				dmginfo:ScaleDamage(1)
			end
		end
	end
end

kill display addons
goto Steam\steamapps\common\GarrysMod\bin
and create a shortcut of the gmad.exe file, put it into a folder on your desktop
then find the following addons inside your addons folder
drag and drop them onto the gmad.exe file individually to create their source code
dont profit of their work

https://steamcommunity.com/sharedfiles/filedetails/?id=601936815 – untested

https://steamcommunity.com/sharedfiles/filedetails/?id=191294108 – working

red damage indication hud


hook.Add("HUDPaint", "DrawMyHud" , function()
	local client = LocalPlayer()
	if !client:Alive() then return end
	if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end

        --- all your hud elements  below ---


        -------------------------------------------
	
	-- the screen goes red when you take damage!

	if(client:Health() >= 100) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(0,0,0,0))
	elseif(client:Health() >= 95) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(5,0,0,5))
	elseif(client:Health() >= 90) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(10,0,0,10))
	elseif(client:Health() >= 85) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(15,0,0,15))
	elseif(client:Health() >= 80) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(20,0,0,20))
	elseif(client:Health() >= 75) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(25,0,0,25))
	elseif(client:Health() >= 70) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(30,0,0,30))
	elseif(client:Health() >= 65) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(35,0,0,35))
	elseif(client:Health() >= 60) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(40,0,0,40))
	elseif(client:Health() >= 55) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(45,0,0,45))
	elseif(client:Health() >= 50) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(50,0,0,50))
	elseif(client:Health() >= 45) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(55,0,0,55))
	elseif(client:Health() >= 40) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(60,0,0,60))
	elseif(client:Health() >= 35) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(65,0,0,65))
	elseif(client:Health() >= 30) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(70,0,0,70))
	elseif(client:Health() >= 25) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(75,0,0,75))
	elseif(client:Health() >= 20) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(80,0,0,80))
	elseif(client:Health() >= 15) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(85,0,0,85))
	elseif(client:Health() >= 10) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(90,0,0,90))
	elseif(client:Health() >= 5) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(95,0,0,95))
	elseif(client:Health() >= 0) then
	draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(100,0,0,100))
	end
end)

[editline]23rd September 2017[/editline]

local falloff = (((maxdmg - (maxdmg/3)) / ((effrange - maxrange)) * range) + ((maxdmg - (maxdmg/3)) / (effrange - maxrange) * range)) is wrong dont use it

can’t tell if the post above is a troll or if he’s being serious.
either way that’s hilarious.

[lua]
hook.Add(“HUDPaint”, “DrawMyHud” , function()
local client = LocalPlayer()
if !client:Alive() then return end

local EPIC_RED_SCREEN_AMOUNT = (client:Health()/client:GetMaxHealth())*100
draw.RoundedBox(0,0,0,ScrW(),ScrH(), Color(EPIC_RED_SCREEN_AMOUNT,0,0,EPIC_RED_SCREEN_AMOUNT)
end)
[/lua]

He didn’t actually mean the red screen with your health going down, he meant those animated sections when you get damage that go from initial amount of health, to the correct, true one (after damage)

Lerp?

[editline]26th September 2017[/editline]

Good tutorial by CodeBlue.