Re-Positioning A HUD

I was wondering if someone could help me. Iv been messing around with numbers for the past like 3 hours and i still can get this right.

I got this hud and i noticed that it was really high up on my screen. So i tried re-positioning the hud but the silkicons, lettering, and the heath/armor bar were

all out of place.

If someone could help me ASAP that would be great.

I would like it to be at the bottom left of the screen

[lua]/---------------------------------------------------------------------------
HUD ConVars
---------------------------------------------------------------------------
/
local ConVars = {}
local HUDWidth
local HUDHeight

local function ReloadConVars()
ConVars = {
background = {0,0,0,100},
Healthbackground = {0,0,0,200},
Healthforeground = {140,0,0,180},
HealthText = {255,255,255,200},
Job1 = {0,0,150,200},
Job2 = {0,0,0,255},
salary1 = {0,150,0,200},
salary2 = {0,0,0,255}
}

for name, Colour in pairs(ConVars) do
	ConVars[name] = {}
	for num, rgb in SortedPairs(Colour) do
		local CVar = GetConVar(name..num) or CreateClientConVar(name..num, rgb, true, false)
		table.insert(ConVars[name], CVar:GetInt())

		if not cvars.GetConVarCallbacks(name..num, false) then
			cvars.AddChangeCallback(name..num, function() timer.Simple(0,ReloadConVars) end)
		end
	end
	ConVars[name] = Color(unpack(ConVars[name]))
end

end
ReloadConVars()

local function formatNumber(n)
if (!n) then
return 0
end
if n >= 1e14 then return tostring(n) end
n = tostring(n)
sep = sep or “.”
local dp = string.find(n, “%.”) or #n+1
for i=dp-4, 1, -3 do
n = n:sub(1, i) … sep … n:sub(i+1)
end
return n
end

local Scrw, Scrh, RelativeX, RelativeY
/---------------------------------------------------------------------------
HUD Seperate Elements
---------------------------------------------------------------------------
/
local PlayerTexture = surface.GetTextureID(“gui/silkicons/user”) // Player name
local MoneyTexture = surface.GetTextureID(“breens-protector/money”) // Wallet
local MoneyAddTexture = surface.GetTextureID(“breens-protector/money_add”) // Salary
local JobTexture = surface.GetTextureID(“gui/silkicons/group”) // Job
local HealthTexture = surface.GetTextureID(“gui/silkicons/heart”) // Health
local ArmorTexture = surface.GetTextureID(“gui/silkicons/shield”) // Armor
local PageTexture = surface.GetTextureID(“gui/silkicons/page”) // Gun License

local HUDWidth = 300
local HUDHeight = 180
local Offset = 0

local function DrawText(x, y, text, font)
surface.SetFont(font)

surface.SetTextPos(x,y)
surface.SetTextColor(255,255,255,255)
surface.DrawText(text)

end

local function DrawGenericHud()

local HUDWidth = 300
local HUDHeight = 180
local Offset = 0

local len = surface.GetTextSize(formatNumber(LocalPlayer().DarkRPVars.money)) / 2

// Background
draw.RoundedBox(4, Offset - len, (ScrH() - 190) - Offset, 180, 25, Color(0,0,0,200))

draw.RoundedBox(4, Offset, (ScrH() - 160) - Offset, HUDWidth - 35, 25, Color(0,0,0,200))

draw.RoundedBox(4, Offset + 185, (ScrH() - 130) - Offset, 80, 25, Color(0,0,0,200))

draw.RoundedBox(4, Offset, (ScrH() - 130) - Offset, 180, 25, Color(0,0,0,200))

draw.RoundedBox(4, Offset, (ScrH() - 100) - Offset, 180, 25, Color(0,0,0,200))

if LocalPlayer():Armor() > 1 then
draw.RoundedBox(4, Offset, (ScrH() - 70) - Offset, 180, 25, Color(0,0,0,200))
end

// Health and Armor

local PlayerHealth = 135 / 100 * LocalPlayer():Health()

if LocalPlayer():Health() > 1 then
draw.RoundedBox(4, 40, (ScrH() - 98) - Offset, PlayerHealth, 20, Color(255,0,0,200))
draw.RoundedBox(4, 40, (ScrH() - 98) - Offset, PlayerHealth, 10, Color(255,255,255,50))
end

local PlayerAmor = 135 / 100 * LocalPlayer():Armor()

if LocalPlayer():Armor() > 1 then
draw.RoundedBox(4, 40, (ScrH() - 68) - Offset, PlayerAmor, 20, Color(0,178,255,200))
draw.RoundedBox(4, 40, (ScrH() - 68) - Offset, PlayerAmor, 10, Color(255,255,255,50))
end

// Playername
surface.SetTexture(PlayerTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 10, ((ScrH() - 165) - Offset) + 10, 16, 16)

// Wallet
surface.SetTexture(MoneyTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 10, ((ScrH() - HUDHeight - 38) - Offset) + 32, 16, 16)

// Sallary
surface.SetTexture(MoneyAddTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 190, ((ScrH() - 158) - Offset) + 32, 16, 16)

// Job
surface.SetTexture(JobTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 10, ((ScrH() - 208) - Offset) + 82, 16, 16)

// Health
surface.SetTexture(HealthTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 10, ((ScrH() - 202) - Offset) + 107, 16, 16)

if LocalPlayer():Armor() > 1 then
// Armor
surface.SetTexture(ArmorTexture)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(Offset + 10, ((ScrH() - 198) - Offset) + 132, 16, 16)
end

DrawText(Offset + 40, ((ScrH() - HUDHeight) - Offset) - 9, CUR … (formatNumber(LocalPlayer().DarkRPVars.money) or 0), “TargetID”)
DrawText(Offset + 40 , ((ScrH() - HUDHeight) - Offset) + 21, LocalPlayer():Nick() or “”, “TargetID”)
DrawText(Offset + 215, ((ScrH() - HUDHeight) - Offset) + 50, CUR … (LocalPlayer().DarkRPVars.salary or 0), “TargetID”)
DrawText(Offset + 40, ((ScrH() - HUDHeight) - Offset) + 50, LocalPlayer().DarkRPVars.job or “”, “TargetID”)
if LocalPlayer():Health() > 1 then
DrawText(Offset + 94, ((ScrH() - HUDHeight) - Offset) + 80, LocalPlayer():Health() or 0, “TargetID”)
end

if LocalPlayer():Armor() > 1 then
DrawText(Offset + 94, ((ScrH() - HUDHeight) - Offset) + 111, LocalPlayer():Armor() or 0, “TargetID”)
end

end

local function JobHelp()
local Helps = {“Cop”, “Mayor”, “Admin”, “Boss”}

for k,v in pairs(Helps) do
	if LocalPlayer().DarkRPVars["help"..v] then
		draw.RoundedBox(10, 10, 10, 590, 194, Color(0, 0, 0, 255))
		draw.RoundedBox(10, 12, 12, 586, 190, Color(51, 58, 51, 200))
		draw.RoundedBox(10, 12, 12, 586, 20, Color(0, 0, 70, 200))
		draw.DrawText(v.." Help", "ScoreboardText", 30, 12, Color(255,0,0,255),0)
		draw.DrawText(string.format(LANGUAGE[v:lower().."help"], GetConVarNumber("jailtimer")), "ScoreboardText", 30, 35, Color(255,255,255,255),0)
	end
end

end

local function Agenda()
local DrawAgenda, AgendaManager = DarkRPAgendas[LocalPlayer():Team()], LocalPlayer():Team()
if not DrawAgenda then
for k,v in pairs(DarkRPAgendas) do
if table.HasValue(v.Listeners, LocalPlayer():Team()) then
DrawAgenda, AgendaManager = DarkRPAgendas[k], k
break
end
end
end
if DrawAgenda then
draw.RoundedBox(10, 10, 10, 460, 110, Color(0, 0, 0, 155))
draw.RoundedBox(10, 12, 12, 456, 106, Color(51, 58, 51,100))
draw.RoundedBox(10, 12, 12, 456, 20, Color(0, 0, 70, 100))

	draw.DrawText(DrawAgenda.Title, "ScoreboardText", 30, 12, Color(255,0,0,255),0)
	
	local AgendaText = ""
	for k,v in pairs(team.GetPlayers(AgendaManager)) do
		AgendaText = AgendaText .. (v.DarkRPVars.agenda or "")
	end
	draw.DrawText(string.gsub(string.gsub(AgendaText, "//", "

"), "
", "
"), “ScoreboardText”, 30, 35, Color(255,255,255,255),0)
end
end

local VoiceChatTexture = surface.GetTextureID(“voice/icntlk_pl”)
local function DrawVoiceChat()
if LocalPlayer().DRPIsTalking then
if not LocalPlayer():Alive() then return end

	local chbxX, chboxY = chat.GetChatBoxPos()

	local Rotating = math.sin(CurTime()*3)
	local backwards = 0
	if Rotating < 0 then
		Rotating = 1-(1+Rotating)
		backwards = 180
	end
	surface.SetTexture(VoiceChatTexture)
	surface.SetDrawColor(140,0,0,180)
	surface.DrawTexturedRectRotated(ScrW() - 100, chboxY, Rotating*96, 96, backwards)
end

end

local function LockDown()
local chbxX, chboxY = chat.GetChatBoxPos()
if util.tobool(GetConVarNumber(“DarkRP_LockDown”)) then
local cin = (math.sin(CurTime()) + 1) / 2
draw.DrawText(LANGUAGE.lockdown_started, “ScoreboardSubtitle”, chbxX, chboxY - 25, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
end
end

local Arrested = function() end

usermessage.Hook(“GotArrested”, function(msg)
local StartArrested = CurTime()
local ArrestedUntil = msg:ReadFloat()

Arrested = function()
	if CurTime() - StartArrested <= ArrestedUntil and LocalPlayer().DarkRPVars.Arrested then
	draw.DrawText(string.format(LANGUAGE.youre_arrested, math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "ScoreboardText", ScrW()/2, ScrH() - ScrH()/12, Color(255,255,255,255), 1)
	elseif not LocalPlayer().DarkRPVars.Arrested then 
		Arrested = function() end
	end
end

end)

local AdminTell = function() end

usermessage.Hook(“AdminTell”, function(msg)
local Message = msg:ReadString()

AdminTell = function() 
	draw.RoundedBox(4, 10, 10, ScrW() - 20, 100, Color(0, 0, 0, 255))
	draw.DrawText(LANGUAGE.listen_up, "GModToolName", ScrW() / 2 + 10, 10, Color(255, 255, 255, 255), 1)
	draw.DrawText(Message, "ChatFont", ScrW() / 2 + 10, 65, Color(200, 30, 30, 255), 1)
end

timer.Simple(10, function() 
	AdminTell = function() end
end)

end)

// NLR
local NLRWidth = 600
local NLRHeigt = 200
local NLRText = “Beachte die NLR (New Life Rule)! Du hast nun alles vergessen!”
local function DrawNLR()
if not LocalPlayer():Alive() then
// Background
draw.RoundedBox(6, (ScrW() - NLRWidth) / 2, (ScrH() - NLRHeigt) / 2, NLRWidth, NLRHeigt, Color(0,0,0,200))

	// Text
	surface.SetFont("TargetID")
	
	local NLRTSizeW, NLRTSizeH = surface.GetTextSize(NLRText)
	surface.SetTextPos((ScrW() - NLRTSizeW) / 2, (ScrH() - NLRTSizeH) / 2)
	surface.SetTextColor(255,255,255,255)
	surface.DrawText(NLRText)
end

end

// EXP
local EXPOffset = 0
local EXPBarWidth = 300
local EXPBarHeight = 20
local EXPBarX = (ScrW() - EXPBarWidth) / 2
local EXPBarY = (ScrH() - EXPBarHeight) - EXPOffset

/---------------------------------------------------------------------------
Drawing the HUD elements such as Health etc.
---------------------------------------------------------------------------
/
local function DrawHUD()
Scrw, Scrh = ScrW(), ScrH()
RelativeX, RelativeY = 0, Scrh

DrawGenericHud()
Agenda()
JobHelp()
DrawVoiceChat()
LockDown()

Arrested()
AdminTell()

DrawNLR()

end

/---------------------------------------------------------------------------
Entity HUDPaint things
---------------------------------------------------------------------------
/
local function DrawPlayerInfo(ply)
local pos = ply:EyePos()

pos.z = pos.z + 34
pos = pos:ToScreen()

if GetConVarNumber("nametag") == 1 then
	draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
	draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1)
	draw.DrawText(LANGUAGE.health ..ply:Health(), "TargetID", pos.x + 1, pos.y + 21, Color(0, 0, 0, 255), 1)
	draw.DrawText(LANGUAGE.health..ply:Health(), "TargetID", pos.x, pos.y + 20, Color(255,255,255,200), 1)
end

if GetConVarNumber("jobtag") == 1 then
	draw.DrawText(ply.DarkRPVars.job or "", "TargetID", pos.x + 1, pos.y + 41, Color(0, 0, 0, 255), 1)
	draw.DrawText(ply.DarkRPVars.job or "", "TargetID", pos.x, pos.y + 40, Color(255, 255, 255, 200), 1)
end
/*
if ply.DarkRPVars.HasGunlicense then
	surface.SetTexture(surface.GetTextureID("gui/silkicons/page"))
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
end
*/

end

local function DrawWantedInfo(ply)
if not ply:Alive() then return end

local pos = ply:EyePos()
if not pos:RPIsInSight({LocalPlayer(), ply}) then return end

pos.z = pos.z + 14
pos = pos:ToScreen()

if GetConVarNumber("nametag") == 1 then
	draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
	draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1)
end

draw.DrawText(LANGUAGE.wanted.."

Reason: “…tostring(ply.DarkRPVars[“wantedReason”]), “TargetID”, pos.x, pos.y - 40, Color(255, 255, 255, 200), 1)
draw.DrawText(LANGUAGE.wanted…”
Reason: "…tostring(ply.DarkRPVars[“wantedReason”]), “TargetID”, pos.x + 1, pos.y - 41, Color(255, 0, 0, 255), 1)
end

/---------------------------------------------------------------------------
The Entity display: draw HUD information about entities
---------------------------------------------------------------------------
/
local function DrawEntityDisplay()
for k, ply in pairs(player.GetAll()) do
if not ply:Alive() then continue end

	ply.DarkRPVars = ply.DarkRPVars or {}
	if ply.DarkRPVars.wanted then DrawWantedInfo(ply) end

	if GetConVarNumber("globalshow") == 1 and ply ~= LocalPlayer() then DrawPlayerInfo(ply) end
end

local tr = LocalPlayer():GetEyeTrace()
if tr.Entity and tr.Entity.IsValid and ValidEntity(tr.Entity) and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 400 then
	if tr.Entity:IsPlayer() and not tobool(GetConVarNumber("globalshow")) then
		DrawPlayerInfo(tr.Entity)
	end
end

if tr.Entity:IsOwnable() and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 200 then
	tr.Entity:DrawOwnableInfo()
end

end
[/lua]

Hate to break it to you, kid… but nobody is going to fix / write you code for free.

then would you like the $2 to fix it?

That’s what you get for using constants, instead of variables >_>

Just move each thing by the same amount, and they wont get out of place…

I made this HUD fully functional with moving it around on the screen, so you only need to change 2 variables now. Add me on Steam I already sent you a friends request.(Inferno, Eh?)

^ Nice person there.

When making clientside things like this in future, remember to use variables for positioning.
It’s a lot easier to reposition things if you just need to change named variables at the beginning of the file.