Jump to content

Key Hide Hud


iPanda

Recommended Posts

My life does not work: (

Purpose: When you press key F, then hides HUD, pressing the key returns back to HUD.

function hudChanger ( key ) 
    local key = "F6" 
    if key == "F6" then 
        showPlayerHudComponent ( source, "ammo", false ) 
        showPlayerHudComponent ( source, "area_name", false ) 
        showPlayerHudComponent ( source, "armour", false )     
        showPlayerHudComponent ( source, "breath", false ) 
        showPlayerHudComponent ( source, "clock", false ) 
        showPlayerHudComponent ( source, "health", false ) 
        showPlayerHudComponent ( source, "money", false )  
        showPlayerHudComponent ( source, "radar", false ) 
        showPlayerHudComponent ( source, "vehicle_name", false ) 
        showPlayerHudComponent ( source, "radio", false ) 
        showPlayerHudComponent ( source, "weapon", false ) 
        showPlayerHudComponent ( source, "wanted", false ) 
    else 
        showPlayerHudComponent ( source, "ammo", false ) 
        showPlayerHudComponent ( source, "area_name", false ) 
        showPlayerHudComponent ( source, "armour", false )     
        showPlayerHudComponent ( source, "breath", false ) 
        showPlayerHudComponent ( source, "clock", false ) 
        showPlayerHudComponent ( source, "health", false ) 
        showPlayerHudComponent ( source, "money", false )  
        showPlayerHudComponent ( source, "radar", true ) 
        showPlayerHudComponent ( source, "vehicle_name", false ) 
        showPlayerHudComponent ( source, "radio", false ) 
        showPlayerHudComponent ( source, "weapon", false ) 
        showPlayerHudComponent ( source, "wanted", false ) 
    end 
end 
  
addEventHandler ("onPlayerJoin", getRootElement (), 
    function () 
        addEventHandler ( "onResourceStart", source, hudChanger) 
    end 
) 
  
bindKey( key, "down", hudChanger ) 

Link to comment
local key = "F6" 
  
function hudChanger ( thePlayer ) 
    showPlayerHudComponent ( thePlayer, "all", ( not isPlayerHudComponentVisible ( thePlayer, "ammo" ) ) ) 
end 
  
addEventHandler ( "onPlayerJoin", getRootElement (), 
    function ( ) 
        bindKey ( source, key, "down", hudChanger ) 
    end 
) 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            bindKey ( player, key, "down", hudChanger ) 
        end 
    end 
) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...