• Players Name On An Entity?
    5 replies, posted
I am getting really far with my entities, they are nearly done actually. I have it so when the crosshair contacts the entity, it displays a text bubble next to a random number. In game it would be like [i]Number 36[/i] My Code VVVVV [lua]AddWorldTip( self.Entity:EntIndex(), ( "Number" .. number .. "" ), 5, self.Entity:GetPos(), self.Entity )[/lua] But what would I do if I wanted it to show the player who created the entity's name? So it would appear like [i]Number 36 By ErrolLiamP[/i] ^^^^^^^^^^^^^^^^ If I created the Entity, and my friend created another of the same Entity, I am hoping that the names displayed on the little text bubbles wouldn't interfear with eachother.:pwn: I have been looking at this [url]http://wiki.garrysmod.com/page/Player/GetName[/url] Any help is appreciated.
[CODE]AddWorldTip( self.Entity:EntIndex(), ( "Number" .. number .. " by ".. ownerentity:Nick() ), 5, self.Entity:GetPos(), self.Entity )[/CODE]
[QUOTE=Sm63;46444554][CODE]AddWorldTip( self.Entity:EntIndex(), ( "Number" .. number .. " by ".. ownerentity:Nick() ), 5, self.Entity:GetPos(), self.Entity )[/CODE][/QUOTE] Thanks for that fast reply, but I'm getting this lua error. attempt to call method 'Nick' (a nil value) I have had problems spawning things through the console before, think thats the reason?
the ownerentity variable must be replaced with a function/variable that returns the owner, like self.Owner, or self:GetOwner().
[QUOTE=Sm63;46444635]the ownerentity variable must be replaced with a function/variable that returns the owner, like self.Owner, or self:GetOwner().[/QUOTE] I know, I had it set to self.Entity, then tried self.Owner, still the same problem. I am spawning these through the console though, I don't think that should change anything, but I could be wrong. Anyway, it still spams that error. Other ideas? :dance:
hook PlayerSpawnedEntity or whatever it is and if the entity has the classname of the custom ent, save the players entity somewhere and you figure out the rest
Sorry, you need to Log In to post a reply to this thread.