For some reason, other players on my server can't see the HUD I have set up, but I can.
[lua]
function hud()
local health = LocalPlayer():Health()
draw.RoundedBox(4, 10, ScrH() - 120, 260, 110, Color(25,25,25,200))
surface.SetDrawColor(255,255,255)
surface.SetTexture(surface.GetTextureID("gui/silkicons/user"))
surface.DrawTexturedRect(20,ScrH() - 110,16,16)
surface.SetTexture(surface.GetTextureID("gui/silkicons/vcard"))
surface.DrawTexturedRect(20,ScrH() - 90,16,16)
surface.SetTexture(surface.GetTextureID("gui/silkicons/money"))
surface.DrawTexturedRect(20,ScrH() - 70,16,16)
end
hook.Add("HUDPaint", "MyHudName", hud)
function hidehud(name)
for k, v in pairs({"CHudHealth", "CHudBattery", "CHudCrosshair"})do
if name == v then return false end
end
end
hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)
[/lua]
The file is AddCSLuaFile'd in init.lua, and in cl_init.lua, it is included.
Is this a gamemode?
Yes
Override GM.PaintHUD instead of hooking it. Same with GM.HUDShouldDraw.
Override them.
[QUOTE=Freze;35106176]Override GM.PaintHUD instead of hooking it. Same with GM.HUDShouldDraw.
Override them.[/QUOTE]
From personal experience, I concluded that one does not simply override those functions.
In other words, they seem to be only hooks.
If I am wrong, I beg you, show me a working code.
[QUOTE=vercas;35108339]From personal experience, I concluded that one does not simply override those functions.
In other words, they seem to be only hooks.
If I am wrong, I beg you, show me a working code.[/QUOTE]
[lua]
function GM:HUDShouldDraw( id )
local nodraw = {
"CHudHealth",
"CHudAmmo",
"CHudSecondaryAmmo",
"CHudBattery",
"CHudChat",
"CHudWeaponSelection"
}
for k, v in pairs( nodraw ) do
if( id == v ) then
return false;
end
end
return true;
end
[/lua]
I'm overwriting mine. But hooking will work, if he needs some of garrys original hud too.
[lua]
function GM:HudPaint()
self.BaseClass:HUDPaint()
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.