GetClientName: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function | This function gets a [[client]]'s name (a client can either be a [[player]] or an admin). | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
* '''theClient:''' The | * '''theClient:''' The [[client]] element (player or admin) you want to get the name of. | ||
===Returns=== | ===Returns=== | ||
Returns a string containing the requested client's name, or ''false'' if the client passed to the function is invalid. | Returns a ''string'' containing the requested client's name, or ''false'' if the client passed to the function is invalid. | ||
==Example== | ==Example== | ||
This example | This example adds a tag before a player's nick. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function tagPlayer( thePlayer, tag ) | |||
--we check thePlayer is a player, otherwise this function could be used with admins | |||
-- | if getElementType(thePlayer) == "player" then | ||
if ( | --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 | ||
end | end |
Revision as of 14:53, 25 April 2007
This function gets a client's name (a client can either be a player or an admin).
Syntax
string getClientName ( client theClient )
Required Arguments
- theClient: The client element (player or admin) you want to get the name of.
Returns
Returns a string containing the requested client's name, or false if the client passed to the function is invalid.
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