IsPlayerNametagShowing: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Syntax: OOP syntax added) |
||
(10 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
{{Deprecated feature|3|1.0|Serverside only in DP2.x}} | |||
<!-- 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 function will allow you to determine if a player's name tag is currently showing. | This function will allow you to determine if a player's name tag is currently showing. | ||
Line 8: | Line 10: | ||
bool isPlayerNametagShowing ( player thePlayer ) | bool isPlayerNametagShowing ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:isNametagShowing|nametagShowing|setPlayerNametagShowing}} | |||
===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 --> | ||
Line 15: | Line 17: | ||
===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 the player's name tag is being shown, ''false'' otherwise. | ||
==Example== | ==Example== | ||
<!-- Explain what the example is in a single sentance --> | <!-- Explain what the example is in a single sentance --> | ||
This example | This example toggles a player's nametag. If no playername is given, it toggles the nametag of the player who entered the command. | ||
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | <!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function toggleNametag ( sourcePlayer, command, who ) | |||
local tplayer = sourcePlayer -- by default, toggle the name tag of the player who issued the command | |||
if ( who ) then -- if there was a nick entered in the command | |||
-- | tplayer = getPlayerFromName ( who ) -- search for the player | ||
-- | else | ||
whoNick = getPlayerName(sourcePlayer) | |||
end | |||
if ( tplayer ~= false ) then -- if the player was found (or no playername was entered) | |||
if isPlayerNametagShowing ( tplayer ) then -- if the nametag is shown | |||
setPlayerNametagShowing ( tplayer, false ) -- hide it | |||
outputChatBox ( who .. "'s nametag is now hidden", sourcePlayer ) -- output a message to the player who entered the command | |||
else -- if the nametag is not shown | |||
setPlayerNametagShowing ( tplayer, true ) -- show it | |||
outputChatBox ( who .. "'s nametag is now showing", sourcePlayer ) -- output a message to the player who entered the command | |||
end | |||
else | else | ||
outputChatBox ( "Player not found.", sourcePlayer ) | |||
end | end | ||
end | end | ||
addCommandHandler ( "toggleNametag", toggleNametag ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 40: | Line 49: | ||
<!-- 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}} | {{Player_functions}} | ||
Latest revision as of 05:17, 15 July 2014
This function will allow you to determine if a player's name tag is currently showing.
Syntax
bool isPlayerNametagShowing ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:isNametagShowing(...)
- Variable: .nametagShowing
- Counterpart: setPlayerNametagShowing
Required Arguments
- thePlayer: The player whose current name tag condition you want to check
Returns
Returns true if the player's name tag is being shown, false otherwise.
Example
This example toggles a player's nametag. If no playername is given, it toggles the nametag of the player who entered the command.
function toggleNametag ( sourcePlayer, command, who ) local tplayer = sourcePlayer -- by default, toggle the name tag of the player who issued the command if ( who ) then -- if there was a nick entered in the command tplayer = getPlayerFromName ( who ) -- search for the player else whoNick = getPlayerName(sourcePlayer) end if ( tplayer ~= false ) then -- if the player was found (or no playername was entered) if isPlayerNametagShowing ( tplayer ) then -- if the nametag is shown setPlayerNametagShowing ( tplayer, false ) -- hide it outputChatBox ( who .. "'s nametag is now hidden", sourcePlayer ) -- output a message to the player who entered the command else -- if the nametag is not shown setPlayerNametagShowing ( tplayer, true ) -- show it outputChatBox ( who .. "'s nametag is now showing", sourcePlayer ) -- output a message to the player who entered the command end else outputChatBox ( "Player not found.", sourcePlayer ) end end addCommandHandler ( "toggleNametag", toggleNametag )
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