How to make text appear when you hold your mouse over the SENT?

How to make text appear when you hold your mouse over the SENT?
If you don´t know what I am meaning, look at the picture to the right.

I dosen’t test it, but something like this should work:
[lua]function ENT:Draw()
self.Entity:DrawModel()
local trace = LocalPlayer():GetEyeTrace()
if trace.Entity:GetClass() == “yourentity” then
draw.DrawText(“Yourtext”, “ScoreboardText”, ScrW() / 2 - 70, ScrH() - 63, Color(255,255,255,255),1)
end
end[/lua]

Yeh you should add the get class in a lua file instead
[lua]
local trace = LocalPlayer():GetEyeTrace()
if trace.Entity:GetClass() == “yourentity” then
draw.DrawText(“Yourtext”, “ScoreboardText”, ScrW() / 2 - 70, ScrH() - 63, Color(255,255,255,255),1)
end
[/lua]
this in a different file gamemodes cl_init not in a sent.

[lua]if ( LocalPlayer():GetEyeTrace().Entity == self.Entity && EyePos():Distance( self.Entity:GetPos() ) < 512 ) then
AddWorldTip( self.Entity:EntIndex(), self.GetTitle(), 0.5, self.Entity:GetPos(), self.Entity )
end[/lua]
That’s how the addon in the picture did it.
Just make it so if you’re looking at it, then call **[G.AddWorldTip

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.AddWorldTip)**

That way it’ll draw the text multiple times if there’s more than one of the entity, 20 of the same entity will make it draw the text 20 times over.

Better ways to do it:

[lua]
hook.Add( “HUDPaint”, “DrawEntText”, function()
local ent = LocalPlayer():GetEyeTrace().Entity
if (ent:GetClass() == “ent_class”) then
draw.SimpleText( “Entity Text”, “ScoreboardText”, ScrW()*0.5, ScrH()*0.5, Color( 255, 255, 255, 255 ), 1)
end
end )
[/lua]

Or maybe even

[lua]
function ENT:Draw()
self.Entity:DrawModel()
local ent = LocalPlayer():GetEyeTrace().Entity
if (ent == self) then
draw.DrawText( “Entity Text”, “ScoreboardText”, ScrW()*0.5, ScrH()*0.5, Color( 255, 255, 255, 255 ), 1)
end
end
[/lua]

I don’t know which is better.

I`ll test yours Mighty(something) and yours, Jo The blah.

[editline]08:19AM[/editline]

Shall I put the ent:Draw code in shared.lua init.lua or cl_init.lua?

its clientside, so in cl_init.lua.