<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=SetPlayerName</id>
	<title>SetPlayerName - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=SetPlayerName"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=SetPlayerName&amp;action=history"/>
	<updated>2026-08-05T04:55:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=SetPlayerName&amp;diff=119&amp;oldid=prev</id>
		<title>QCherry: Document authoritative player name functions</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=SetPlayerName&amp;diff=119&amp;oldid=prev"/>
		<updated>2026-08-04T16:29:59Z</updated>

		<summary type="html">&lt;p&gt;Document authoritative player name functions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;!-- This page is generated automatically from the function definition: setPlayerName. --&amp;gt;&lt;br /&gt;
= setPlayerName =&lt;br /&gt;
Changes a connected player&amp;#039;s authoritative multiplayer name.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPlayerName(int playerId, string playerName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Required !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;playerId&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; || yes || The connected player whose name will be changed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;playerName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || yes || A unique name containing 3-16 ASCII letters, digits, spaces, underscores or hyphens.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; when the server accepts the new name; otherwise returns &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Create a private /name command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;name&amp;quot;, function(playerId, commandName, ...)&lt;br /&gt;
    local requestedName = table.concat({...}, &amp;quot; &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if setPlayerName(playerId, requestedName) then&lt;br /&gt;
        outputChatBox(&amp;quot;Your name is now &amp;quot; .. getPlayerName(playerId) .. &amp;quot;.&amp;quot;, playerId)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;That player name is invalid or already in use.&amp;quot;, playerId)&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Available only in server-side resource scripts.&lt;br /&gt;
* Names are trimmed and must be 3-16 characters long.&lt;br /&gt;
* Allowed characters are A-Z, a-z, 0-9, spaces, underscores and hyphens. Consecutive spaces are rejected.&lt;br /&gt;
* Names must be unique among connected players; uniqueness is checked case-insensitively.&lt;br /&gt;
* Successful changes are replicated to clients and raise &amp;lt;code&amp;gt;onPlayerNameChange&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server Functions]]&lt;br /&gt;
[[Category:Player Functions]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>