So when using this HUD(Kinda edited together two HUDs I found and changed them up a bit)
[CODE]
good_hud = { };
local function clr( color ) return color.r, color.g, color.b, color.a; end
function good_hud:PaintBar( x, y, w, h, colors, value )
self:PaintPanel( x, y, w, h, colors );
x = x + 1; y = y + 1;
w = w - 2; h = h - 2;
local width = w * math.Clamp( value, 0, 1 );
local shade = 4;
surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );
surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect( x, y + shade, width, h - shade );
end
function good_hud:PaintPanel( x, y, w, h, colors )
surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );
x = x + 1; y = y + 1;
w = w - 2; h = h - 2;
surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );
end
function good_hud:TextSize( text, font )
surface.SetFont( font );
return surface.GetTextSize( text );
end
function good_hud:PaintText( x, y, text, font, colors )
surface.SetFont( font );
surface.SetTextPos( x + 1, y + 1 );
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );
surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );
end
local vars =
{
font = "TargetID",
padding = 10,
margin = 2,
text_spacing = 2,
bar_spacing = 2,
bar_height = 21,
width = 0.17
};
local colors =
{
background =
{
border = Color( 0, 0, 0, 255 ),
background = Color( 200, 27, 27, 75 )
},
text =
{
shadow = Color( 0, 0, 0, 200 ),
text = Color( 255, 255, 255, 255 )
},
health_bar =
{
border = Color( 0, 255, 0, 255 ),
background = Color( 255, 255, 255, 25 ),
shade = Color( 136, 136, 255, 255 ),
fill = Color( 27, 27, 176, 255 )
},
suit_bar =
{
border = Color( 0, 255, 0, 255 ),
background = Color( 255, 255, 255, 25 ),
shade = Color( 255, 136, 136, 255 ),
fill = Color( 255, 0, 0, 255 )
}
};
local function HUDPaint( )
client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end
local _, th = good_hud:TextSize( "TEXT", vars.font );
local i = 2;
local width = vars.width * ScrW( );
local bar_width = width - ( vars.padding * i );
local height = ( vars.padding * i ) + ( th * i ) + ( vars.text_spacing * i ) + ( vars.bar_height * i ) + vars.bar_spacing;
local x = 740;
local y = ScrH( ) - vars.margin - height;
local cy = y + vars.padding;
local cx = 750;
good_hud:PaintPanel( x, y, width, height, colors.background );
local by = th + vars.text_spacing;
local text = string.format( "Health: %i", client:Health( ) );
good_hud:PaintText( cx, cy, text, vars.font, colors.text );
good_hud:PaintBar( cx, cy + by, bar_width, vars.bar_height, colors.health_bar, client:Health( ) / 100 );
by = by + vars.bar_height + vars.bar_spacing;
local text = string.format( "Armor: %i", client:Armor( ) );
good_hud:PaintText( cx, cy + by, text, vars.font, colors.text );
good_hud:PaintBar( cx, cy + by + th + vars.text_spacing, bar_width, vars.bar_height, colors.suit_bar, client:Armor( ) / 100 );
LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
local v1 = LocalPlayer().DarkRPVars.money
if not v1 then v1 = "" end
local v2 = LocalPlayer().DarkRPVars.salary
if not v2 then v2 = "" end
surface.SetDrawColor(255,255,255)
surface.SetTexture(surface.GetTextureID("gui/silkicons/user"))
surface.DrawTexturedRect(25 + 1050,ScrH() - 115,16,16)
surface.SetTexture(surface.GetTextureID("gui/silkicons/money"))
surface.DrawTexturedRect(25 + 1050,ScrH() - 85,16,16)
surface.SetTexture(surface.GetTextureID("gui/silkicons/money_add"))
surface.DrawTexturedRect(25 + 1050,ScrH() - 55,16,16)
surface.SetTexture(surface.GetTextureID("gui/silkicons/group"))
surface.DrawTexturedRect(25 + 1050,ScrH() - 25,16,16)
if LocalPlayer():IsAdmin() then
surface.SetTexture(surface.GetTextureID("gui/silkicons/shield"))
surface.DrawTexturedRect(25 + 1050,ScrH() - 145,16,16)
end
draw.SimpleText(LocalPlayer():Nick(),"TargetID", 25 + 1075,ScrH() - 117, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
draw.SimpleText("$" .. v1,"TargetID", 25 + 1075,ScrH() - 87, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
draw.SimpleText("$" .. v2,"TargetID", 25 + 1075,ScrH() - 57, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
draw.SimpleText(LocalPlayer().DarkRPVars.job,"TargetID", 25 + 1075,ScrH() - 27, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
end
hook.Add( "HUDPaint", "PaintOurHud", HUDPaint );
[/CODE]
I tried to add it to darkrp by replacing the client/hud.lua, and it works on singleplayer with DarkRP, but not on multiplayer. I get the error:
ags' changed to Evolve,SCars 2.0,garrysmod139,gm:DarkRP
Hook 'PaintOurHud' Failed: [@lua\includes\modules\draw.lua:103] bad argument #1 to 'DrawText' (string expected, got nil)
I have no idea how to fix this. Any help would be appreciated
Sorry, you need to Log In to post a reply to this thread.