IsPlayerHudComponentVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{client function}} __NOTOC__ This function checks if the component is visible. ==Syntax== <syntaxhighlight lang="lua"> bool isPlayerHudComponentVisible ( string component ) </syntaxhighlight> ===Require...")
 
(Remove obsolete Requirements section)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{client function}}
__NOTOC__
__NOTOC__
{{Client function}}
This function can be used to check whether an hud component is visable or not.


This function checks if the component is visible.
==Syntax==
<syntaxhighlight lang="lua">
bool isPlayerHudComponentVisible( string component )
</syntaxhighlight>


==Syntax==
===Required Arguments===  
<syntaxhighlight lang="lua"> bool isPlayerHudComponentVisible ( string component ) </syntaxhighlight>
*'''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
{{New feature/item|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
}}


===Required===
===Returns===
''' component: ''' The component to check.
Returns ''true'' if the component is visable, ''false'' if not.


===Return===
==Example==
Returns true if the component is visible, else false.
<syntaxhighlight lang="lua">addEventHandler("onClientResourceStart",resourceRoot,function()
 
local components = {"ammo","area_name","armour","breath","clock","health","money",
===Example===
"radar","vehicle_name","weapon","radio","wanted","crosshair"
<syntaxhighlight lang="lua">addCommandHandler("isComponent",function(_,theComponent)
} --Table filled with all the available components to check
    if isPlayerHudComponentVisible(theComponent) then
for _,component in ipairs(components)do
          outputChatBox("Yes, the component "..theComponent.." is visible.")
if isPlayerHudComponentVisible(component)then --check if the component is visible
    else
outputChatBox("Hud Component: "..component.." is visible!") --if it is then tell the client that
          outputChatBox("No, the component "..theComponent.." is not visible or might not exist.")
else
    end
outputChatBox("Hud Component: "..component.." is not visible!") --if it is not then tell the client that it isn't
end
end
end)</syntaxhighlight>
end)</syntaxhighlight>


==See Also==
==See Also==
{{Client_player_functions}}
{{Player_functions}}

Latest revision as of 17:08, 7 November 2024

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)

See Also