SetClientName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Visual improvement)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
{{Server function}}
{{Deprecated|setPlayerName}}
__NOTOC__


__NOTOC__
This function changes the specified [[client]]'s name.
This fake function is for use with blah & blah and does blahblahblabhalbhl


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Insert syntax here             
bool setClientName ( client theClient, string newName )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theClient:''' the [[client]] that will have its name set.
 
*'''newName:''' the new name to set for the client.
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if the client's name was changed succesfully, ''false'' if invalid arguments are specified.


==Example==  
==Example==
This example does...
<section name="Server" class="server" show="true">
This example adds a tag before a player's nickname via a /changetag command
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
 
blabhalbalhb --abababa
--Define the function for this command (/changetag, as defined below)
--This line does this...
--Source = the player that triggered this command
mooo
--Command = The command passed into the function (changetag)
--thePlayer = The player argument that you wish to add a tag too
--tag = The tag to add to the players nickname
function tagPlayer( source, command, thePlayer, tag )
--Attempt to grab the elemennt id for the player from the parsed name.
local sPlayerElement = getPlayerFromNick(thePlayer)
--Check to see if the player were changing the tag for exists.
if (sPlayerElement) then
--make sure that the element type of thePlayer is acctually pointing to a player element
if getElementType( sPlayerElement ) == "player" then
--we store the player's current name,
local oldName = getClientName( sPlayerElement )
--append the tag passed to this function before it
local taggedName = tag .. oldName
--then set it as his new name
setClientName( sPlayerElement, taggedName )
--Tell the player who triggerd the command that the tag has been applied
outputChatBox ( "Player " .. thePlayer .. "'s tag changed to " .. taggedName, source )
end
else
--Tell the player who triggerd the command that the player could not be found
outputChatBox ( "Unable to change player tag: Player " .. thePlayer .. " not found", source )
end
end
--Add a command handler for either the console or / chat commands
--Example: /changetag <playername> <tag>
addCommandHandler ( "changetag", tagPlayer )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Client_functions}}

Latest revision as of 12:31, 26 June 2014

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setPlayerName instead.


This function changes the specified client's name.

Syntax

bool setClientName ( client theClient, string newName )

Required Arguments

  • theClient: the client that will have its name set.
  • newName: the new name to set for the client.

Returns

Returns true if the client's name was changed succesfully, false if invalid arguments are specified.

Example

Click to collapse [-]
Server

This example adds a tag before a player's nickname via a /changetag command


--Define the function for this command (/changetag, as defined below)
--Source = the player that triggered this command
--Command = The command passed into the function (changetag)
--thePlayer = The player argument that you wish to add a tag too
--tag = The tag to add to the players nickname
function tagPlayer( source, command, thePlayer, tag )
	--Attempt to grab the elemennt id for the player from the parsed name.
	local sPlayerElement = getPlayerFromNick(thePlayer)
	--Check to see if the player were changing the tag for exists.
	if (sPlayerElement) then
		--make sure that the element type of thePlayer is acctually pointing to a player element
		if getElementType( sPlayerElement ) == "player" then
			--we store the player's current name,
			local oldName = getClientName( sPlayerElement )
			--append the tag passed to this function before it
			local taggedName = tag .. oldName
			--then set it as his new name
			setClientName( sPlayerElement, taggedName )
			--Tell the player who triggerd the command that the tag has been applied
			outputChatBox ( "Player " .. thePlayer .. "'s tag changed to " .. taggedName, source )
		end
	else
		--Tell the player who triggerd the command that the player could not be found
		outputChatBox ( "Unable to change player tag: Player " .. thePlayer .. " not found", source )
	end
end
--Add a command handler for either the console or / chat commands
--Example: /changetag <playername> <tag>
addCommandHandler ( "changetag", tagPlayer )

See Also

BEFORE VERSION 1.0 :