Jump to content

Hide the HUD


Trinx

Recommended Posts

Hi!

I started in LUA script for a few days, and I would need help for my first scripts.

I want to hide the radar and time of the interface, I try to script a code for it.

function CacherInterface () 
         setPlayerHudComponentVisible ( source, "radar", false ) -- Cacher le Radar 
         setPlayerHudComponentVisible ( source, "clock", false ) -- Cacher l'heure 
end 
addEventHandler ("onResourceStart", getRootElement(), CacherInterface) 

I want the time and has radar disappear activation of the resource, but it does not work.

No Error in DebugScript / Console / MTA Script Editor.

Sorry for my english, i'm french and I use a translator.

Help :(

Link to comment

source here is a resource, not the player. That's why it doesn't work.

Just type it on client side without any events:

setPlayerHudComponentVisible ( "radar", false ) 
setPlayerHudComponentVisible ( "clock", false ) 

Edited by Guest
  • Like 1
Link to comment
  • 3 years later...
On 8/3/2013 at 05:02, Kenix said:

source here is a resource, not the player. That's why it doesn't work.

Just type it on client side without any events:


setPlayerHudComponentVisible ( "radar", false ) 
setPlayerHudComponentVisible ( "clock", false ) 
 

 

1

For me it only hides the time ;((((((( How to hide the whole hud?

Link to comment
  • 8 months later...
On 3/8/2013 at 14:02, Kenix said:

source here is a resource, not the player. That's why it doesn't work.

Just type it on client side without any events:

?


 
  1.  
  2. setPlayerHudComponentVisible ( "radar", false )
  3. setPlayerHudComponentVisible ( "clock", false )
 

 

A question and how can you put it for the player is what I'm looking for please help me !!

function hudChangerOFF ()
    setPlayerHudComponentVisible ( "radar", false ) 
    setPlayerHudComponentVisible ( "clock", false ) 
    setPlayerHudComponentVisible ( "all", false )
    showPlayerHudComponent ( source, "ammo", false )    
    showPlayerHudComponent ( source, "weapon", false )  
    showPlayerHudComponent ( source, "radar", false )
    showPlayerHudComponent("all",false) 
    showChat(false)
    showCursor ( false ) 

end
addCommandHandler ("visiblehud", hudChangerOFF)

function hudChangerON ()
    setPlayerHudComponentVisible ( "radar", true ) 
    setPlayerHudComponentVisible ( "all", true )
    setPlayerHudComponentVisible ( "clock", true ) 
    showPlayerHudComponent ( source, "ammo", true )  
    showPlayerHudComponent ( source, "weapon", true )  
    showPlayerHudComponent ( source, "radar", true )
    showChat(true)
    showCursor ( true )
    showPlayerHudComponent("all",false) 

end

addCommandHandler ("disablehud", hudChangerON)
 

I want that when the player puts visiblehud everything is opened and when I put disablehud everything is hidden

Edited by xSrJulianProHG
Link to comment
3 hours ago, xSrJulianProHG said:

A question and how can you put it for the player is what I'm looking for please help me !!

function hudChangerOFF ()
    setPlayerHudComponentVisible ( "radar", false ) 
    setPlayerHudComponentVisible ( "clock", false ) 
    setPlayerHudComponentVisible ( "all", false )
    showPlayerHudComponent ( source, "ammo", false )    
    showPlayerHudComponent ( source, "weapon", false )  
    showPlayerHudComponent ( source, "radar", false )
    showPlayerHudComponent("all",false) 
    showChat(false)
    showCursor ( false ) 

end
addCommandHandler ("visiblehud", hudChangerOFF)

function hudChangerON ()
    setPlayerHudComponentVisible ( "radar", true ) 
    setPlayerHudComponentVisible ( "all", true )
    setPlayerHudComponentVisible ( "clock", true ) 
    showPlayerHudComponent ( source, "ammo", true )  
    showPlayerHudComponent ( source, "weapon", true )  
    showPlayerHudComponent ( source, "radar", true )
    showChat(true)
    showCursor ( true )
    showPlayerHudComponent("all",false) 

end

addCommandHandler ("disablehud", hudChangerON)
 

I want that when the player puts visiblehud everything is opened and when I put disablehud everything is hidden

Use else statement to make whole code  work under one command handler on or off when they type disablehud

  • Thanks 1
Link to comment
8 hours ago, Khadeer143 said:

Use else statement to make whole code  work under one command handler on or off when they type disablehud

but thanks anyway with the idea you gave me I was able to do this, and it worked


Hud = guiCreateLabel(0, 0, 0, 0, "", false)
  
function HideShow() 
    if ( guiGetVisible (Hud) == false) then 
    guiSetVisible (Hud, true) -- Este Es el Laber FAKE PARA PODER OCULTAR EL HUD Y ABRIR EL HUD 
    
    showChat(true)
    showPlayerHudComponent("all",true) 
    setPlayerHudComponentVisible ( "radar", true ) 
    setPlayerHudComponentVisible ( "all", true )
    setPlayerHudComponentVisible ( "clock", true ) 
    showPlayerHudComponent ( source, "ammo", true )  
    showPlayerHudComponent ( source, "weapon", true )  
    showPlayerHudComponent ( source, "radar", true )
    
    else 
    guiSetVisible(Hud, false) -- Este Es el Laber FAKE PARA PODER ABRIR EL HUD Y OCULTAR EL HUD 
    
    showCursor(false)
    showChat(false)    
    showPlayerHudComponent("all",false) 
    outputChatBox("Hud Disable", source, 255, 0, 0, true)
    showPlayerHudComponent ( source, "weapon", false )  
    showPlayerHudComponent ( source, "radar", false )    
    showPlayerHudComponent ( source, "ammo", false )
    setPlayerHudComponentVisible ( "radar", false ) 
    setPlayerHudComponentVisible ( "clock", false ) 
    setPlayerHudComponentVisible ( "all", false )
    showPlayerHudComponent("all",false) 
   end 
end 
bindKey("f5", "down", HideShow) 

Link to comment

Aqui tienes un codigo mas corto. Dado que el tuyo problamente te de errores.

local showingHud = true -- AQUIT CAMBIALO POR 'false' si quieres que si/no se muestre desde el principio

function toggleHUD()
	showingHud = not showingHud
	if showingHud then
		showChat(true)
		setPlayerHudComponentVisible ( "all", true )
		outputChatBox("HUD Enabled")
	else
		showChat(false)
		setPlayerHudComponentVisible ( "all", false )
		outputChatBox("HUD Disabled")
	end
end
bindKey("f5","down",toggleHUD)

 

Link to comment
  • 3 years later...

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...