• Getting the printname for hl2 entities
    2 replies, posted
currently i have a healthbar that gets the class of an entity OR the printname (if its available) is there a way i can get a "nice" version of the name without resorting to making a table of all the hl2 npcs? currently i have this [lua] local name = {["npc_zombie"] = "Zombie", ["npc_fastzombie"] = "Fast Zombie", ["npc_poisonzombie"] = "Poison Zombie", ["npc_headcrab_black"] = "Poison Headcrab" } local nicename = name[trace.Entity:GetClass()] if trace.Entity:GetTable().PrintName == nil then trace.Entity:GetTable().PrintName = nicename or "Unknown" end draw.SimpleText(trace.Entity:GetTable().PrintName , "Trebuchet18", x+100, y + 20, Color(255,255,255,255),1,1) [/lua] It has got to be possible unless there is already a table somewhere with this in it (somehow the q menu gets the entities name even though it is not in the entity table)
#npc_zombie or language.GetPhrase("npc_zombie")
thanks! :) [editline]17th October 2015[/editline] [lua] if trace.Entity:GetTable().PrintName == nil then trace.Entity:GetTable().PrintName = language.GetPhrase(trace.Entity:GetClass()) end [/lua] [editline]17th October 2015[/editline] [lua] local name = trace.Entity:GetTable().PrintName or language.GetPhrase(trace.Entity:GetClass()) draw.SimpleText(name , "Trebuchet18", x+100, y + 20, Color(255,255,255,255),1,1) [/lua] probably more efficient lol
Sorry, you need to Log In to post a reply to this thread.