Head HUD NPC

Hi, My code works half the time I do not understand , I have to reload the file every time. Otherwise it does not appear.

My code :


if CLIENT then
surface.CreateFont( "NPC1", {
font = "Arial",
size = 50,
weight = 2000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false
} )

surface.CreateFont( "NPC2", {
font = "Arial",
size = 50,
weight = 2000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false
} )

surface.CreateFont( "coolfont", {
 font = "Bebas Neue",
 size = 40,
 weight = 300,
 blursize = 0,
 scanlines = 0,
 antialias = true
} )



hook.Add( "HUDPaint", "DrawNPCName", function()

	for i, v in pairs( ents.FindByClass( "banknpc" ) ) do
		if( v:GetPos():Distance( LocalPlayer():GetPos() ) < 200 ) then
			local _pos = v:GetPos() + Vector( 0, 0, 80 );
			_pos = _pos:ToScreen();
			if( LocalPlayer():IsLineOfSightClear( v:GetPos() + Vector( 0, 0, 80 ) ) ) then
				local _name = v:GetNWString( "name", "Banquier" );
				
				surface.SetFont( "NPC1" );
				local _w, _h = surface.GetTextSize( _name );
				draw.DrawText( _name, "NPC1", _pos.x - ( _w / 2 ) - 3, _pos.y, Color( 0, 0, 0, 255 ), ALIGN_CENTER );
				draw.DrawText( _name, "NPC2", _pos.x - ( _w / 2 ), _pos.y, Color( 255, 255, 255, 255 ), ALIGN_CENTER );
			end
		end
	end
  end)
end

Thank’s you for helping.

Use PostDrawTranslucentRenderables not HUDPaint as you want to draw in the world using cam.Start3D2D and not on the HUD.