SetPlayerHudComponentVisible

From Multi Theft Auto: Wiki
Revision as of 13:43, 11 January 2017 by Haha (talk | contribs) (→‎Syntax)
Jump to navigation Jump to search

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

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

EJECT

TO

PSEUDO

SKRYPTER

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.

-- 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 [-]
Client

This example hides the ammo and weapon 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