DrawHud depth?

I feel really stupid asking this, but is there a way to control depth of something drawn with SWEP:DrawHud?

I’m making a sniper scope and I’d like to have the regular hud show over it for the ammo and killfeeds and such.

Draw background before foreground.

Specifically, what would this look like? Do you just need to put --Background or --Foreground before the image specifications?

Things are pretty simple… It draws when you tell it to. If you draw a box first and then a text, you will have the text over the box. If you draw the text first and then the box, you’ll have a box (and the text behind it).
Drawing isn’t like VGUI, where the controls are layered. When you call a draw function, it draws over the existing buffer.

Sooooooo that means that it’s impossible to draw over the default hud?

You can hide the default HUD and make your own with this hook.



Did you try using this hook instead?



[editline]28th December 2011[/editline]

Well since the hook I showed you is a gamemode hook, you’ll obviously need to check the current weapon held by the local player before drawing your scope. You can always do something like this to keep things practical:

[lua]hook.Add(“HUDPaintBackground”, “some_unique_name_here”, function()
local w = LocalPlayer():GetActiveWeapon()
if ValidEntity(w) and w:GetClass() == “my_sniper_rifle” then

Then all you’d need to do is add a DrawHudBackground function in your weapon and do all your HUD drawing in there. Don’t forget to change hook and class names so they fit the name of your weapon.

It means that when you tell it to draw, it draws over whatever is already on the screen.

Just like real painting… You can’t draw a line behind another.