Disabling standard HUD and Shortcut

hey everybody,
i got one very small problem. At the moment i am scripting the HUD for my gamemode but i have still no idea how to disable the standard HUD/GUI (red marked in the screen below). May canybody can give me a tip?
Screen: http://dl.dropbox.com/u/13693172/facepunch_pic1.png

Also i got a second question which i’d like to ask. How can i do that if i press 1,2 or 3 that the weapon is changing immediatly to another one? I mean at the moment he will select a slot in the standard HUD and you have to click to change weapon. But i want to change the weapon just with pressing 1, 2 or 3. Any suggestions?

Would be nice if somebody can help.
Greeting Obstalat



[lua]function HideHUD( name )
if (name == “CHudSuitPower” or name == “CHudHealth” or name == “CHudBattery” or name == “CHudAmmo” or name == “CHudWeaponSelection” or name == “CHudSecondaryAmmo”) then
return false
hook.Add( “HUDShouldDraw”, “HideHUD”, HideHUD)[/lua]

Bit long but you could make it shorter with a table I suppose but that’s for you to work out :slight_smile:

Using a table would be slower due lookups.


hook.Add( “HUDShouldDraw”, “HideHUD”,function( name )
return not (name == “CHudSuitPower” or name == “CHudHealth” or name == “CHudBattery” or name == “CHudAmmo” or name == “CHudWeaponSelection” or name == “CHudSecondaryAmmo”);

That should be the best way.

Actually, you don’t want to do that Wizard.

That would return true in every instance where the HUD element’s name is not one of those listed. This is a good example of how to write code that conflicts with other addons. If another script wanted to remove some other HUD bit, like “CHudElement” or whatever, then it wouldn’t work because you override that script by returning true in all cases except the ones you specify.

Nope, that will prevent any other HUDShouldDraw hook from running, even when the HUD element is allowed. xomaxhox’s code will allow other HUDShouldDraw hooks to run when it doesn’t block the HUD element.


Would only be the best way if you just have 1 hook.

Thanks, works :smiley:

Any idea to the second question?