• 3D2D Text Help
    7 replies, posted
Hello! I need some help with displaying a title above a NPCs head and if you move it moves. Like this [url]https://youtu.be/n1zBnkarJEo[/url]
[CODE]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[i]:IsNPC() then --get position and convert it to 2d local pos2 = es[i]:GetPos():ToScreen() ---draw our text draw.SimpleText("text above npcs","Derma_Large",pos2.x,pos2.y,Color(0,100,200)) end end end)[/CODE]
Thats not really what i want to do. I just want to define it in the NPCs client side file. Anyone else ?
[QUOTE=Cheese_3;48705122]Thats not really what i want to do. I just want to define it in the NPCs client side file. Anyone else ?[/QUOTE] 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 :/ [url]http://pastebin.com/piF4QJU6[/url] Placed it the NPCs client file. [url]http://i.imgur.com/j3Rpmp2.jpg[/url]
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() [CODE] 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)) [/CODE] However, I didn't test it.
[QUOTE=Cheese_3;48710212]I can't seem to get the code to work :/ [url]http://pastebin.com/piF4QJU6[/url] Placed it the NPCs client file. [url]http://i.imgur.com/j3Rpmp2.jpg[/url][/QUOTE] Read closely of what I said: "thats literally what you have to do..use ent:draw, and [B]built it[/B] with the code given." Spoonfeeding is bad, you have to learn Lua too.
Sorry, you need to Log In to post a reply to this thread.