General > Developers Corner
How to change playernames
Neku:
Where would that function be located though?
MrPresident:
Inside of the Player MetaTable. :P
Now we're getting into more advanced GLua stuff.
MrPresident:
you can override it, but there is no way to just see what it is already in lua. It's built into the game at the engine level.
to override it is just something like this:
in this example you could change a players name by setting the 'customname' object on their player entity to whatever string you want. If they don't have one it'll return their default steam name.
--- Code: ---meta = FindMetaTable( "Player" )
function meta:Nick()
if self.customname then return self.customname end
return self:GetName()
end
--- End code ---
Neku:
OP, can you paste DarkRP's set rpname function here?
The command works and all, but the scoreboard and chat still displays the original name.
Th3_§mp3r0r:
--- Code: ---meta = FindMetaTable( "Player" )
function meta:Nick()
if self.customname then return self.customname end
return self:GetName()
end
--- End code ---
OMG I found a similar code in DarkRP days ago, but I interpreted it wrong. I thought it creates his own table as a database to store variables, not that this is the actual game table.
Thank you! Now I have a point where I can begin to write a code.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version