Client-Side Code won't work..

[lua]
–init.lua
AddCSLuaFile( “cl_hud.lua” )

–cl_hud.lua
HUDToHide = { “CHudHealth”, “CHudBattery”, “CHudSuitPower”, “CHudAmmo”, “CHudSecondaryAmmo”, “CHudPoisonDamageIndicator”, “CHudDeathNotice” }

function GM:HUDShouldDraw( name )
for k, v in pairs( HUDToHide ) do
if name == v then return false end
end

return true

end
[/lua]

Why isn’t this working?! :S

What are your errors?

Put AddCSLua for the file inside of cl_init.lua and any other client side files.

There are no errors…

[editline]16th February 2012[/editline]

I also put the AddCSLuaFile in shared.lua ( in an if CLIENT then check ) and in cl_init.lua

[editline]16th February 2012[/editline]

Also in cl_hud.lua

In what way is it “not working”. Be specific if you want help.

[editline]16th February 2012[/editline]

There’s no point in doing that. What you need to make sure to do is include all your clientside files in cl_init.lua and serverside files in init.lua like so:
[lua]
include “cl_hud.lua”
[/lua]

If you’ve done that and it still isn’t “working”, what do you mean it isn’t “working”?

Why would you use include if its clientside, not serverside?

You clearly need to learn more Lua
AddCSLuaFile is serverside only, meaning you call it on the server to send the specifed clientside file, but you have to include said file clientside also.

You could just run IncludeClientFile shared too.

Nevermind I got mixed up between the two again…

My bad.

I put it in everywhere I could find just for the sake of it. I know there’s no reason in doing it…

And what I mean by it’s not working is:

It won’t take away the Base Gamemode HUD… So basically:
“CHudHealth”, “CHudBattery”, “CHudSuitPower”, “CHudAmmo”, “CHudSecondaryAmmo”, “CHudPoisonDamageIndicator”, “CHudDeathNotice”

So to clear this up… My problem is that it won’t take away the Base Gamemode HUDs I listed above…

What I have is:
[lua]
–cl_hud.lua
HUDToHide = { “CHudHealth”, “CHudBattery”, “CHudSuitPower”, “CHudAmmo”, “CHudSecondaryAmmo”, “CHudPoisonDamageIndicator”, “CHudDeathNotice” }

function GM:HUDShouldDraw( name )
for k, v in pairs( HUDToHide ) do
if name == v then return false end
end

return true

end

–init.lua
AddCSLuaFile( “cl_hud.lua” )

–cl_init.lua
include( ‘cl_hud.lua’ )
[/lua]

Any ideas?

Remove the “return true” line

Still doesn’t work. And I put that in there because if it isn’t one of those, then it will return true.

bad idea
That will make his HUD not paint

… The fuck, I can even put it in my cl_init.lua and it still won’t work. :S

If you return true, you overwrite other HudShouldDraw Hooks. It’s better to remove it.

Okay Jack, I did it your way and my way, both didn’t work. So that’s obviously not the problem…

I think the problem might be that when you do a for loop and you return false it completely stops the loop. Try doing it seperately like:

if name == “CHudHealth” or name == “CHudBattery” then …etc etc

[lua]local HUDToHide = { “CHudHealth”, “CHudBattery”, “CHudSuitPower”, “CHudAmmo”, “CHudSecondaryAmmo”, “CHudPoisonDamageIndicator”, “CHudDeathNotice” }

function GM:HUDShouldDraw( name )
return !table.HasValue( HudToHide, name );
end[/lua]

Still won’t work, Banana Lord. :S

( I fixed the table inside the table.HasValue and changed it to HUDToHide instead of HudToHide )

[editline]18th February 2012[/editline]

It seems to me like anything that’s not in init.lua won’t work. I tried putting that code in cl_init.lua and shared.lua ( client side ) and neither worked… :confused:

if this is for DarkRP then put this code in cl_hud.lua, not cl_init.lua, I tried putting a HUD hook in cl_init.lua (yes, at the bottom) and it didn’t work for some reason