3D2D Text Help

Hello! I need some help with displaying a title above a NPCs head and if you move it moves.

Like this https://youtu.be/n1zBnkarJEo


hook.Add("HUDPaint","text",function()
---Find all nearby entities
local es = ents.FindInSphere(LocalPlayer():GetPos()

for i = 1,table.Count(es) do
             --find npcs inside es
             if es*:IsNPC() then

                     --get position and convert it to 2d
                     local pos2 = es*:GetPos():ToScreen()

                      ---draw our text
                     draw.SimpleText("text above npcs","Derma_Large",pos2.x,pos2.y,Color(0,100,200))

             end
end



end)

Thats not really what i want to do. I just want to define it in the NPCs client side file.

Anyone else ?

thats literally what you have to do…use ent:draw, and built it with the code given.

I only want to label single NPCs, wouldn’t 3D2D cam work better ?

I can’t seem to get the code to work :confused:

http://pastebin.com/piF4QJU6

Placed it the NPCs client file.

Err it doesn’t work this way.
Basically what you are doing is creating every Frame a new hook which searches for NPCs, and tries to draw. You need to put the hook anywhere where it will be initialized one time, but not not in a function which is called every frame.

But better: Instead just put into ENT:Draw()



self.Entity:DrawModel( )
local pos2 = self:GetPos():ToScreen() -- Maybe self:Entity:GetPos():ToScreen()
 ---draw our text
draw.SimpleText("text above npcs","Derma_Large",pos2.x,pos2.y,Color(0,100,200))


However, I didn’t test it.

Read closely of what I said:
“thats literally what you have to do…use ent:draw, and built it with the code given.”
Spoonfeeding is bad, you have to learn Lua too.