GetPlayerName: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Improved examples) |
||
(16 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This function returns a string containing the name of the specified player. | This function returns a string containing the name of the specified player. | ||
Line 6: | Line 7: | ||
string getPlayerName ( player thePlayer ) | string getPlayerName ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:getName|name|setPlayerName}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
* '''thePlayer:''' | * '''thePlayer:''' the [[player]] you want to get the name of | ||
===Returns=== | ===Returns=== | ||
Returns a string containing the requested player's name, or ''false'' if the player passed to the function is invalid. | Returns a string containing the requested player's name, or ''false'' if the player passed to the function is invalid. | ||
===Limits=== | |||
* Player name can consist of ASCII characters between 33 and 126 are allowed (basic latin): | |||
<nowiki>!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</nowiki> | |||
* Minimal player name length is 1 character. | |||
* Maximum player name length is 22 characters. | |||
* Player names are case-insensitive. It is not possible to have two clients with same name but different character case. | |||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
addCommandHandler("myname", function(ply) | |||
outputChatBox("Your name: "..getPlayerName(ply), ply) | |||
end) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
This example outputs the local player name to the chatbox. | This example outputs the local player name to the chatbox. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addCommandHandler("myname", function() | |||
-- output local player's name to the chatbox | |||
outputChatBox(getPlayerName(localPlayer)) | |||
end) | |||
-- | |||
outputChatBox( | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Client player functions}} | {{Client player functions}} | ||
[[es:getPlayerName]] | |||
[[pt-br:getPlayerName]] |
Latest revision as of 22:01, 15 January 2024
This function returns a string containing the name of the specified player.
Syntax
string getPlayerName ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:getName(...)
- Variable: .name
- Counterpart: setPlayerName
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.
Limits
- Player name can consist of ASCII characters between 33 and 126 are allowed (basic latin):
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
- Minimal player name length is 1 character.
- Maximum player name length is 22 characters.
- Player names are case-insensitive. It is not possible to have two clients with same name but different character case.
Example
Click to collapse [-]
ServeraddCommandHandler("myname", function(ply) outputChatBox("Your name: "..getPlayerName(ply), ply) end)
Click to collapse [-]
ClientThis 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
- getLocalPlayer
- getPlayerMapBoundingBox
- getPlayerMapOpacity
- isPlayerMapVisible
- resetBlurLevel
- isPlayerHudComponentVisible
- Shared
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState