Code hides death notices when it shoulden't

function GM:HUDPaint()
local Charge = LocalPlayer():GetNWInt( “run_power” )
if Charge != 100 then
draw.SimpleText(“Sprint Energy”, “HudHintTextLarge”, ScrW()*0.2 + 10, ScrH()0.9+31, Color(225, 225, 0, 235), 0, 0)
draw.RoundedBox( 4, ScrW() * 0.2+8, ScrH() * 0.9+8, 174
(Charge/100), 24, Color( 225, 225, 0, 140) )
draw.RoundedBox( 6, ScrW() * 0.2, ScrH() * 0.9, 200, 50, Color( 0, 0, 0, 70) )

It hides death notices. It works the way it’s supposed to, but also the way it’s not supposed to. by hiding death notices. I also think that it’s hiding player names when you scroll over them. All I can say it: What the fuck.

I want to be able to use this… without it hiding death notices. Removing the code from my gamemode’s cl_init re-allows death notices… But then I don’t get my snazzy run energy meter. Why is this happening.


If I’m understanding the problem correctly, maybe putting that in the first line of the function will help

Well, whatever that did, it fixed it. Thank you.

I’ll explain -

HUDPaint is a function that is already written. It’s responsible for painting a bunch of the default HUD stuff.

What you did was overwrote/overrode that function, so the default stuff was removed. By running BaseClass.HUDPaint , you’re running the original function first, then continuing with your own code.

I find that it’s usually better to do self.BaseClass.HUDPaint(self) because if you do self.BaseClass:HUDPaint() then the self that’s called is the base class, which would be the gamemode it’s derived from, rather than the current gamemode.
So if you overrode a function from the BaseClass, which HUDPaint calls then it’d call the old one rather than the new one.

I did not realize that. That could be a problem.

Rated informative. Time to go look through all my code

My solution seems really clumsy and unnecessary now, but I copied cl_deathnotice.lua from base to the new gamemode folder when I had this problem and called GAMEMODE:DrawDeathNotice(x, y).

I’m thinking self.BaseClass.DrawDeathNotice(self, x, y) would work as well if you want to draw the death notice explicitly.

I don’t bother with baseclasses. I just save a copy of the function, then call it after my code.