Blood splat on screen when hit and when close to splatter?

I would like to know how to have blood splats on your HUD when you get shot and when close to a blood splatter. and then fade away after 5 seconds.

all help is appreciated.

thanks :slight_smile:

[lua]function GM:HUDPaint()
self.BaseClass:HUDPaint()

GAMEMODE:OnHUDPaint()

end

function GM:OnHUDPaint()
GAMEMODE:PaintBlood()
end

function GM:PaintBlood()

if #Stains < 1 then return end

for k,v in pairs( Stains ) do
	v.Alpha = math.Approach( v.Alpha, 0, FrameTime() * v.DieRate * -1 )

	surface.SetTexture( v.Mat )
	surface.SetDrawColor( 255, 10, 10, v.Alpha )
	surface.DrawTexturedRectRotated( v.X, v.Y, v.W, v.H, v.Rotation )
end

for k,v in pairs( Stains ) do
	if v.Alpha < 2 then
		table.remove( Stains, k )

	elseif not LocalPlayer():Alive() then
		v.DieRate = 30
	end
end

end

function AddStain()
local x, y, w, h = ScrW() * math.Rand(-0.2,1), ScrH() * math.Rand(-0.2,1), ScrW() * math.Rand(0.3,0.6), ScrH() * math.Rand(0.3,0.6)
table.insert( Stains, {X = x, Y = y, W = w, H = h, Mat = table.Random( StainMats ), DieRate = math.Rand(5,15), Rot = math.random(0,360), Alpha = math.random(50,150)} )
end[/lua]

Just how Zombie Onslaught does it. Check the rest of code here.

Thanks for the help man this is really useful Iā€™m going to test it now :slight_smile: