SetPlayerName
From SA-MP Wiki
(Difference between revisions)
Revision as of 00:48, 22 October 2012 1337pr0 (Talk | contribs) (Fixed some grammar to improve readability) ← Previous diff |
Revision as of 04:16, 5 February 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
{{Scripting}} | {{Scripting}} | ||
- | {{Title}} | ||
{{Description|Sets the name of a player.}} | {{Description|Sets the name of a player.}} | ||
Line 39: | Line 38: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
- | + | [[fr:SetPlayerName]] | |
[[ru:SetPlayerName]] | [[ru:SetPlayerName]] |
Revision as of 04:16, 5 February 2014
Description:
Sets the name of a player.
(playerid, name[])
playerid | The ID of the player to set the name of |
name[] | The name to set |
Return Values:
1 if the name was changed, 0 if the player is already using that name or -1 when the name cannot be changed (it's in use, too long or has invalid characters)
// Command simply sets the player's name to to "Superman" if possible, with no error checking or messages. if(strcmp(cmdtext, "/superman", true) == 0) { SetPlayerName(playerid, "Superman"); return 1; } // Command sets the players name to "Superman" if possible, informs the player of // any errors using a "switch" statement. if(strcmp(cmdtext, "/superman", true) == 0) { switch(SetPlayerName(playerid, "Superman")) { case -1: SendClientMessage(playerid, 0xFF0000FF, "Unable to change your name, someone else is known as 'Superman' already."); case 0: SendClientMessage(playerid, 0xFF0000FF, "You are already known as 'Superman'"); case 1: SendClientMessage(playerid, 0x00FF00FF, "You are now known as 'Superman'"); } return 1; }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- GetPlayerName: Get a player's name.