• Client-Side Code won't work..
    89 replies, posted
Maybe an addon is using "GM:HUDShouldDraw" when it SHOULD to be using a hook. Try changing it from [lua] --cl_hud.lua HUDToHide = { "CHudHealth", "CHudBattery", "CHudSuitPower", "CHudAmmo", "CHudSecondaryAmmo", "CHudPoisonDamageIndicator", "CHudDeathNotice" } function GM:HUDShouldDraw( name ) return !table.HasValue( HUDToHide, name ); end [/lua] to [lua] --cl_hud.lua local HUDToHide = { "CHudHealth", "CHudBattery", "CHudSuitPower", "CHudAmmo", "CHudSecondaryAmmo", "CHudPoisonDamageIndicator", "CHudDeathNotice" } hook.Add( "HUDShouldDraw","GamemodeName", function( name ) return !table.HasValue( HUDToHide, name ); end ) [/lua]
I'll try that, thanks Chief!
[QUOTE=Chief Tiger;34763560]Maybe an addon is using "GM:HUDShouldDraw" when it SHOULD to be using a hook. Try changing it from [lua] --cl_hud.lua HUDToHide = { "CHudHealth", "CHudBattery", "CHudSuitPower", "CHudAmmo", "CHudSecondaryAmmo", "CHudPoisonDamageIndicator", "CHudDeathNotice" } function GM:HUDShouldDraw( name ) return !table.HasValue( HUDToHide, name ); end [/lua] to [lua] --cl_hud.lua local HUDToHide = { "CHudHealth", "CHudBattery", "CHudSuitPower", "CHudAmmo", "CHudSecondaryAmmo", "CHudPoisonDamageIndicator", "CHudDeathNotice" } hook.Add( "HUDShouldDraw","GamemodeName", function( name ) return !table.HasValue( HUDToHide, name ); end ) [/lua][/QUOTE] I should go to bed..
Unfortunately, it still doesn't work.. :S
Is this gamemode completely from scratch or are you using code from another gamemode as well?
I used the Skeleton gamemode then made it from scratch using that. [editline]19th February 2012[/editline] Oh and also, the code in the same file as this that makes my custom HUD doesn't work either. I just noticed that.
If you are using Notepad ++ open all of the files in the gamemode and press Ctrl+F Then search through all open documents for "GM:HUDShouldDraw" and see if it gets more than 1 hit. If so, then see where else it's being defined. If not, good luck because I have no fucking clue.
Nope... No other functions with GM:HUDShouldDraw.... fuck my life.
Ok, one more thing. If a HOOK isn't working, then that means there's another HOOK killing it with a return statement. While you're in game, open your console and type lua_run_cl PrintTable( hook.GetTable()['HUDShouldDraw'] ) Post results.
] lua_run_cl PrintTable( hook.GetTable()['HUDShouldDraw'] ) ... It didn't print anything
To see if your gamemode is acting weird, try creating a lua file in lua/autorun/client/ and see if it works.
Even in lua/autorun/client/ it won't work.... -_-
I really feel like you aren't AddCSLuaFileing this correctly
Well, it didn't work lua/autorun/client, so it's not that.. But I double checked and I don't think so
Open all files, and do Ctrl-F and instead of GM:HUDShouldDraw Just search HUDShouldDraw.
Try this. [lua] local HUDToHide = { CHudHealth = true, --Hide it. CHudBattery = false --Show this. -- ...but also show all other undefined hud elements. } function GM:HUDShouldDraw( name ) return HUDToHide[name] end [/lua]
that will return nil for the other types though, should be HUDToHide || false
so try: [lua] local HUDToHide = { CHudHealth = true, --Hide it. CHudBattery = false --Show this. -- ...but also show all other undefined hud elements. } function GM:HUDShouldDraw( name ) return HUDToHide[name] || false end [/lua] ?
[QUOTE=Banana Lord.;34772267]that will return nil for the other types though, should be HUDToHide || false[/QUOTE] [B]nil[/B] represents false in Lua.
[QUOTE=Panto;34773028][B]nil[/B] represents false in Lua.[/QUOTE] No.. but tobool(nil) will be false.
I just remembered this thread, when i saw my own code. This works: [lua]function GM:HUDShouldDraw( id ) local nodraw = { "CHudHealth", "CHudAmmo", "CHudSecondaryAmmo", "CHudBattery", } for k, v in pairs( nodraw ) do if( id == v ) then return false; end end return true; end[/lua] If it doesn't something else is blocking it.
Why create that table every time the hook is called?
[QUOTE=Freze;34840226]I just remembered this thread, when i saw my own code. This works: [lua]function GM:HUDShouldDraw( id ) local nodraw = { "CHudHealth", "CHudAmmo", "CHudSecondaryAmmo", "CHudBattery", } for k, v in pairs( nodraw ) do if( id == v ) then return false; end end return true; end[/lua] If it doesn't something else is blocking it.[/QUOTE] I have basically the same code, it didn't work..
[QUOTE=Panto;34773028][B]nil[/B] represents false in Lua.[/QUOTE] [url]http://codepad.org/5JGkLSjl[/url] I think that all "if" statements are converted to a bool, so nil will be converted to "false" but not necessarily represent false.
[QUOTE=InfernalCookie;34841615]I have basically the same code, it didn't work..[/QUOTE] if none of our solutions work then you're not including the file, I took the code directly from my gamemode.
You're supposed to use hooks in addons, not creating a member of "GM".
[lua] --init.lua AddCSLuaFile( "cl_hud.lua" ) --cl_init.lua include( "cl_hud.lua" ) [/lua] Please tell me what I'm doing wrong to include the file.
Includes has nothing wrong. But something else is doing it wrong. Check your addons and stuff. It might be overwritten in some addon.
[QUOTE=Freze;34846051]Includes has nothing wrong. But something else is doing it wrong. Check your addons and stuff. It might be overwritten in some addon.[/QUOTE] Only functions / hooks with HUDShouldDraw are in seperate gamemodes. One per gamemode...
And this is your own gamemode, yes?
Sorry, you need to Log In to post a reply to this thread.