I wanted to start working with HUDs yesterday, so I found a video on YouTube for it and then fixed the code he showed (His code was outdated and produced errors)
After making it work with GM13, I realized whenever I was on my server running the code for a few minutes, I would crash out of GMod with no errors or anything
I get no errors on the code and my game shows no errors when I crash
My GMod will just suddenly close
I'm sure this code is making me crash, because when I moved it to another folder where the code wouldn't run, I stopped crashing
//include( "shared.lua" )
hook.Add( "HUDShouldDraw", "hidethehud", function( name )
if (name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo") then return false end end )
function PaintZeeHud()
local ply = LocalPlayer()
local HP = ply:Health()
local ARM = ply:Armor()
local NewScrH = (ScrH() - 50 )
draw.RoundedBox( 10, 10, NewScrH - 30, 75, 75, Color( 87, 81, 81, 255 ) )
surface.CreateFont( "ZeeFont", {
font = "ScoreboardText",
size = 40,
weight = 255,
antialias = false,
underline = false,
italic = false,
})
surface.SetTextColor( 0, 0, 255, 255 )
if (ply:Health() == 100) then
surface.SetTextPos( 20, NewScrH - 14)
elseif (ply:Health() == 0) then
surface.SetTextPos( 39, NewScrH - 14 )
else
surface.SetTextPos( 30, NewScrH - 14 )
end
surface.SetFont( "ZeeFont" )
surface.DrawText( HP )
end
hook.Add( "HUDPaint", "PaintZeeHUDHook", PaintZeeHud )
Does anyone know what I did wrong?
Line 1 is commented out because I didn't create a shared.lua file yet