• HUD Problem
    9 replies, posted
Hello Guys, I have a big Problem! I wanted to create a HUD. I wanted to show the Name of the Player. But now is my Problem: The bigger the name, the bigger the bug/ or whatever... With normal Name(no bugs/...) [URL="http://prntscr.com/duprpj"]http://prntscr.com/duprpj[/URL] With a big name(bug...) [URL="http://prntscr.com/dupqze"]http://prntscr.com/dupqze[/URL] Help pls! [editline]12th January 2017[/editline] The Same thing with Health and Velocity...
You need to align the text properly. Can you show us the code where the name is drawn?
I assume you're using this to draw the text; [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/SimpleText]draw.SimpleText[/url] If so, the last two arguments are the X & Y alignment. Set the X alignment to TEXT_ALIGN_LEFT
yes, draw.SimpleText [code]draw.SimpleText("Name:" ..name ,"HUDFont2",130 + 15, 615 + 15, Color(255,255,255),1,1)[/code] [editline]12th January 2017[/editline] The Same thing is with HP, when I have more then 100 Hp the HP bar gos forward... So out of Bar
If you want the text to be aligned at the left side, you can just leave the last two arguments. [lua] draw.SimpleText("Name:" ..name ,"HUDFont2",130 + 15, 615 + 15, Color(255,255,255)) [/lua] Otherwise you probably want to look at [URL="http://wiki.garrysmod.com/page/Enums/TEXT_ALIGN"]this[/URL].
Ok, thank you! [editline]12th January 2017[/editline] New problem! In Singleplayer my Picture is showing up, but I tried it on my Server and my Picture is a big ? Why? [code]local Avatar = vgui.Create( "AvatarImage", Panel ) Avatar:SetSize( 75, 75 ) Avatar:SetPos( 12, 625 ) Avatar:SetPlayer( LocalPlayer(), 64 )[/code] [editline]12th January 2017[/editline] Thats my Code
Thats because the player that you are trying to use (LocalPlayer) isnt loaded. You can change your "avatar-code" to something like this: [lua] local Avatar = vgui.Create( "AvatarImage", Panel ) Avatar:SetSize( 75, 75 ) Avatar:SetPos( 12, 625 ) hook.Add("InitPostEntity","HUD:CreateAvatar",function() Avatar:SetPlayer( LocalPlayer(), 64 ) end) [/lua] This will set the player after the player is initialized.
Sry I need to type it in German! Benn Ich brauch noch einmal Hilfe! Die HP und Velocity Bars überschreiten die Grenze wenn es über 100 HP oder 1000 Velocity ist Was kann man dagegen tun? SRY FOR GERMAN!
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/math/min]math.min[/url], for example [code]local hp = math.min(ply:Health(), 100) -- 100 is maximum, use this variable in your weight arg[/code]
Omg it Works! But how did ya understood it? XD [editline]12th January 2017[/editline] THANKS TO EVERYONE!!!:freakout::excited::chem101:
Sorry, you need to Log In to post a reply to this thread.