GetPlayerName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 74472 by KoADEV (talk))
Tag: Undo
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{BR/Função compartilhada}}
{{Server client function}}
Essa função retorna uma string contendo o nome do player especificado.
This function returns a string containing the name of the specified player.


==Sintaxe==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getPlayerName ( player thePlayer )
string getPlayerName ( player thePlayer )
</syntaxhighlight>
</syntaxhighlight>
{{PT-BR/POO||[[player]]:getName|name|setPlayerName}}
{{OOP||[[player]]:getName|name|setPlayerName}}
===Argumentos necessários===
===Required Arguments===
* '''thePlayer:''' O [[player]] que você deseja obter o nome.
* '''thePlayer:''' the [[player]] you want to get the name of


===Retorna===
===Returns===
Retorna uma string contendo o nome do player solicitado, ou ''false'' se o player é inválido.
Returns a string containing the requested player's name, or ''false'' if the player passed to the function is invalid.


===Limites===
===Limits===
* O nome do jogador pode consistir em caracteres ASCII entre 33 e 126 são permitidos (latim básico):   
* Player name can consist of ASCII characters between 33 and 126 are allowed (basic latin):   
     <nowiki>!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</nowiki>
     <nowiki>!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</nowiki>
* O comprimento mínimo do nome do jogador é de 1 caractere.  
* Minimal player name length is 1 character.  
* O comprimento máximo do nome do jogador é de 22 caracteres.  
* Maximum player name length is 22 characters.
* O nome dos jogadores não diferenciam letras maiúsculas e minúsculas. Não é possível dois clientes terem nomes iguais, mesmo com letras maiúsculas e minúsculas diferentes.
* Player names are case-insensitive. It is not possible to have two clients with same name but different character case.


==Exemplo==
==Example==
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("meunome",
addCommandHandler("myname",
   function(playerSource)
   function(playerSource)
     outputChatBox("Seu nome: "..getPlayerName(playerSource), playerSource)
     outputChatBox("Your name: "..getPlayerName(playerSource), playerSource)
   end
   end
)
)
Line 33: Line 33:


<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
Esse exemplo envia o nome do jogador ao bate-papo.
This example outputs the local player name to the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("meunome",
addCommandHandler("myname",
   function()
   function()
   local localPlayerName = getPlayerName(getLocalPlayer())
   local localPlayerName = getPlayerName(getLocalPlayer())
   --e nós enviamos ao bate-papo
   --and we output it to the chatbox
   outputChatBox(localPlayerName)
   outputChatBox(localPlayerName)
   end
   end
Line 45: Line 45:
</section>
</section>


==Veja também==
==See Also==
{{Client player functions}}
{{Client player functions}}
[[es:getPlayerName]]
[[es:getPlayerName]]
[[pt-br:getPlayerName]]
[[pt-br:getPlayerName]]

Revision as of 14:42, 20 April 2022

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 [-]
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