This is the code for the KunFuel that I believe contains the HUD.
[CODE]function Kun_Gasmeter()
local ply = LocalPlayer()
local car = ply:GetVehicle()
if(car != nil and car:IsValid() and car.KunFuel != nil) then
draw.RoundedBox( 4, ScrW() - 125, ScrH() - 20, 140, 30, Color( 155, 155, 155, 150 ) )
draw.SimpleText("F", "TargetID", ScrW() - 120, ScrH() -20, Color(255,255,255,255))
draw.SimpleText("E", "TargetID", ScrW() - 10, ScrH() - 20, Color(255,255,255,255))
draw.SimpleText(car.KunFuel.."%", "TargetID", ScrW() - 80, ScrH() - 40, Color(255,255,255,255))
surface.SetDrawColor( 255, 0, 0, 255)
surface.DrawRect((ScrW() - 10) - car.KunFuel, ScrH()-20, 5, 20 )
end
end
hook.Add("HUDPaint", "Kun_Gasmeter", Kun_Gasmeter)
function Kun_CS_Gas()
local ply = LocalPlayer()
local frame = vgui.Create("DFrame")
frame:SetSize( 200, 180)
frame:Center()
frame:SetDraggable( false )
frame:SetVisible( true )
frame:ShowCloseButton( true )
frame:MakePopup()
frame:SetTitle("")
frame.Paint = function(frame)
draw.RoundedBox( 6, 0, 0, frame:GetWide(), frame:GetTall(), Color( 250, 250, 250, 255 ) )
draw.RoundedBox( 6, 2, 2, frame:GetWide() - 4, frame:GetTall() - 4, Color( 50, 50, 50, 255 ) )
surface.SetDrawColor( 255, 255, 255, 255)
surface.DrawOutlinedRect(frame:GetWide() / 2 - 40, 35, 80, 80)
end
local icon = vgui.Create( "DModelPanel", frame )
icon:SetModel( "models/props_junk/gascan001a.mdl" )
icon:SetPos(frame:GetWide() / 2 - 40, 40)
icon:SetSize( 80, 80 )
icon:SetCamPos( Vector( 20, 20, 30 ) )
icon:SetLookAt( Vector( 0, 0, 0 ) )
icon:SetFOV(50)
local buygas = vgui.Create("DButton",frame)
buygas:SetSize(frame:GetWide() - 20,30)
buygas:SetPos(10,frame:GetTall() - 40)
buygas:SetText("")
buygas.DoClick = function()
net.Start("Kun_BuyGas")
net.SendToServer()
end
buygas.Paint = function()
surface.SetDrawColor( 250, 250, 250, 255)
surface.DrawRect(0 , 0, buygas:GetWide(), buygas:GetTall() )
surface.SetDrawColor( 50, 50, 50, 255)
surface.DrawRect(2 , 2, buygas:GetWide()-4, buygas:GetTall()-4 )
draw.SimpleText( "Buy Gas: $"..Kun_GasPrice, "TargetID", buygas:GetWide() / 2, buygas:GetTall() / 2, Color(250,250,250,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
end
net.Receive( "Kun_CS_Gas", Kun_CS_Gas)
function Kun_CS_Repair()
local ply = LocalPlayer()
local frame = vgui.Create("DFrame")
frame:SetSize( 200, 180)
frame:Center()
frame:SetDraggable( false )
frame:SetVisible( true )
frame:ShowCloseButton( true )
frame:MakePopup()
frame:SetTitle("")
frame.Paint = function(frame)
draw.RoundedBox( 6, 0, 0, frame:GetWide(), frame:GetTall(), Color( 250, 250, 250, 255 ) )
draw.RoundedBox( 6, 2, 2, frame:GetWide() - 4, frame:GetTall() - 4, Color( 50, 50, 50, 255 ) )
surface.SetDrawColor( 255, 255, 255, 255)
surface.DrawOutlinedRect(frame:GetWide() / 2 - 40, 35, 80, 80)
end
local icon = vgui.Create( "DModelPanel", frame )
icon:SetModel( "models/props_c17/tools_wrench01a.mdl" )
icon:SetPos(frame:GetWide() / 2 - 40, 40)
icon:SetSize( 80, 80 )
icon:SetCamPos( Vector( 20, 20, 30 ) )
icon:SetLookAt( Vector( 0, 0, 0 ) )
icon:SetFOV(50)
local buyrepair = vgui.Create("DButton",frame)
buyrepair:SetSize(frame:GetWide() - 20,30)
buyrepair:SetPos(10,frame:GetTall() - 40)
buyrepair:SetText("")
buyrepair.DoClick = function()
net.Start("Kun_BuyRepair")
net.SendToServer()
end
buyrepair.Paint = function()
surface.SetDrawColor( 250, 250, 250, 255)
surface.DrawRect(0 , 0, buyrepair:GetWide(), buyrepair:GetTall() )
surface.SetDrawColor( 50, 50, 50, 255)
surface.DrawRect(2 , 2, buyrepair:GetWide()-4, buyrepair:GetTall()-4 )
draw.SimpleText( "Buy Repair: $"..Kun_RepairCost, "TargetID", buyrepair:GetWide() / 2, buyrepair:GetTall() / 2, Color(250,250,250,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
end
net.Receive( "Kun_CS_Repair", Kun_CS_Repair)
function Kun_CS_SetGas()
local ply = LocalPlayer()
local ent = net.ReadEntity()
local gas = net.ReadInt(32)
if(ent != nil and ent:IsValid()) then
print("Set car health")
ent.KunFuel = gas
end
end
net.Receive( "Kun_CS_SetGas", Kun_CS_SetGas)
[/CODE]
I just want to position it to the top right corner of the screen because it overlays with RocketMania's blue line HUD.
Modify the draw.* and surface.* functions in the HudPaint function, as to position it accordingly. Right now its setup to be in the bottom right it looks like. You will mostly want to look at the ScrH() part.
I know nothing about HUD so none of this makes sense to me. ;~:
Well we aren't going to do it for you. [URL="http://wiki.garrysmod.com/page/draw/RoundedBox"]Here's the box function[/URL] and [URL="http://wiki.garrysmod.com/page/Global/ScrH"]here's what ScrH() is[/URL]. You're going to want to remove the ScrH() variable, and re-align everything else.
Sorry, you need to Log In to post a reply to this thread.