- Documentation
- Shared functions
- setPlayerHudComponentVisible
Function
setPlayerHudComponentVisible
Shows or hides a game HUD component. Each component works on its own: hiding money keeps health, armour, the weapon, the clock and the rest of the HUD in place. "all" affects all of them at once (including the radar) and clears earlier settings of single components. Components: ammo, armour (or armor), breath, clock, health, money, weapon, wanted, area_name, vehicle_name, radio, radar, all. The setting survives death and respawn; after reconnecting set it again (e.g. in onPlayerJoin).
Syntax
Server
bool setPlayerHudComponentVisible(player thePlayer, string component, bool show)Client
bool setPlayerHudComponentVisible(string component, bool show)Arguments
thePlayerplayer- A player or
root(server only). componentstring- Component name (see
getHudComponentNames). showbooltrueshows it.
Returns
true on success, false for an unknown component.
Example
addEventHandler("onClientResourceStart", resourceRoot, function()
setPlayerHudComponentVisible("money", false)
setPlayerHudComponentVisible("area_name", false)
end)
addEventHandler("onPlayerSpawn", root, function()
setPlayerHudComponentVisible(source, "all", true)
setPlayerHudComponentVisible(source, "money", false)
setPlayerHudComponentVisible(source, "wanted", false)
end)
See also
isPlayerHudComponentVisibleChecks whether a game HUD component is visible for the player (according tosetPlayerHudComponentVisible). A component with no setting of its own follows"all".getHudComponentNamesReturns the names of game HUD components that can be hidden separately:ammo,armour(orarmor),breath,clock,health,money,weapon,wanted,area_name,vehicle_name,radio,radar,all.showPlayerHudComponentAnother name forsetPlayerHudComponentVisible: shows or hides a game HUD component for a player (e.g."radar","money","health","all").