• my hud wont work
    14 replies, posted
File Structure: garrysmod\addons\birbshud\lua\autorun\client\cl_birbhud.lua Code: surface.CreateFont( "Server", {     font = "Arial",     size = 16,     weight = 500, } ) hook.Add("HUDPaint", "DrawText", DrawText()     draw.SimpleText("You are playing on Birbs&Parrots Clan Server", "Server", ScrW() / 2 - 70, 5, Color(255,255,255,255) end) When I do lua_openscript, I dont see cl_birbhud anywhere and its no drawing on my screen either
lua_openscript_cl
You’re not calling the function properly.
how do i call the function
It just looks like you forgot a closing bracket after the colour where you’re drawing your simple text
you do know that this chat message will SPAM several hundret times a second in your chat, nonstop. Right? to open a lua file from console the lua file needs to be in garrysmod/lua and not in addons.
Try like this hook.Add("HUDPaint", "DrawText", function() -- This code end)
I got it to work I can open it but i get this error: [ERROR] lua/cl_birbhud.lua:8: ')' expected near '='   1. unknown - lua/cl_birbhud.lua:0 Here is my code: surface.CreateFont( "Server", {     font = "Arial",     size = 16,     weight = 500, } ) local function DrawHud() draw.DrawText("You are playing on the Birbs&Parrots Clan Server", "Server", x=0, y=0, Color(255, 0, 12, 255), TEXT_ALIGN_CENTER ) end) hook.Add("HUDPaint", "DrawText", DrawHud() end)
your still having a ) after the functions end. you dont need that for a function thats not in a hook
oh
also your Hook is still wrong. You dont need to call end) anymore. just put ) right after DrawHud()
fixed it but now i have this error: [ERROR] lua/cl_birbhud.lua:14: ')' expected (to close '(' at line 11) near 'end'   1. unknown - lua/cl_birbhud.lua:0 Code: surface.CreateFont( "Server", {     font = "Arial",     size = 16,     weight = 500, } ) function DrawHud() draw.DrawText("You are playing on the Birbs&Parrots Clan Server", "Server", 0, 0, Color(255, 0, 12, 255), TEXT_ALIGN_CENTER ) end  hook.Add("HUDPaint", "DrawText", DrawHud() end)
Try surface.CreateFont( "Server", { font = "Trebuchet18", size = 16, weight = 500, } ) function DrawHud() draw.DrawText("You are playing on the Birbs&Parrots Clan Server", "Server", 0, 0, Color(255, 0, 12, 255), TEXT_ALIGN_CENTER ) end hook.Add("HUDPaint", "DrawText", DrawHud)
that worked thanks
oh right thats something i forgot to mention. when calling a function with a hook you dont need to use (). just type the function name
Sorry, you need to Log In to post a reply to this thread.