Custom CHUDHealth?

Hello FacePunch, I dont know directly how HUDShouldDraw things like CHUDHealth can be overwritten, like I want to make a gamemode which calls the function GM:HUDPaint directly, and I want to provide others to disable certain things of the hud with HUDShouldDraw, is it possible to do so? And how? Also, I wanted to ask if I can add in the HUDPaint hook something on the top that checks if a var is true, and when someone returns true in their hook.add, it will overwrite the HUDPaint function completely?

The only function of HUDShouldDraw is to return a boolean on whether or not a part of the hud should be drawn. If you wanted a custom health hud, you would disable CHUDHealth in HUDShouldDraw, then in hud paint draw your own hud for the health.

You didn’t fully understand what I meant. I want to overwrite/make a custom CHUDHealth which people can disable in my gamemode, because my ‘base’ hud is being drawn in GM:HUDPaint itself, not a hook. So they’d have to overwrite the function if I cant get HUDShouldDraw working.

At the time of drawing your hud health bar call the hook HUDShouldDraw with one argument: “CHUDHealth”.
If it returns false then dont draw it, if else draw it, BUT check if it is NOT false (VariableOrHookCall != false) specifically, beacouse as i know it will return false or nil, and you want to draw it on nil.

[editline]28th January 2016[/editline]

Or just name it as you want.
What i mean with that is that you should call that hook with hook.Call and put an argument as for example “CustomHUDHealth”.

so something like

local returnedvar = hook.Call("HUDShouldDraw", GAMEMODE, "CHUDHealth") or false

Would that do it?

Call it something different than CHUDHealth, like MyHUDHealth or so.
Also, instead of “or false” remove it if youvare going to do the != false or put “or true” if you are checking the value.