getPlayerName | Multi Theft Auto: Wiki Skip to content

getPlayerName

Client-side
Server-side
Shared

Pair: setPlayerName

This function returns a string containing the name of the specified player.

OOP Syntax Help! I don't understand this!

  • Method: player:getName(...)
  • Variable: .name

Syntax

string|false getPlayerName ( player thePlayer )
Required Arguments
  • thePlayer: The player you want to get the name of.

Returns

  • string|false: name

Returns a string containing the requested player's name, or false if the player passed to the function is invalid.

Code Examples

client

This example outputs the local player name to the chatbox.

addCommandHandler("myname", function()
-- output local player's name to the chatbox
outputChatBox(getPlayerName(localPlayer))
end)

See Also