IsPlayerHudComponentVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Client function}}
{{New feature/item|4.0132|1.3.1|4689|
This function can be used to check whether an hud component is visable or not.
This function can be used to check whether an hud component is visable or not.
}}
 
==Syntax==  
==Syntax==  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
bool isPlayerHudComponentVisible( player thePlayer, string component )
</syntaxhighlight>
===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:
:*'''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
{{New feature|3.0110|1.1|
:*'''radio:''' The display showing the radio label
:*'''wanted:''' The display showing the player's wanted level
:*'''crosshair:''' The weapon crosshair and sniper scope
}}
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool isPlayerHudComponentVisible( string component )
bool isPlayerHudComponentVisible( string component )
Line 36: Line 9:


===Required Arguments===  
===Required Arguments===  
*'''component:''' The component you wish to show or hide. Valid values are:
*'''component:''' The component you wish to check. Valid values are:
:*'''ammo:''' The display showing how much ammo the player has in their weapon
:*'''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
:*'''area_name:''' The text that appears containing the name of the area a player has entered
Line 52: Line 25:
:*'''crosshair:''' The weapon crosshair and sniper scope
:*'''crosshair:''' The weapon crosshair and sniper scope
}}
}}
</section>


===Returns===
===Returns===
Line 58: Line 30:


==Example==
==Example==
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
local components = {"ammo","area_name","armour","breath","clock","health","money",
local components = {"ammo","area_name","armour","breath","clock","health","money",
Line 71: Line 42:
end
end
end)</syntaxhighlight>
end)</syntaxhighlight>
</section>


==Requirements==
==Requirements==

Latest revision as of 20:46, 6 October 2013

This function can be used to check whether an hud component is visable or not.

Syntax

bool isPlayerHudComponentVisible( string component )

Required Arguments

  • component: The component you wish to check. Valid values are:
  • 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

Returns

Returns true if the component is visable, false if not.

Example

addEventHandler("onClientResourceStart",resourceRoot,function()
	local components = {"ammo","area_name","armour","breath","clock","health","money",
		"radar","vehicle_name","weapon","radio","wanted","crosshair"
	} --Table filled with all the available components to check
	for _,component in ipairs(components)do
		if isPlayerHudComponentVisible(component)then --check if the component is visible
			outputChatBox("Hud Component: "..component.." is visible!") --if it is then tell the client that
		else
			outputChatBox("Hud Component: "..component.." is not visible!") --if it is not then tell the client that it isn't
		end
	end
end)

Requirements

Minimum server version n/a
Minimum client version 1.3.1-9.04689

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 client="1.3.1-9.04689" />

See Also