• Hud Problem
    13 replies, posted
So my hud is not displaying on the server i cannot see my k/d ratio on the top right AddCSLuaFile("config.lua") include("config.lua") surface.CreateFont( "EssentialsHUDFont", { font = "Montserrat", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name extended = false, size = 13, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } )     local health_icon = Material( "icon16/heart.png" )     local shield_icon = Material( "icon16/shield.png" )     local cash_icon = Material( "icon16/money.png" )     local star_icon = Material( "icon16/star.png" )     local tick_icon = Material( "icon16/tick.png" ) local health = LocalPlayer():Health() local armor  = LocalPlayer():Armor() local steamid = LocalPlayer():SteamID() local group = LocalPlayer():GetUserGroup() local ammo1 = LocalPlayer():GetActiveWeapon():Clip1() local ammo2 = LocalPlayer():GetActiveWeapon():Clip2() local weapon = LocalPlayer():GetActiveWeapon():GetClass() local name = LocalPlayer():Nick() or "" local job = LocalPlayer():getDarkRPVar("job") or "" local money  = LocalPlayer():getDarkRPVar("money") or 0 local salary = LocalPlayer():getDarkRPVar("salary") or 0 print ( " read after local functions" ) local function Killcounter() print ( "read after local function kill counter" ) w = 125 h = 85 x = ScrW() / 2 + 550 y = ScrH() / 2 - 375 draw.RoundedBox( 10, x, y, w, h, Color( 0, 0, 0, 200 ) )  surface.SetFont("EssentialsHUDFont") local tW, tH = surface.GetTextSize("Stats") draw.DrawText( "Kills: "..LocalPlayer():Frags(), "EssentialsHUDFont", x + 5, y + (tH) - 5, HudConfig.kdcolor ) draw.DrawText( "Deaths: "..LocalPlayer():Deaths(), "EssentialsHUDFont", x + 5, y + (tH*2) - 5, HudConfig.kdcolor ) draw.DrawText( "K/D Ratio: "..math.Round(LocalPlayer():Frags()/LocalPlayer():Deaths(), 3), "EssentialsHUDFont", x + 5, y + (tH*3) - 5, HudConfig.kdcolor ) end print ( " Read after kill counter" ) local function DrawEssentialsHud() if HudConfig.kd == true then Killcounter() end end hook.Add("HUDPaint", "DrawEssentialsHud", DrawEssentialsHud)
Having tested the basic code (tweaked to work out of context), this should display fine. https://files.facepunch.com/forum/upload/297607/901f16e2-a738-4501-ab01-69876ef1f972/HUDtest1.png Please check for any runtime errors, and make sure the code is being run clientside. You should also check that HudConfig.kd evaluates to true and that you are testing this in DarkRP since you are using DarkRP methods in the code.
use if CLIENT then end
where do i put that kubu?
You can wrap the entire VGUI stuff with the if CLIENT then: if CLIENT then surface.CreateFont( "EssentialsHUDFont", { ... hook.Add("HUDPaint", "DrawEssentialsHud", DrawEssentialsHud) end
Now there's an example of terrible file name convension.
how??
The easiest way to fix your problem is by putting the config in the client folder.
Ok, let me explain. Addons files in the filesystem are shared. That means if a file exists in both addons, in your case lua/config.lua, the file will only be loaded from ONE of the addons, resulting in the other addon being broken. Putting the file into client folder will not solve this problem, editing the file name to be unique will. something like config_ehud.lua or whatever.
so make a config for the bank robbery entity and make a seperate config file for the hud?
What Rubat is saying is that regardless, your script filenames need to be unique as they share the same virtual filesystem as all other Lua scripts. So TOGEssentials_config.lua is much better than config.lua.
ohh ok
i have if CLIENT then surface.CreateFont( "EssentialsHUDFont", { font = "Montserrat", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name extended = false, size = 13, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } )     local health_icon = Material( "icon16/heart.png" )     local shield_icon = Material( "icon16/shield.png" )     local cash_icon = Material( "icon16/money.png" )     local star_icon = Material( "icon16/star.png" )     local tick_icon = Material( "icon16/tick.png" ) local health  = LocalPlayer():Health() local armor  = LocalPlayer():Armor() local steamid = LocalPlayer():SteamID() local group = LocalPlayer():GetUserGroup() local ammo1 = LocalPlayer():GetActiveWeapon():Clip1() local ammo2 = LocalPlayer():GetActiveWeapon():Clip2() local weapon = LocalPlayer():GetActiveWeapon():GetClass() local name = LocalPlayer():Nick() or "" local job = LocalPlayer():getDarkRPVar("job") or "" local money  = LocalPlayer():getDarkRPVar("money") or 0 local salary = LocalPlayer():getDarkRPVar("salary") or 0 local function Killcounter() w = 125 h = 85 x = ScrW() / 2 + 550 y = ScrH() / 2 - 375 draw.RoundedBox( 10, x, y, w, h, Color( 0, 0, 0, 200 ) )  surface.SetFont("EssentialsHUDFont") local tW, tH = surface.GetTextSize("Stats") draw.DrawText( "Kills: "..LocalPlayer():Frags(), "EssentialsHUDFont", x + 5, y + (tH) - 5, HudConfig.kdcolor ) draw.DrawText( "Deaths: "..LocalPlayer():Deaths(), "EssentialsHUDFont", x + 5, y + (tH*2) - 5, HudConfig.kdcolor ) draw.DrawText( "K/D Ratio: "..math.Round(LocalPlayer():Frags()/LocalPlayer():Deaths(), 3), "EssentialsHUDFont", x + 5, y + (tH*3) - 5, HudConfig.kdcolor ) end local function DrawEssentialsHud() if HudConfig.kd == true then Killcounter() end end hook.Add("HUDPaint", "DrawEssentialsHud", DrawEssentialsHud) end its still not showing?
Are you getting any lua errors? If I construct HudConfig as a global table and set its kd member to true, the HUD shows up.
Sorry, you need to Log In to post a reply to this thread.