• HUD
    20 replies, posted
Heres a basic hud, that I hand scripted. Hope you like it. I'm not the best of the best at LUA, Please give credit :3 I learned some LUA from the begining on a sight called "roblox" where it was game.Workspace blah, but here you go. [CODE]surface.CreateFont("s1", { font = "Arial", size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) --mistake #3, HUDShouldDraw wasn't a string function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = ply:Health() local ARM = ply:Armor() surface.SetTextColor(255, 255, 255, 255) surface.SetFont("s1") surface.SetTextPos(ScrW()-10, ScrH()-10) surface.DrawText(hp) end [/CODE] This is a small HUD that tracks your movement speed, and health.
hook,Add should be hook.Add, HUDShouldDraw should be a string
[QUOTE=john552;44937909]hook,Add should be hook.Add, HUDShouldDraw should be a string[/QUOTE] oh right, im thinking old gmod, there, fixed. should work now
[QUOTE=DJ Dippa;44937920]oh right, im thinking old gmod, there, fixed. should work now[/QUOTE] you're creating a font every second, the first argument in the surface.CreateFont table should be font, not the last is this SweetTeas alt?
no, it should work. hold on, ill test it right now no im not a alt
[QUOTE=DJ Dippa;44937934]no, it should work. hold on, ill test it right now no im not a alt[/QUOTE] move [code] surface.CreateFont("s1", { size = 20, weight = 900, antialias = true, shadow = false, font = "Arial"}) [/code] this, out of the hudpaint hook you also shouldn't be including shared.lua because you're not supplying us with any
ok ok i think i got it [CODE]function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end local ply = LocalPlayer() surface.CreateFont( "HUD", { font = "DermaLarge", size = 72 } ) hook.Add( "HUDPaint", "HUDHP", function() surface.SetFont( "HUD" ) surface.SetTextColor( 255, 0, 0 ) surface.SetTextPos( 32, 32 ) surface.DrawText( ply:Health() ) end ) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() surface.CreateFont("s1", { size = 20, weight = 900, antialias = true, shadow = false, font = "Arial"}) end[/CODE] would this be correct? i think i need to study gmod on its new system
[QUOTE=DJ Dippa;44937958]ok ok i think i got it [CODE]function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end local ply = LocalPlayer() surface.CreateFont( "HUD", { font = "DermaLarge", size = 72 } ) hook.Add( "HUDPaint", "HUDHP", function() surface.SetFont( "HUD" ) surface.SetTextColor( 255, 0, 0 ) surface.SetTextPos( 32, 32 ) surface.DrawText( ply:Health() ) end ) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() surface.CreateFont("s1", { size = 20, weight = 900, antialias = true, shadow = false, font = "Arial"}) end[/CODE][/QUOTE] I'm done. You're clearly SweetTeas alt account and you're just laughing at my attempts to help you.
[QUOTE=john552;44937982]I'm done. You're clearly SweetTeas alt account and you're just laughing at my attempts to help you.[/QUOTE] uh i have no clue who sweetteas is, but if your saying im wrong, would you mind correcting me? well would someone correct me, i dont want to look like a complete imbisul here e.e
[QUOTE=DJ Dippa;44937988]uh i have no clue who sweetteas is, but if your saying im wrong, would you mind correcting me? well would someone correct me, i dont want to look like a complete imbisul here e.e[/QUOTE] why did you create hook.Add when you already overrode the gamemode function?
[QUOTE=john552;44938003]why did you create hook.Add when you already overrode the gamemode function?[/QUOTE] I looked at a tutorial to help, and edited some things to see what the updates were, and I thought that was the thing.
[QUOTE=DJ Dippa;44938010]I looked at a tutorial to help, and edited some things to see what the updates were, and I thought that was the thing.[/QUOTE] [code] surface.CreateFont("s1", { font = "Arial", size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() --You declared this but didn't use it, which is pretty pointless but doesn't make a huge difference local HP = ply:Health() local ARM = ply:Armor() surface.SetTextColor(255, 255, 255, 255) surface.SetFont("s1") surface.SetTextPos(ScrW()-10, ScrH()-10) --do the positioning yourself, i'm not feeding you all of it surface.DrawText(hp) end [/code] try this
so is this correct, or am i stupid [CODE]function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end local ply = LocalPlayer() surface.CreateFont("s1", { font = "Arial", size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() end[/CODE]
Why declare ply as LocalPlayer() in the HUDPaint, and then use LocalPlayer() in HP and ARM?
[QUOTE=DJ Dippa;44938040]so is this correct, or am i stupid [CODE]function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end local ply = LocalPlayer() surface.CreateFont("s1", { font = "Arial", size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() local HP = LocalPlayer():Health() local ARM = LocalPlayer():Armor() end[/CODE][/QUOTE] do you want me to draw it for you too?..
[QUOTE=john552;44938060]do you want me to draw it for you too?..[/QUOTE] I'm guessing so I can figure out what I did wrong, because im not sure.
[QUOTE=DJ Dippa;44938087]I'm guessing so I can figure out what I did wrong, because im not sure.[/QUOTE] [CODE] surface.CreateFont("s1", { font = "Arial", --mistake #1, this was put at the end of surface.CreateFont table size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end --mistake #2, too many ends. should only be two. using return doesn't require an end end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) --mistake #3, HUDShouldDraw wasn't a string function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() --You declared this but didn't use it, which is pretty pointless but doesn't make a huge difference local HP = ply:Health() local ARM = ply:Armor() surface.SetTextColor(255, 255, 255, 255) surface.SetFont("s1") surface.SetTextPos(ScrW()-10, ScrH()-10) --do the positioning yourself, i'm not feeding you all of it surface.DrawText(hp) end [/CODE] what you did was override hudpaint and stop elements from being drawn, but you didn't draw anything yourself. what I did in the script above is draw some stuff for you with the surface library, do the positioning yourself though. i've also updated what was incorrect and would cause errors with your code. [url]http://wiki.garrysmod.com/page/Category:Lua_Tutorials[/url]
[QUOTE=john552;44938115][code] surface.CreateFont("s1", { font = "Arial", size = 20, weight = 900, antialias = true, shadow = false, }) function HUDHide( myhud ) for k, v in pairs{"CHUDHealth","CHUDBattery"} do if myhud == v then return false end end end hook.Add("HUDShouldDraw","HudHide123",HUDHide) function GM:HUDPaint() self.BaseClass:HUDPaint() local ply = LocalPlayer() --You declared this but didn't use it, which is pretty pointless but doesn't make a huge difference local HP = ply:Health() local ARM = ply:Armor() surface.SetTextColor(255, 255, 255, 255) surface.SetFont("s1") surface.SetTextPos(ScrW()-10, ScrH()-10) --do the positioning yourself, i'm not feeding you all of it surface.DrawText(hp) end [/code] what you did was override hudpaint and stop elements from being drawn, but you didn't draw anything yourself. what I did in the script above is draw some stuff for you with the surface library, do the positioning yourself though. [url]http://wiki.garrysmod.com/page/Category:Lua_Tutorials[/url][/QUOTE] OOOOOH, I'm stupid. Thank you.
[QUOTE=DJ Dippa;44938121]OOOOOH, I'm stupid. Thank you.[/QUOTE] i updated my post, read it
i'm not really sure atm, im tired, will look into this tomarrow, but im guessing its 0 , 0 but not sure. ill figure this out tomarrow [url]http://wiki.garrysmod.com/page/GM/HUDShouldDraw[/url] this says hudshoulddraw is a string
[QUOTE=DJ Dippa;44938209]i'm not really sure atm, im tired, will look into this tomarrow, but im guessing its 0 , 0 but not sure. ill figure this out tomarrow [url]http://wiki.garrysmod.com/page/GM/HUDShouldDraw[/url] this says hudshoulddraw is a string[/QUOTE] it is a string
Sorry, you need to Log In to post a reply to this thread.