SetClientName: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 17: | Line 17: | ||
This example adds a tag before a player's nick. | This example adds a tag before a player's nick. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function tagPlayer( thePlayer, tag ) | function tagPlayer( command, thePlayer, tag ) | ||
--we check thePlayer is a player, otherwise this function could be used with admins | --we check thePlayer is a player, otherwise this function could be used with admins | ||
if getElementType( thePlayer ) == "player" then | if getElementType( thePlayer ) == "player" then | ||
Line 28: | Line 28: | ||
end | end | ||
end | end | ||
addCommandHandler ( "changetag", tagPlayer ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_functions}} | {{Client_functions}} |
Revision as of 07:55, 3 August 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( command, 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 addCommandHandler ( "changetag", tagPlayer )