SetPlayerHudComponentVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Tag: Reverted
Tag: Reverted
Line 81: Line 81:
This example hides the weapon icon, weapon ammo, health bar, clock, money, breath bar, armor bar & wanted level stars displays for players when they join. // Ten przykład ukrywa ikonę broni, amunicję, pasek zdrowia, zegar, pieniądze, pasek oddechu, pasek zbroi(kamizelka) i gwiazdki poszukiwanych poziomów.
This example hides the weapon icon, weapon ammo, health bar, clock, money, breath bar, armor bar & wanted level stars displays for players when they join. // Ten przykład ukrywa ikonę broni, amunicję, pasek zdrowia, zegar, pieniądze, pasek oddechu, pasek zbroi(kamizelka) i gwiazdki poszukiwanych poziomów.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Hide the hud when the resource is started
-- Hide the hud when the resource is started - Ukrywamy hud po dołączeniu do serwera.
local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }
local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }



Revision as of 08:02, 27 July 2021

[[{{{image}}}|link=|]] Note: This function is identical to showPlayerHudComponent

This function will show or hide a part of the player's HUD.

Syntax

Click to collapse [-]
Server
bool setPlayerHudComponentVisible ( player thePlayer, string component, bool show )

OOP Syntax Help! I don't understand this!

Method: player:setHudComponentVisible(...)


Required Arguments

  • thePlayer: The player element for which you wish to show/hide a HUD component
  • component: The component you wish to show or hide. Valid values are:
  • all: All of the following at the same time
  • ammo: The display showing how much ammo the player has in their weapon
  • area_name: The text that appears containing the name of the area a player has entered
  • armour: The display showing the player's armor
  • breath: The display showing the player's breath
  • clock: The display showing the in-game time
  • health: The display showing the player's health
  • money: The display showing how much money the player has
  • radar: The bottom-left corner miniradar
  • vehicle_name: The text that appears containing the player's vehicle name when the player enters a vehicle
  • weapon: The display showing the player's weapon
  • radio: The display showing the radio label
  • wanted: The display showing the player's wanted level
  • crosshair: The weapon crosshair and sniper scope
  • show: Specify if the component should be shown (true) or hidden (false)
Click to collapse [-]
Client
bool setPlayerHudComponentVisible ( string component, bool show )

Required Arguments

  • component: The component you wish to show or hide. Valid values are:
  • all: All of the following at the same time
  • ammo: The display showing how much ammo the player has in their weapon
  • area_name: The text that appears containing the name of the area a player has entered
  • armour: The display showing the player's armor
  • breath: The display showing the player's breath
  • clock: The display showing the in-game time
  • health: The display showing the player's health
  • money: The display showing how much money the player has
  • radar: The bottom-left corner miniradar
  • vehicle_name: The text that appears containing the player's vehicle name when the player enters a vehicle
  • weapon: The display showing the player's weapon
  • radio: The display showing the radio label
  • wanted: The display showing the player's wanted level
  • crosshair: The weapon crosshair and sniper scope
  • show: Specify if the component should be shown (true) or hidden (false)

Returns

Returns true if the component was shown or hidden succesfully, false if an invalid argument was specified.

Requirements

Minimum server version 1.3.2
Minimum client version 1.3.2

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.3.2" client="1.3.2" />

Example

Click to collapse [-]
Server

This example hides the ammo and weapon displays for players when they join. / Ten przykład ukrywa wyświetlanie amunicji i broni dla graczy którzy dołączą na serwer.

-- Hide some of the hud components when a player joins the server / Ukrywanie niektórych elementów interfejsu jak gracz dołącza do serwera.
addEventHandler ( "onPlayerJoin", root, 
    function ()
        setPlayerHudComponentVisible ( source, "ammo", false )    -- Hide the ammo displays for the newly joined player / Ukrywanie amunicji dla osoby, która dołącza na serwer. 
        setPlayerHudComponentVisible ( source, "weapon", false )  -- Hide the weapon displays for the newly joined player / Ukrywanie broni dla osoby, która dołączyła na serwer.
    end
)
Click to collapse [-]
Client

This example hides the weapon icon, weapon ammo, health bar, clock, money, breath bar, armor bar & wanted level stars displays for players when they join. // Ten przykład ukrywa ikonę broni, amunicję, pasek zdrowia, zegar, pieniądze, pasek oddechu, pasek zbroi(kamizelka) i gwiazdki poszukiwanych poziomów.

-- Hide the hud when the resource is started - Ukrywamy hud po dołączeniu do serwera. 
local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

See Also