SetPlayerHudComponentVisible: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(25 intermediate revisions by 13 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function will show or hide a part of the player's HUD. | This function will show or hide a part of the player's HUD. | ||
Line 10: | Line 9: | ||
bool setPlayerHudComponentVisible ( player thePlayer, string component, bool show ) | bool setPlayerHudComponentVisible ( player thePlayer, string component, bool show ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]: | {{OOP||[[player]]:setHudComponentVisible||}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The player element for which you wish to show/hide a HUD component | *'''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: | *'''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 | :*'''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 28: | Line 28: | ||
:*'''wanted:''' The display showing the player's wanted level | :*'''wanted:''' The display showing the player's wanted level | ||
:*'''crosshair:''' The weapon crosshair and sniper scope | :*'''crosshair:''' The weapon crosshair and sniper scope | ||
}} | }} | ||
*'''show:''' Specify if the component should be shown (''true'') or hidden (''false'') | *'''show:''' Specify if the component should be shown (''true'') or hidden (''false'') | ||
Line 40: | Line 38: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''component:''' The component you wish to show or hide. Valid values are: | *'''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 | :*'''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 54: | Line 53: | ||
:*'''wanted:''' The display showing the player's wanted level | :*'''wanted:''' The display showing the player's wanted level | ||
:*'''crosshair:''' The weapon crosshair and sniper scope | :*'''crosshair:''' The weapon crosshair and sniper scope | ||
}} | }} | ||
*'''show:''' Specify if the component should be shown (''true'') or hidden (''false'') | *'''show:''' Specify if the component should be shown (''true'') or hidden (''false'') | ||
Line 62: | Line 59: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the component was shown or hidden succesfully, ''false'' if an invalid argument was specified. | Returns ''true'' if the component was shown or hidden succesfully, ''false'' if an invalid argument was specified. | ||
==Example== | ==Example== | ||
Line 77: | Line 71: | ||
end | end | ||
) | ) | ||
</syntaxhighlight> | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
This example lets players hide or bring up their bottom-left radar with a command | |||
<syntaxhighlight lang="lua"> | |||
function toggleRadar() | |||
state = not state | |||
setPlayerHudComponentVisible("radar", state) | |||
end | |||
addCommandHandler( "toggleradar", toggleRadar) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
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. | |||
<syntaxhighlight lang="lua"> | |||
-- Hide the hud when the resource is started | |||
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) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 17:10, 7 November 2024
This function will show or hide a part of the player's HUD.
Syntax
Click to collapse [-]
Serverbool 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 [-]
Clientbool 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.
Example
Click to collapse [-]
ServerThis example hides the ammo and weapon displays for players when they join.
-- Hide some of the hud components when a player joins the server addEventHandler ( "onPlayerJoin", root, function () setPlayerHudComponentVisible ( source, "ammo", false ) -- Hide the ammo displays for the newly joined player setPlayerHudComponentVisible ( source, "weapon", false ) -- Hide the weapon displays for the newly joined player end )
Click to collapse [-]
ClientThis example lets players hide or bring up their bottom-left radar with a command
function toggleRadar() state = not state setPlayerHudComponentVisible("radar", state) end addCommandHandler( "toggleradar", toggleRadar)
Click to collapse [-]
ClientThis example hides the weapon icon, weapon ammo, health bar, clock, money, breath bar, armor bar & wanted level stars displays for players when they join.
-- Hide the hud when the resource is started 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
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState