HUD Text size too big for box?


draw.DrawText(""…LocalPlayer():getDarkRPVar(“job”)or 0, “PropFont1”, ScrW()-ScrW()+326, ScrH()-125, Color(255,255,255,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT)

Also if you can make my profile picture actaully fix the box when resolution is changed that’d be great

local function Avatar()
local Avatar = vgui.Create(“AvatarImage”)
Avatar:SetSize(ScrW() / 4 * 0.236, ScrW() / 4 * 0.236)
Avatar:SetPos(ScrW() * 0.019, ScrH() * 0.796)
Avatar:SetPlayer(LocalPlayer(), 64)
timer.Simple(.5, function()

The problem with dividing the ScrW and ScrH is that for different resolutions you’ll get different results, which wouldn’t be a problem if you used the same calculation everywhere for the base position.

Creating HUDs with efficient method for HUDShouldDraw:

How to hard-code the screen-size into your VGUI and then use a modifier to make it adjust properly to all screen resolutions:

Basically just setup variables where you hard-code it to your default game-resolution. Then, you need to define 2 vars with your resolution width and height, then you divide with the ScrW and ScrH of the client playing the game. For you the result will be 1 ( meaning you multiply all width vars with the modifier for width, and you multiply all height vars with the modifier for height; additionally you’d use the modifier for the x and y position using the width and height modifiers respectively ) and nothing will change. Smaller resolutions will have a value less than 1 and larger resolutions will have a value larger than 1.

I hope this helps making it easier.

If you want something that will fire a hook clientside ( and serverside if you network it ) when the resolution changes, take a look at this:

This is the example usage bit ( notice all vars are initialized as local to the file outside of the HUDPaint; when the hook for resolution change is fired we simply update those vars and re-create the poly table [ custom function, but instead of creating the poly table each frame we only make it once and update on change ] which helps with efficiency ):

So how can I apply this to the text being offset for jobs with longer titles?

You can scale the text as well with something like this:

local mat = Matrix()
mat:Scale( Vector( 1, 1, 1 ) * SCALE )


cam.PushModelMatrix( mat )
  --draw text here


I’m confused, how does that apply to the text being offset for different jobs?