SetPlayerNametagShowing: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__
{{Server 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 -->
Use this to define whether the player's name tag is visible or invisible.
Use this to define whether the player's name tag is visible or invisible.
Line 20: 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">
players = {}
--Store all the players in the server into the table
--Make a table called players
players = getElementsByType ( "player" )
players = getElementsByType ( "player" )
--Store all the players in the server into the table


addEventHandler ( "onResourceStart", root, "ResourceStart" )
function ResourceStart ( name, root )
function ResourceStart ( name, root )
for k,v in players do
    for k,v in ipairs(players) do                         -- for all the players in the table
--for all the players in the table
        setPlayerNametagShowing ( v, false )     -- turn off their nametag
setPlayerNametagShowing ( v, false )
    end
--turn off their nametag
end
end
end
addEventHandler ( "onResourceStart", root, ResourceStart )


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


</syntaxhighlight>
</syntaxhighlight>

Revision as of 21:39, 15 August 2007

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

--Store all the players in the server into the table
players = getElementsByType ( "player" )

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

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

See Also