SetPlayerNametagShowing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(17 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
{{Server client function}}
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{New feature|3|1.0|This function allows you to set whether a player's nametag visibility both clientside and serverside}}
 
Use this to define whether the player's name tag is visible or invisible.


==Syntax==  
==Syntax==  
Line 8: Line 10:
bool setPlayerNametagShowing ( player thePlayer, bool showing )
bool setPlayerNametagShowing ( player thePlayer, bool showing )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[player]]:setNametagShowing|nametagShowing|isPlayerNametagShowing}}
===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 -->
*'''thePlayer:''' Define the player whos tag visiblity status you want to change
*'''argumentName:''' description
*'''showing:''' Use true or false to show/hide the tag
 
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===Returns===
<!-- 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 successful, ''false'' otherwise
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This script will turn off player tags for everyone
This example does...
<!-- 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">
--This line does...
function onResourceStart ( )
blabhalbalhb --abababa
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table
--This line does this...
    for key, player in ipairs ( players ) do      -- for all the players in the table
mooo
        setPlayerNametagShowing ( player, false )  -- turn off their nametag
    end
end
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart )
 
function onPlayerJoin ( )
      -- Whoever joins the server should also have their nametags deactivated
setPlayerNametagShowing ( source, false )
end
addEventHandler ( "onPlayerJoin", root, onPlayerJoin )
 
</syntaxhighlight>
</syntaxhighlight>


==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 -->
{{Player functions}}
{{FunctionArea_functions}}
 
[[Category:Incomplete]] -- leave this unless you complete the function
 
[[ar:setPlayerNametagShowing]]

Latest revision as of 14:12, 24 March 2016

This function allows you to set whether a player's nametag visibility both clientside and serverside

Use this to define whether the player's name tag is visible or invisible.

Syntax

bool setPlayerNametagShowing ( player thePlayer, bool showing )

OOP Syntax Help! I don't understand this!

Method: player:setNametagShowing(...)
Variable: .nametagShowing
Counterpart: isPlayerNametagShowing


Required Arguments

  • thePlayer: Define the player whos tag visiblity status you want to change
  • showing: Use true or false to show/hide the tag

Returns

Returns true if successful, false otherwise

Example

This script will turn off player tags for everyone

function onResourceStart ( )
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table
    for key, player in ipairs ( players ) do       -- for all the players in the table
        setPlayerNametagShowing ( player, false )  -- turn off their nametag
    end
end
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart )

function onPlayerJoin ( )
      -- Whoever joins the server should also have their nametags deactivated
	setPlayerNametagShowing ( source, false )
end
addEventHandler ( "onPlayerJoin", root, onPlayerJoin )

See Also

Shared