LUA: HUDPaint / Loading Error


	surface.SetFont( "HudCash" )
	surface.SetTextColor( 255, 255, 255, 255 )
	surface.SetTextPos( 150, ScrH() - 86 )
	surface.DrawText( client:GetNWInt( "coins" ) )

As you see aboth, it is displaying how much money the player has using GetNWInt, if I save my lua it reloads ingame and you can see it… BUT if you just join, the HUD displays a 0, untill you reload. Is there a way of reloading ALL lua on player to get the best performance? Aswell, my Scoreboard has to loadup when the player first joins and presses TAB does the HUDPaint do the same?

That’s odd… since a HUDPaint hook runs every frame it should be resetting every single time the hook is called… could you post the code around the DrawText bit? Maybe you’re using a different hook or a strange method to draw it


draw.SimpleText(client:GetNWString( "gmt_coins" ), "HudText", 150, ScrH() - 86, Color(255, 255, 255, 255), 0, 0)

This is what I first tried, and it loads after EVERY reload? Maybe when player joins I can Initialize every lua script?

Please help!

[editline]11th August 2016[/editline]

Oh and:


function GM:HUDPaint()
   draw.RoundedBox(0, 30, ScrH() - 95, 340, 80, Color(0, 128, 255, 230))
   draw.RoundedBox(0, 110, ScrH() - 90, 255, 45, Color(0, 76, 153, 230))
   draw.RoundedBox(0, 110, ScrH() - 45, 255, 25, Color(0, 30, 30, 230))
   
    draw.SimpleText(client:GetNWString( "location" ), "HudText", 120, ScrH() - 40, Color(255, 255, 255, 255), 0, 0)
    draw.SimpleText(client:GetNWInt( "coins" ), "HudCash", 150, ScrH() - 86, Color(255, 255, 255, 255), 0, 0)
	
    surface.SetDrawColor( 255, 255, 255 )
    surface.SetMaterial( coinimage )
    surface.DrawTexturedRect( 123, ScrH() - 78, 20, 20 )
	
	surface.SetDrawColor( 255, 255, 255 )
    surface.SetMaterial( logoimage )
    surface.DrawTexturedRect( -12, ScrH() - 125, 125, 125 )
end