I've been learning how to influence HUDs and use draw functions on Gmod but whenever I try running any code relying on a 2d rendering context hook like HUDPaint it doesn't seem to work. There's no error that appears but there's also no drawing or any change to the HUD. Here's my code:
function test()
surface.SetDrawColor( 0, 0, 0, 120 )
surface.DrawRect( 50, 50, 128, 128 )
end
hook.Add("HUDPaint", "HUDPaint_DrawABox", test)
I'm not sure if it's a problem with HUDPaint, or the function I'm using to draw(test). My best guess is that it has something to do with HUDPaint being a server-side script, as I haven't yet used any code that is specifically server-side. I've been attempting to run this code in the normal singleplayer Gmod instance, which has worked so far for me when I've used other scripts.
HUDPaint is client-side, as are all rendering hooks.
Where are you placing the lua file for this? It should be placed in addons/YOUR ADDON NAME/lua/autorun/client
Also, it's more standard convention to use draw.RoundedBox https://wiki.facepunch.com/gmod/draw.RoundedBox
(As you don't want to be setting a suface draw color unnecessarily if you can help it)