• HUD only shows up in singleplayer
    1 replies, posted
Hey guys, my custom HUD is only showing up in singleplayer, anyone know how to fix that? Here is my code: cl_init.lua [CODE] function hud() -- Consider functions like a cyber button, and everything INSIDE the function turns on when this cyber button is pressed. local health = LocalPlayer():Health() local player = LocalPlayer() local pTeam = team.GetName( player:Team() ) --Round-Time draw.RoundedBox(0, ScrW() - 122 - 10, ScrH() - 12 - 30 - 30 - 20, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, ScrW() - 120 - 10, ScrH() - 10 - 30 - 30 - 20, 120, 30, Color(102,102,102,255)) draw.SimpleText("Time: " .. ROUND_REMAININGTIME, "Trebuchet24", ScrW() - 122, ScrH() - 36 - 30 - 20, Color(255,255,255,255)) --Battery --draw.RoundedBox(0, 8, ScrH() - 12 - 30 - 30 - 20, 124, 34, Color(255,255,255,20)) --draw.RoundedBox(0, 10, ScrH() - 10 - 30 - 30 - 20, 120, 30, Color(102,102,102,255)) --draw.SimpleText("Battery: " .. BATTERY, "Trebuchet24", 15, ScrH() - 36 - 30 - 20, Color(255,255,255,255)) --Team Box draw.RoundedBox(0, ScrW() - 122 - 10, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, ScrW() - 120 - 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) draw.SimpleText(pTeam, "Trebuchet24", ScrW() - 107, ScrH() - 36, Color(255,255,255,255)) --Player Health if player:Team() == 0 then draw.RoundedBox(0, 8, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) draw.SimpleText("Unkillable", "Trebuchet24", 23, ScrH() - 36, Color(255,255,255,255)) else draw.RoundedBox(0, 8, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) draw.SimpleText("Blood:", "Trebuchet24", 15, ScrH() - 36, Color(255,255,255,255)) draw.SimpleText(health .. "%", "Trebuchet24", 75, ScrH() - 36, Color(255,0,0,255)) end end hook.Add("HUDPaint", "MyHudName", hud) -- I'll explain hooks and functions in a second function hidehud(name) for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do if name == v then return false end end end hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)[/CODE]
Something I suggest to do for hiding the hud would be changing it to this [CODE] local HideHudElements = { CHudCrosshair = true; CHudHealth = true; CHudBattery = true; CHudAmmo = true; CHudSecondaryAmmo = true; CHudHintDisplay = true; CHudHistoryResource = true; }; function GM:HUDShouldDraw( _name ) return !HideHudElements[ _name ]; end [/CODE] Much easier overall, also for the actual codde itself, I'll see if it will work for me, let you know the result. [CODE] function hud() -- Consider functions like a cyber button, and everything INSIDE the function turns on when this cyber button is pressed. local ply = LocalPlayer() local health = ply:Health() // local pTeam = team.GetName( player:Team() ) --Round-Time draw.RoundedBox(0, ScrW() - 122 - 10, ScrH() - 12 - 30 - 30 - 20, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, ScrW() - 120 - 10, ScrH() - 10 - 30 - 30 - 20, 120, 30, Color(102,102,102,255)) --draw.SimpleText("Time: " .. ROUND_REMAININGTIME, "Trebuchet24", ScrW() - 122, ScrH() - 36 - 30 - 20, Color(255,255,255,255)) --Battery --draw.RoundedBox(0, 8, ScrH() - 12 - 30 - 30 - 20, 124, 34, Color(255,255,255,20)) --draw.RoundedBox(0, 10, ScrH() - 10 - 30 - 30 - 20, 120, 30, Color(102,102,102,255)) --draw.SimpleText("Battery: " .. BATTERY, "Trebuchet24", 15, ScrH() - 36 - 30 - 20, Color(255,255,255,255)) --Team Box draw.RoundedBox(0, ScrW() - 122 - 10, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, ScrW() - 120 - 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) --draw.SimpleText(pTeam, "Trebuchet24", ScrW() - 107, ScrH() - 36, Color(255,255,255,255)) --Player Health if ply:Team() == 0 then draw.RoundedBox(0, 8, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) draw.SimpleText("Unkillable", "Trebuchet24", 23, ScrH() - 36, Color(255,255,255,255)) else draw.RoundedBox(0, 8, ScrH() - 12 - 30, 124, 34, Color(255,255,255,20)) draw.RoundedBox(0, 10, ScrH() - 10 - 30, 120, 30, Color(102,102,102,255)) draw.SimpleText("Blood:", "Trebuchet24", 15, ScrH() - 36, Color(255,255,255,255)) draw.SimpleText(health .. "%", "Trebuchet24", 75, ScrH() - 36, Color(255,0,0,255)) end end hook.Add("HUDPaint", "hud", hud) -- I'll explain hooks and functions in a second [/CODE] Works fine, I commented out the lines that gave errors because you may be loading a gamemode that uses the shit which I'm not, I changed the player function up and shit, you should probably try to use what I edited it to, and depending on the gamemode, uncomment the lines I commented, if it's sandbox, then it's the problem with the lines I commented out as they aren't in sandbox by default. [editline]9th June 2014[/editline] For some reason the top part of the script is glitching out, ignore the part that says ="keyword"> if that shows for you
Sorry, you need to Log In to post a reply to this thread.