SetPlayerNametagText: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Syntax: OOP syntax added) |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | ||
This | This will change the text of a player's nickname in the world to something besides the nickname he chose. This will not change the player's actual nickname, it only changes the visible aspect inside the world (you will see his original nickname in the scoreboard and will refer to his original name in scripts). | ||
==Syntax== | ==Syntax== | ||
Line 8: | Line 9: | ||
bool setPlayerNametagText ( player thePlayer, string text ) | bool setPlayerNametagText ( player thePlayer, string text ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:setNametagText|nametagText|getPlayerNametagText}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | <!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | ||
*''' | *'''thePlayer:''' The player whose nickname text you wish to change | ||
*'''text:''' The new nickname text that will be displayed | |||
*''' | |||
===Returns=== | ===Returns=== | ||
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | <!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | ||
Returns ''true'' if | Returns ''true'' if successful, ''false'' otherwise. | ||
==Example== | ==Example== | ||
< | <section name="Server" class="server" show="true"> | ||
This | This console command lets you change the name tag of lamers. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--This | function iHateLamers ( thePlayer, commandName, playername ) | ||
-- This is a command handler that activates on text "lamer" followed by the playername | |||
-- | -- in the console. The playername argument was added as an extra function argument to store the | ||
-- name of the player whose text will be changed. | |||
if not playername then | |||
-- Prevents the command from running if the player did not specify a value for playername | |||
outputChatBox ( "You MUST define a player to change his name tag!", thePlayer ) | |||
else | |||
local culprit = getPlayerFromName ( playername ) | |||
-- This variable stores the result of trying to find the player associated with the playername | |||
-- that the user of the command specified | |||
if culprit then | |||
-- This checks to make sure a player nick was found. If it was not then the playername argument | |||
-- specified by the command user was not equivalent to the name of any players in the server | |||
setPlayerNametagText ( culprit, "IM_LAME" ) | |||
-- finally, the nickname text is changed since the command arguments were checked and are valid | |||
else | |||
outputChatBox ( "Player does not exist!", thePlayer ) | |||
end | |||
end | |||
end | |||
addCommandHandler ( "lamer", iHateLamers ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{ | {{Player_functions}} | ||
Latest revision as of 04:53, 15 July 2014
This will change the text of a player's nickname in the world to something besides the nickname he chose. This will not change the player's actual nickname, it only changes the visible aspect inside the world (you will see his original nickname in the scoreboard and will refer to his original name in scripts).
Syntax
bool setPlayerNametagText ( player thePlayer, string text )
OOP Syntax Help! I don't understand this!
- Method: player:setNametagText(...)
- Variable: .nametagText
- Counterpart: getPlayerNametagText
Required Arguments
- thePlayer: The player whose nickname text you wish to change
- text: The new nickname text that will be displayed
Returns
Returns true if successful, false otherwise.
Example
Click to collapse [-]
ServerThis console command lets you change the name tag of lamers.
function iHateLamers ( thePlayer, commandName, playername ) -- This is a command handler that activates on text "lamer" followed by the playername -- in the console. The playername argument was added as an extra function argument to store the -- name of the player whose text will be changed. if not playername then -- Prevents the command from running if the player did not specify a value for playername outputChatBox ( "You MUST define a player to change his name tag!", thePlayer ) else local culprit = getPlayerFromName ( playername ) -- This variable stores the result of trying to find the player associated with the playername -- that the user of the command specified if culprit then -- This checks to make sure a player nick was found. If it was not then the playername argument -- specified by the command user was not equivalent to the name of any players in the server setPlayerNametagText ( culprit, "IM_LAME" ) -- finally, the nickname text is changed since the command arguments were checked and are valid else outputChatBox ( "Player does not exist!", thePlayer ) end end end addCommandHandler ( "lamer", iHateLamers )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState