[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]
[QUOTE=InfernalCookie;34720318]
Also in cl_hud.lua[/QUOTE]
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?
[QUOTE=brandonj4;34730607]Why would you use include if its clientside, not serverside?[/QUOTE]
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.
[QUOTE=Jackthemaster;34758414]Remove the "return true" line[/QUOTE]
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... :/
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
This is for a custom gamemode I'm making. I usually have it in cl_hud.lua but it won't work. Perhaps it's due to my lack of including the file correctly?
What do I need to put to correctly have the cl_hud file run?
You need to AddCSLuaFile( "cl_hud.lua" ) in init.lua, and then include( "cl_hud.lua" ) in cl_init.lua
Thought so... I have all that in the correct places, but it still doesn't want to work.
[editline]18th February 2012[/editline]
[lua]
--init.lua
AddCSLuaFile( "cl_hud.lua" )
--cl_init.lua
include( 'cl_hud.lua' )
--cl_hud.lua
HUDToHide = { "CHudHealth", "CHudBattery", "CHudSuitPower", "CHudAmmo", "CHudSecondaryAmmo", "CHudPoisonDamageIndicator", "CHudDeathNotice" }
function GM:HUDShouldDraw( name )
return !table.HasValue( HUDToHide, name );
end
[/lua]
Also local on HUDToHide.. Unless you use it somewhere else?
Try using doublequotes in the include? Top of my head, I can't see anything wrong with it otherwise.
Tried it, won't work.
Something else than THAT code is stopping it from working. Any hooks to it?
Nope. I do have code below it that is for my custom HUD, I tried it without the extra code and it still doesn't work.
Try it above?
It is above, and I tried it without the extra code period.
I'm giving up. You're getting no errors?
Sorry, you need to Log In to post a reply to this thread.