Issues with drawing text

include(“shared.lua”)

function ENT:Draw()

    local owner = self:Getowning_ent();
    owner = ( IsValid( owner ) and owner:Nick( ) ) or "Disconnected";
    local txt1 = "test"

    txt2 = "$" ..self:GetNWInt( "Amount" );
    surface.SetFont("HUDNumber5")
    local TextWidth = surface.GetTextSize(txt1)
    local TextWidth2 = surface.GetTextSize(txt2)
    local TextWidth3 = surface.GetTextSize(owner)

    local tr = LocalPlayer():GetEyeTrace()
    if IsValid( tr.Entity) and tr.Entity == self then
	draw.SimpleText( txt1, "HUDNumber5", ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
    end

end

The entity is invisible, I was wondering if anyone could help/tell me whats wrong with this. I am quite new to Lua so please dont judge^
I think It is in the “draw.SimpleText” But I am uncertain. Thank you!

You need to use DrawModel in the ent:Draw function, also please use “Code” tags.

Thanks man. The Entity is visible now but the “draw.SimpleText( txt1, “HUDNumber5”, ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )” Is not showing ingame, any idea why?

You want to draw text over the entity, right? I uh currently got no example, but there should be code lying around in the recent topics.

Well, I want it to only be visible when you aim at the entity.
A good example of this is the doors in DarkRP, when you are close enough and your crosshair is aiming at the door you will get the option to buy it.

HUD drawing needs to be done in the DrawHUD hook

Im not sure if I understand what you mean, this is not a hud. Well not for the player anyway it is for a money printer in DarkRP.

for drawing text on those you need to make checks, but the normal “kewl” printers use 3D2D text to print directly on them.

Yes it is, you’re (trying) drawing “test” on the HUD when you look at a printer

Try something like this



hook.Add("DrawHUD", "drawprinterhud", function()
    local tr = LocalPlayer():GetEyeTrace()
    if(IsValid(tr.Entity) and tr.Entity:GetClass()=="classofenthere") then
        draw.SimpleText("$"..string.Comma(tr.Entity:GetNWInt("Amount")), "HUDNumber5", ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
    end
end)


whitestar posts some real shit

Why

so

many

whitespaces?

._.

[editline]1st October 2015[/editline]

nvm its your pic >w< I ish stoopid