SetClientName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This function sets the name of the specified client.
This function changes the specified [[client]]'s name.


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


===Required Arguments===  
===Required Arguments===  
*'''theClient:''' The client that will have it's name set
*'''theClient:''' the [[client]] that will have its name set.
*'''name:''' The name to set for the client
*'''newName:''' the new name to set for the client.


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


==Example==  
==Example==
This example does...
This example adds a tag before a player's nick.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function tagPlayer( thePlayer, tag )
blabhalbalhb --abababa
--we check thePlayer is a player, otherwise this function could be used with admins
--This line does this...
if getElementType( thePlayer ) == "player" then
mooo
--we store the player's current name,
local oldName = getClientName( thePlayer )
--append the tag passed to this function before it,
local taggedName = tag .. oldName
--then set it as his new name
setClientName( thePlayer, taggedName )
end
end
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 14:56, 25 April 2007

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

This example adds a tag before a player's nick.

function tagPlayer( thePlayer, tag )
	--we check thePlayer is a player, otherwise this function could be used with admins
	if getElementType( thePlayer ) == "player" then
		--we store the player's current name,
		local oldName = getClientName( thePlayer )
		--append the tag passed to this function before it,
		local taggedName = tag .. oldName
		--then set it as his new name
		setClientName( thePlayer, taggedName )
	end
end

See Also

BEFORE VERSION 1.0 :