GetPlayerName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 36: Line 36:
)
)
</syntaxhighlight>
</syntaxhighlight>
<section>
</section>


==See Also==
==See Also==
{{Client player functions}}
{{Client player functions}}

Revision as of 07:33, 19 June 2009

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

Syntax

string getPlayerName ( player thePlayer )

Required Arguments

  • thePlayer: The player you want to get the name of.

Returns

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

Example

Click to collapse [-]
Server
addCommandHandler("myname",
  function(playerSource)
    outputChatBox("Your name: "..getPlayerName(playerSource), playerSource)
  end
)
Click to collapse [-]
Client

This example outputs the local player name to the chatbox.

addCommandHandler("myname",
  function()
   local localPlayerName = getPlayerName(getLocalPlayer())
   --and we output it to the chatbox
   outputChatBox(localPlayerName)
  end
)

See Also