• HUDShouldDraw not working?
    2 replies, posted
[CODE]function HideHUD(name) for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do if name == v then return false end end return true end hook.Add( "HUDShouldDraw", "Draw Hud", HideHud )[/CODE] Simple enough, should work on my sandbox server.. but its not? my HUD is drawing but the Default is being retarded and staying there.. ?
What's "the Default"? You shouldn't return true for everything else, just don't return anything. Your code looks fine to me, other than being inefficient - see example 2: [url]http://wiki.garrysmod.com/page/table/HasValue[/url]
[QUOTE=NeatNit;50888661]What's "the Default"? You shouldn't return true for everything else, just don't return anything. Your code looks fine to me, other than being inefficient - see example 2: [url]http://wiki.garrysmod.com/page/table/HasValue[/url][/QUOTE] Wait so something like this: [CODE]local hide = { CHudHealth = true, CHudBattery = true, CHudAmmo = true, CHudSecondaryAmmo = true, } hook.Add( "HUDShouldDraw", "HideHUD", function( name ) if ( hide[ name ] ) then return false end -- Don't return anything here, it may break other addons that rely on this hook. end )[/CODE] [editline]15th August 2016[/editline] Oh lol, I solved my own problem.. xD
Sorry, you need to Log In to post a reply to this thread.