SetPlayerHudComponentVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 11: Line 11:
==Requirements==
==Requirements==
{{Requirements|1.3.2|1.3.2}}
{{Requirements|1.3.2|1.3.2}}
==Example==
<section name="Server" class="server" show="true">
This example hides the ammo and weapon displays for players when they join.
<syntaxhighlight lang="lua">
-- 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
)
</syntaxhighlight>
</section>
<section name="Client" class="client" show="true">
This example hides the ammo and weapon 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>
</section>


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

Revision as of 13:43, 11 January 2017