SetPlayerNametagShowing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 21: Line 21:
This script will turn off player tags for everyone
This script will turn off player tags for everyone
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
root = getRootElement ( )
function onResourceStart ( )
-- Store all the players in the server into a table
    local players = getElementsByType ( "player" ) -- Store all the players in the server into a table
players = getElementsByType ( "player" )
     for key, player in ipairs ( players ) do       -- for all the players in the table
 
         setPlayerNametagShowing ( player, false ) -- turn off their nametag
function ResourceStart ( name, root )
     for k,v in ipairs ( players ) do             -- for all the players in the table
         setPlayerNametagShowing ( v, false )     -- turn off their nametag
     end
     end
end
end
addEventHandler ( "onResourceStart", root, ResourceStart )
addEventHandler ( "onResourceStart", root, onResourceStart )


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


</syntaxhighlight>
</syntaxhighlight>

Revision as of 20:23, 27 May 2014

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 )

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", root, onResourceStart )

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

See Also