Help converting code. DarkRP Hud

Old Code




/*---------------------------------------------------------------------------
HUD ConVars
---------------------------------------------------------------------------*/
surface.CreateFont( "SpankyID", {
	font = "TargetID",
	size = 13,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = true,
	symbol = false,
	rotary = false,
	shadow = true,
	additive = false,
	outline = false,
} )

local ConVars = {}
local HUDWidth
local HUDHeight

CreateClientConVar("weaponhud", 0, true, false)

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


	HUDWidth = (GetConVar("HudW") or  CreateClientConVar("HudW", 240, true, false)):GetInt()
	HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()

	if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
		cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
		cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
	end
end
ReloadConVars()

local function formatNumber(n)
	n = tonumber(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 function DrawInfo()
	LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
	local Salary = 	"$" .. (LocalPlayer().DarkRPVars.salary or 0)

	local JobWallet =
	LANGUAGE.job .. (LocalPlayer().DarkRPVars.job or "") .. "
"..
	"$" .. (formatNumber(LocalPlayer().DarkRPVars.money) or 0)

	local wep = LocalPlayer( ):GetActiveWeapon( );

	if IsValid(wep) and GAMEMODE.Config.weaponhud then
        local name = wep:GetPrintName();
		draw.DrawText("Weapon: "..name, "UiBold", RelativeX + 5, RelativeY - HUDHeight - 18, Color(255, 255, 255, 255), 0)
	end
end

local Page = Material("icon16/page_white_text.png")
local function GunLicense()
	if LocalPlayer().DarkRPVars.HasGunlicense then
		surface.SetMaterial(Page)
		surface.SetDrawColor(255, 255, 255, 255)
		surface.DrawTexturedRect(RelativeX + HUDWidth, ScrH() - 34, 32, 32)
	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 or {}, LocalPlayer():Team()) then
				DrawAgenda, AgendaManager = DarkRPAgendas[k], k
				break
			end
		end
	end
	if DrawAgenda then
		draw.RoundedBox(0, 10, 10, 460, 110, Color(0, 0, 0, 155))
		draw.RoundedBox(0, 12, 12, 456, 106, Color(51, 58, 51,100))
		draw.RoundedBox(0, 12, 12, 456, 20, Color(0, 0, 70, 100))

		draw.DrawText(DrawAgenda.Title, "DarkRPHUD1", 30, 12, Color(255,0,0,255),0)

		local AgendaText = ""
		for k,v in pairs(team.GetPlayers(AgendaManager)) do
			if not v.DarkRPVars then continue end
			AgendaText = AgendaText .. (v.DarkRPVars.agenda or "") .. "
"
		end
		draw.DrawText(string.gsub(string.gsub(AgendaText, "//", "
"), "\
", "
"), "DarkRPHUD1", 30, 35, Color(255,255,255,255),0)
	end
end

local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
local function DrawVoiceChat()
	if LocalPlayer().DRPIsTalking then
		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(ConVars.Healthforeground)
		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
		local chatBoxSize = math.floor(ScrH() / 4)
		draw.DrawText(LANGUAGE.lockdown_started, "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, 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))), "DarkRPHUD1", 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, 200))
		draw.DrawText(LANGUAGE.listen_up, "GModToolName", ScrW() / 2 + 10, 10, Color(255, 255, 255, 255), 1)
		draw.DrawText(Message, "ChatFont", ScrW() / 2 + 10, 80, Color(200, 30, 30, 255), 1)
	end

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

 
hook.Add("PlayerSpawnedProp", "propCounter", function( ply, model, ent )
	ent.Owner = ply
end)

function timeToStr( time )
	local tmp = time
	local s = tmp % 60
	tmp = math.floor( tmp / 60 )
	local m = tmp % 60
	tmp = math.floor( tmp / 60 )
	local h = tmp % 24
	tmp = math.floor( tmp / 24 )
	local d = tmp % 7
	local w = math.floor( tmp / 7 )

	return string.format( "%2i hours and %2i minutes", h, m)
end
/*---------------------------------------------------------------------------
Drawing the HUD elements such as Health etc.
---------------------------------------------------------------------------*/
name = Material("icon16/user.png")
job = Material("icon16/wrench.png")
salarr = Material("icon16/money.png")
banii = Material("icon16/money_dollar.png")
played = Material("icon16/time.png")

local function MyHUD()
	net.Receive( "FuelMod", function( len )	 
		veh = net.ReadEntity()
		gas = net.ReadFloat()
	end ) 
		local newtime = string.ToMinutesSeconds(CurTime())
		local ply = LocalPlayer()
		local hp,ar = ply:Health(),ply:Armor()
		local slujba = LocalPlayer().DarkRPVars.job or "Unemployed"
		local salar = LocalPlayer().DarkRPVars.salary or "NONE"
		local bani = LocalPlayer().DarkRPVars.money or "NONE"
		local hr = LocalPlayer().DarkRPVars.Energy
		local pr = LocalPlayer():GetCount("props")
		local sta = LocalPlayer():GetNWInt( "tcb_Stamina" )
		local totaltime = timeToStr(LocalPlayer():GetUTimeTotalTime())
		local showstamina = true
	LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
	LocalPlayer().DarkRPVars.Energy = LocalPlayer().DarkRPVars.Energy or 0
	
if (ply:Alive()) then
                
                draw.RoundedBox(0,5,ScrH() - 145,270,25,Color(0,0,0,200))
		
		draw.RoundedBox(0,5,ScrH() - 175,270,25,Color(0,0,0,200))

		surface.SetMaterial(name)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 110,16,16)
		draw.SimpleText("Vist: www.4lategaming.com","TargetID",10,ScrH() - 142)
	draw.RoundedBox(0,5,ScrH() - 115,270,110,Color(0,0,0,200))
	
		surface.SetMaterial(name)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(10,ScrH() - 110,16,16)
	draw.SimpleText("Name: "..ply:Nick(),"TargetID",30,ScrH() - 110)
	
		surface.SetMaterial(job)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(10,ScrH() - 90,16,16)
	draw.SimpleText("Job: "..slujba,"TargetID",30,ScrH() - 90)
	
		surface.SetMaterial(salarr)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(10,ScrH() - 70,16,16)
	draw.SimpleText("Salary: $"..salar,"TargetID",30,ScrH() - 70)
	
			surface.SetMaterial(banii)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(10,ScrH() - 50,16,16)
	draw.SimpleText("Wallet: $"..bani,"TargetID",30,ScrH() - 50)
	
				surface.SetMaterial(played)
	surface.SetDrawColor(255,255,255,255)
	surface.DrawTexturedRect(10,ScrH() - 30,16,16)
	draw.SimpleText(totaltime,"TargetID",30,ScrH() - 30)
	
	draw.RoundedBox(0,280,ScrH() - 25,150,20,Color(0,0,0,200))
	draw.RoundedBox(0,282,ScrH() - 23,math.Clamp(hp,0,100)*1.46,16,Color(127,0,0,200))
	draw.SimpleText("Health: "..hp,"SpankyID",320,ScrH() - 23)
	
	--if (hr > 0) then
		draw.RoundedBox(0,280,ScrH() - 48,150,20,Color(0,0,0,200))
	draw.RoundedBox(0,282,ScrH() - 46,math.Clamp(hr,0,100)*1.46,16,Color(125,226,43,200))
	draw.SimpleText("Hunger: "..hr,"SpankyID",320,ScrH() - 46)
	--end
	local prcolor = Color(255,148,0,200)
	if (ar > 0) then
		draw.SimpleText("[Armor]","SpankyID",379,ScrH() - 23)
	end
	local multi = 1.46
	-- 1.46
	if (pr > 39) and ply:IsUserGroup("user") or ply:IsUserGroup("user_acces") then
	multi = 3.65
	prcolor = Color(255,0,0,200)
	end
	if (pr > 79) and ply:IsUserGroup("superdonator") or  ply:IsUserGroup("trusted") then
	multi = 1.83
	prcolor = Color(255,0,0,200)
	end
	if (pr > 119) and ply:IsUserGroup("donator") then
	multi = 1.46
	prcolor = Color(255,0,0,200)
	end
	if (pr > 149) and ply:IsUserGroup("trial") or  ply:IsUserGroup("admin") then
	multi = 1.46
	prcolor = Color(255,0,0,200)
	end
	if ply:InVehicle() then
		draw.RoundedBox(0,280,ScrH() - 94,150,20,Color(0,0,0,200))
		draw.RoundedBox(0,282,ScrH() - 92,math.Clamp(gas,0,100)*1.46,16,Color(255,148,0,200))
		draw.SimpleText("Fuel: "..string.format("%.1f", gas),"SpankyID",320,ScrH() - 92)
		

					
			draw.RoundedBox(0,280,ScrH() - 71,150,20,Color(0,0,0,200))
			draw.RoundedBox(0,282,ScrH() - 69,math.Clamp(pr,0,100)*multi,16,prcolor)
			draw.SimpleText("Props: "..pr,"SpankyID",320,ScrH() - 69)
	else
			draw.RoundedBox(0,280,ScrH() - 71,150,20,Color(0,0,0,200))
			draw.RoundedBox(0,282,ScrH() - 69,math.Clamp(sta,0,100)*1.46,16,Color(0,148,255,200))
			draw.SimpleText("Stamina: "..sta,"SpankyID",320,ScrH() - 69)
			
		draw.RoundedBox(0,280,ScrH() - 94,150,20,Color(0,0,0,200))
		draw.RoundedBox(0,282,ScrH() - 92,math.Clamp(pr,0,100)*multi,16,prcolor)
		draw.SimpleText("Props: "..pr,"SpankyID",320,ScrH() - 92)
	end
return
false
end
end

local function DrawHUD()
	Scrw, Scrh = ScrW(), ScrH()
	RelativeX, RelativeY = 0, Scrh
	
	MyHUD()
	DrawInfo()
	GunLicense()
	Agenda()
	DrawVoiceChat()
	LockDown()
	Arrested()
	AdminTell()
end

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

	pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
	pos = pos:ToScreen()
	pos.y = pos.y - 50 -- Move the text up a few pixels to compensate for the height of the text

	if GAMEMODE.Config.showname and not ply.DarkRPVars.wanted then
		draw.DrawText(ply:Nick(), "DarkRPHUD2", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
		draw.DrawText(ply:Nick(), "DarkRPHUD2", pos.x, pos.y, team.GetColor(ply:Team()), 1)
		draw.DrawText("Health: "..ply:Health(), "DarkRPHUD2", pos.x + 1, pos.y + 21, Color(0, 0, 0, 255), 1)
		draw.DrawText("Health: "..ply:Health(), "DarkRPHUD2", pos.x, pos.y + 20, Color(255,255,255,200), 1)
	end

	if GAMEMODE.Config.showjob then
		local teamname = team.GetName(ply:Team())
		draw.DrawText(ply.DarkRPVars.job or teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, Color(0, 0, 0, 255), 1)
		draw.DrawText(ply.DarkRPVars.job or teamname, "DarkRPHUD2", pos.x, pos.y + 40, Color(255, 255, 255, 200), 1)
	end

	if ply.DarkRPVars.HasGunlicense then
		surface.SetMaterial(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 GAMEMODE.Config.showname then
		draw.DrawText(ply:Nick(), "DarkRPHUD2", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
		draw.DrawText(ply:Nick(), "DarkRPHUD2", pos.x, pos.y, team.GetColor(ply:Team()), 1)
	end

	draw.DrawText(LANGUAGE.wanted.."
Reason: "..tostring(ply.DarkRPVars["wantedReason"]), "DarkRPHUD2", pos.x, pos.y - 40, Color(255, 255, 255, 200), 1)
	draw.DrawText(LANGUAGE.wanted.."
Reason: "..tostring(ply.DarkRPVars["wantedReason"]), "DarkRPHUD2", pos.x + 1, pos.y - 41, Color(255, 0, 0, 255), 1)
end
]]
/*---------------------------------------------------------------------------
The Entity display: draw HUD information about entities
---------------------------------------------------------------------------*/
local function DrawEntityDisplay()
	local shootPos = LocalPlayer():GetShootPos()
	local aimVec = LocalPlayer():GetAimVector()

	for k, ply in pairs(player.GetAll()) do
		if not ply:Alive() then continue end
		local hisPos = ply:GetShootPos()

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

		if GAMEMODE.Config.globalshow and ply ~= LocalPlayer() then
			DrawPlayerInfo(ply)
		-- Draw when you're (almost) looking at him
		elseif not GAMEMODE.Config.globalshow and hisPos:Distance(shootPos) < 400 then
			local pos = hisPos - shootPos
			local unitPos = pos:GetNormalized()
			if unitPos:Dot(aimVec) > 0.95 then
				local trace = util.QuickTrace(shootPos, pos, LocalPlayer())
				if trace.Hit and trace.Entity ~= ply then return end
				DrawPlayerInfo(ply)
			end
		end
	end

	local tr = LocalPlayer():GetEyeTrace()

	if tr.Entity:isKeysOwnable() and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 200 then
		tr.Entity:drawOwnableInfo()
	end
end

/*---------------------------------------------------------------------------
Zombie display
---------------------------------------------------------------------------*/
local function DrawZombieInfo()
	if not LocalPlayer().DarkRPVars.zombieToggle then return end
	for x=1, LocalPlayer().DarkRPVars.numPoints, 1 do
		local zPoint = LocalPlayer().DarkRPVars["zPoints".. x]
		if zPoint then
			zPoint = zPoint:ToScreen()
			draw.DrawText("Zombie Spawn (" .. x .. ")", "DarkRPHUD2", zPoint.x, zPoint.y - 20, Color(255, 255, 255, 200), 1)
			draw.DrawText("Zombie Spawn (" .. x .. ")", "DarkRPHUD2", zPoint.x + 1, zPoint.y - 21, Color(255, 0, 0, 255), 1)
		end
	end
end

/*---------------------------------------------------------------------------
Actual HUDPaint hook
---------------------------------------------------------------------------*/
function GM:HUDPaint()
	DrawHUD()
	DrawZombieInfo()
	DrawEntityDisplay()

	self.BaseClass:HUDPaint()
end



New Code




/*---------------------------------------------------------------------------
HUD ConVars
---------------------------------------------------------------------------*/
local ConVars = {}
local HUDWidth
local HUDHeight

local Color = Color
local CurTime = CurTime
local cvars = cvars
local DarkRP = DarkRP
local draw = draw
local GetConVar = GetConVar
local hook = hook
local IsValid = IsValid
local Lerp = Lerp
local localplayer
local math = math
local pairs = pairs
local ScrW, ScrH = ScrW, ScrH
local SortedPairs = SortedPairs
local string = string
local surface = surface
local table = table
local timer = timer
local tostring = tostring
local plyMeta = FindMetaTable("Player")

local colors = {}
colors.black = Color(0, 0, 0, 255)
colors.blue = Color(0, 0, 255, 255)
colors.brightred = Color(200, 30, 30, 255)
colors.darkred = Color(0, 0, 70, 100)
colors.darkblack = Color(0, 0, 0, 200)
colors.gray1 = Color(0, 0, 0, 155)
colors.gray2 = Color(51, 58, 51,100)
colors.red = Color(255, 0, 0, 255)
colors.white = Color(255, 255, 255, 255)
colors.white1 = Color(255, 255, 255, 200)

local function formatNumber(n)
	if not n then return "" end
	if n >= 1e14 then return tostring(n) end
    n = tostring(n)
    local 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 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


	HUDWidth = (GetConVar("HudW") or  CreateClientConVar("HudW", 240, true, false)):GetInt()
	HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()

	if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
		cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
		cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
	end
end
ReloadConVars()

local Scrw, Scrh, RelativeX, RelativeY

local Page = Material("icon16/page_white_text.png")
local function GunLicense()
	if localplayer:getDarkRPVar("HasGunlicense") then
		surface.SetMaterial(Page)
		surface.SetDrawColor(255, 255, 255, 255)
		surface.DrawTexturedRect(RelativeX + HUDWidth, Scrh - 34, 32, 32)
	end
end

local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl")
local function DrawVoiceChat()
	if localplayer.DRPIsTalking then
		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(ConVars.Healthforeground)
		surface.DrawTexturedRectRotated(Scrw - 100, chboxY, Rotating*96, 96, backwards)
	end
end

local function LockDown()
	local chbxX, chboxY = chat.GetChatBoxPos()
	if GetGlobalBool("DarkRP_LockDown") then
		local cin = (math.sin(CurTime()) + 1) / 2
		local chatBoxSize = math.floor(Scrh / 4)
		draw.DrawNonParsedText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, 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:getDarkRPVar("Arrested") then
			draw.DrawNonParsedText(DarkRP.getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "DarkRPHUD1", Scrw/2, Scrh - Scrh/12, colors.white, 1)
		elseif not localplayer:getDarkRPVar("Arrested") then
			Arrested = function() end
		end
	end
end)

local AdminTell = function() end

usermessage.Hook("AdminTell", function(msg)
	timer.Destroy("DarkRP_AdminTell")
	local Message = msg:ReadString()

	AdminTell = function()
		draw.RoundedBox(4, 10, 10, Scrw - 20, 110, colors.darkblack)
		draw.DrawNonParsedText(DarkRP.getPhrase("listen_up"), "GModToolName", Scrw / 2 + 10, 10, colors.white, 1)
		draw.DrawNonParsedText(Message, "ChatFont", Scrw / 2 + 10, 90, colors.brightred, 1)
	end

	timer.Create("DarkRP_AdminTell", 10, 1, function()
		AdminTell = function() end
	end)
end)

/*---------------------------------------------------------------------------
Drawing the HUD elements such as Health etc.
---------------------------------------------------------------------------*/
name = Material("icon16/user.png")
jobM = Material("icon16/wrench.png")
salaryM = Material("icon16/money.png")
moneyM = Material("icon16/money_dollar.png")
played = Material("icon16/time.png")
webstieM = Material("icon16/world.png")

local function MyHUD()
	local newtime = string.ToMinutesSeconds(CurTime())
	local ply = LocalPlayer()
	local hp,ar = ply:Health(),ply:Armor()
	local job = ply:getDarkRPVar("job") or ""
	local salary = ply:getDarkRPVar("salary") or ""
	local money = formatNumber(ply:getDarkRPVar("money")) or ""
	local hunger = ply:getDarkRPVar("Energy") or ""
	local enableHunger = true
	
	if (ply:Alive()) then
		draw.RoundedBox(0,5,ScrH() - 115,270,110,Color(0,0,0,200))
                
                surface.SetMaterial(webstieM)
                surface.SetDrawColor(255,255,255,255)
                surface.DrawTexturedRect(10,ScrH() - 138,16,16)
                draw.RoundedBox(0,5,ScrH() - 140,270,20,Color(0,0,0,200))
                draw.SimpleText("Vist: www.4lategaming.com","TargetID",30,ScrH() - 138)
			
                        surface.SetMaterial(name)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 110,16,16)
		draw.SimpleText("Name: "..ply:Nick(),"TargetID",30,ScrH() - 110)
		
			surface.SetMaterial(jobM)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 90,16,16)
		draw.SimpleText("Job: "..job,"TargetID",30,ScrH() - 90)
		
			surface.SetMaterial(salaryM)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 70,16,16)
		draw.SimpleText("Salary: "..salary,"TargetID",30,ScrH() - 70)
		
			surface.SetMaterial(moneyM)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 50,16,16)
		draw.SimpleText("Wallet: "..money,"TargetID",30,ScrH() - 50)
		
			surface.SetMaterial(played)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(10,ScrH() - 30,16,16)
		draw.SimpleText("Session: "..newtime,"TargetID",30,ScrH() - 30)
		
		draw.RoundedBox(0,280,ScrH() - 25,150,20,Color(0,0,0,200))
		draw.RoundedBox(0,282,ScrH() - 23,math.Clamp(hp,0,100)*1.46,16,Color(127,0,0,200))
		draw.SimpleText("Health: "..hp,"TargetID",320,ScrH() - 23)
		
		if (enableHunger == true) then
			draw.RoundedBox(0,280,ScrH() - 50,150,20,Color(0,0,0,200))
		draw.RoundedBox(0,282,ScrH() - 48,math.Clamp(hunger,0,100)*1.46,16,Color(125,226,43,200))
		draw.SimpleText("Hunger: "..hunger,"TargetID",320,ScrH() - 48)
		end
		
		if (ar > 0) then
			draw.RoundedBox(0,280,ScrH() - 75,150,20,Color(0,0,0,200))
		draw.RoundedBox(0,282,ScrH() - 73,math.Clamp(ar,0,100)*1.46,16,Color(0,148,255,200))
		draw.SimpleText("Kevlar: "..ar,"TargetID",320,ScrH() - 73)
		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 or {}, localplayer:Team()) then
				DrawAgenda, AgendaManager = DarkRPAgendas[k], k
				break
			end
		end
	end
	if DrawAgenda then
		draw.RoundedBox(0, 10, 10, 460, 110, Color(20, 20, 20, 230))
		draw.RoundedBox(0, 10, 10, 460, 40, Color(20, 20, 50, 255))

		draw.DrawText(DrawAgenda.Title, "GTAFont", 20, 0, Color(230,230,230,255),0)

		local AgendaText = {}
		for k,v in pairs(team.GetPlayers(AgendaManager)) do
			if not v.DarkRPVars then continue end
			table.insert(AgendaText, v:getDarkRPVar("agenda"))
		end
	
		if Bo.DarkRP_Old == true then
			local text = table.concat(AgendaText, "
")
			text = text:gsub("//", "
"):gsub("\
", "
")
			text = GAMEMODE:TextWrap(text, "DarkRPHUD1", 440)
			draw.DrawText(text, "DarkRPHUD1", 30, 35, Color(255,255,255,255),0)
		else	
			local text = table.concat(AgendaText, "
")
			text = text:gsub("//", "
"):gsub("\
", "
")
			text = DarkRP.textWrap(text, "DarkRPHUD1", 440)
			draw.DrawText(text, "DarkRPHUD1", 30, 35, Color(255,255,255,255),0)
		end
	end
end

CreateConVar("DarkRP_LockDown", 0, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE})
local function LockDown()
	local chbxX, chboxY = chat.GetChatBoxPos()
	if util.tobool(GetConVarNumber("DarkRP_LockDown")) then
		local cin = (math.sin(CurTime()) + 1) / 2
		local chatBoxSize = math.floor(ScrH() / 4)
		draw.DrawText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle",ScrW()/2,ScrH()/2, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_CENTER)
	end
end

local function DrawPlayerInfo(ply)
	local pos = ply:EyePos()

	pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
	pos = pos:ToScreen()
	if not ply:getDarkRPVar("wanted") then
		-- Move the text up a few pixels to compensate for the height of the text
		pos.y = pos.y - 50
	end

	if GAMEMODE.Config.showname then
		local nick, plyTeam = ply:Nick(), ply:Team()
		draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
		draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
	end

	if GAMEMODE.Config.showhealth then
		local health = DarkRP.getPhrase("health", ply:Health())
		draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
		draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
	end

	if GAMEMODE.Config.showjob then
		local teamname = ply:getDarkRPVar("job") or team.GetName(ply:Team())
		draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
		draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
	end

	if ply:getDarkRPVar("HasGunlicense") then
		surface.SetMaterial(Page)
		surface.SetDrawColor(255,255,255,255)
		surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
	end
end

/*---------------------------------------------------------------------------
Drawing the HUD elements such as Health etc.
---------------------------------------------------------------------------*/

local function DrawHUD()
	localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer()
	if not IsValid(localplayer) then return end

	Scrw, Scrh = ScrW(), ScrH()

	MyHUD()
	
	//DrawInfo()	
	
	local shootPos = localplayer:GetShootPos()
	local aimVec = localplayer:GetAimVector()

	for k, ply in pairs(player.GetAll()) do
		if not ply:Alive() then continue end
		local hisPos = ply:GetShootPos()

		if GAMEMODE.Config.globalshow and ply ~= localplayer then
			DrawPlayerInfo(ply)
		elseif not GAMEMODE.Config.globalshow and hisPos:Distance(shootPos) < 400 then
			local pos = hisPos - shootPos
			local unitPos = pos:GetNormalized()
			if unitPos:Dot(aimVec) > 0.95 then
				local trace = util.QuickTrace(shootPos, pos, localplayer)
				if trace.Hit and trace.Entity ~= ply then return end
				DrawPlayerInfo(ply)
			end
		end
	end

	local tr = LocalPlayer():GetEyeTrace()

	if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 200 then
		tr.Entity:drawOwnableInfo()
	end
	
	Agenda()
	LockDown()
	
end

/*---------------------------------------------------------------------------
Drawing death notices
---------------------------------------------------------------------------*/

hook.Add("DrawDeathNotice", "Notify", function(x,y)
	if not GAMEMODE.Config.showdeaths then return end
	GAMEMODE:DrawDeathNotice( 0.8, 0.02 )
	
	return true
end)

/*---------------------------------------------------------------------------
Disable players' names popping up when looking at them
---------------------------------------------------------------------------*/
hook.Add("HUDDrawTargetID","TargetID", function()
	return false
end)

/*---------------------------------------------------------------------------
Actual HUDPaint hook
---------------------------------------------------------------------------*/
hook.Add("HUDPaint","PaintHUD", function()
	DrawHUD()
end)

/*---------------------------------------------------------------------------
Remove some elements from the HUD in favour of the DarkRP HUD
---------------------------------------------------------------------------*/

local HideElements = {
  ["DarkRP_HUD"] = false,
  ["DarkRP_EntityDisplay"] = true,
  ["DarkRP_ZombieInfo"] = false,
  ["DarkRP_Agenda"] = true,
  ["DarkRP_LocalPlayerHUD"] = true,
  ["DarkRP_Hungermod"] = true
}

hook.Add("HUDShouldDraw", "HideElements", function(name)
	if HideElements[name] or 
		name == "CHudHealth" or
		name == "CHudBattery" or
		name == "CHudAmmo" or 
		name ==	"CHudSecondaryAmmo" or
		name ==	"CHudDamageIndicator"
	then 
		return false 
	end
end)



All i want to do is get the Stamina, Fuel and Utime to display on the new hud like it did my old hud. And my friend who normally helps me is off doing a project.

I’ve tried converting it over but it never works. Thanks :slight_smile:

Something like this should work:




local plyHunger = LocalPlayer():getDarkRPVar( "Energy" )

draw.RoundedBox( 6, 20, 10, 200 * plyHunger / 100, 20, Color( 25, 255, 25, 245 ) )

and for the text

draw.DrawText( plyHunger, "DermaLarge", 50, 50, color_white )



Mess around with the code, and make it so that it suits you.

Untested but should work.

It does not trust me i have tried.

I highly doubt you did it correctly. Because the code I provided looks fine.

Well, last time i got the stamina working so i must have done something correctly. So be it lost that code.

That code Tupac provided is incorrect.

I don’t know about DarkRP or DarkRP variables, but the use of draw.RoundedBox is wrong


draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color )

A corner radius wasn’t provided.

Same for draw.DrawText


draw.DrawText( string text, string font, number x, number y, table color, number xAlign )

No font was provided.

My bad, was in a rush. Thanks, fixed.

You don’t need any of that garbage at the top, all of the [lua]local Color = Color
local CurTime = CurTime
local cvars = cvars
local DarkRP = DarkRP
local draw = draw
local GetConVar = GetConVar
local hook = hook
local IsValid = IsValid
local Lerp = Lerp
local localplayer
local math = math
local pairs = pairs
local ScrW, ScrH = ScrW, ScrH
local SortedPairs = SortedPairs
local string = string
local surface = surface
local table = table
local timer = timer
local tostring = tostring
local plyMeta = FindMetaTable(“Player”)
[/lua]

gotta make things quick!!111!!!11!