Jump to content

Hide the custom made hud


..:D&G:..

Recommended Posts

Hey, I recently made a hud, and I want to hide it while the player is on the login screen. There is already a function to hide the default hud:

function hideInterfaceComponents() 
    --triggerEvent("hideHud", getLocalPlayer()) 
    showPlayerHudComponent("weapon", false) 
    showPlayerHudComponent("ammo", false) 
    showPlayerHudComponent("vehicle_name", false) 
    showPlayerHudComponent("money", false) 
    showPlayerHudComponent("clock", false) 
    showPlayerHudComponent("health", false) 
    showPlayerHudComponent("armour", false) 
    showPlayerHudComponent("breath", false) 
    showPlayerHudComponent("area_name", false) 
    showPlayerHudComponent("radar", false) 
    --triggerEvent("hideHud", getLocalPlayer()) 
     
    loadSettings() 
    saveLanguageInformation() 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), hideInterfaceComponents) 

But I need to hide the hud using its function (function hud....) as I can't use showPlayerHudComponent :P

Link to comment

Nobody can help you without knowing what custom HUD do you use, or how does it work if you wrote it yourself. I guess it uses the dx function, and thus it can be easily hidden by either removing the event handler for the time the player logs in, or creating a variable that would be checked before the drawing functions, and if it doesn't match, then don't draw the HUD.

Link to comment

I don't really know why you want to see a function with some dx lines... But anyway here is the code:

function hudComponents ( ) 
    munitie = getPedTotalAmmo ( getLocalPlayer() ) 
    clip = getPedAmmoInClip ( getLocalPlayer() ) 
    IDarma = getPedWeapon(getLocalPlayer()) 
    arma = getWeaponNameFromID(IDarma) 
    viata = getElementHealth (localPlayer) 
    armura = getPedArmor (localPlayer) 
    bani = getPlayerMoney(thePlayer)  
    dxDrawRectangle(15, 240, 264, 78, tocolor(0, 0, 0, 209), false) 
    dxDrawLine(15, 260, 278, 260, tocolor(255, 255, 255, 255), 1, false) 
    dxDrawLine(15, 279, 278, 279, tocolor(255, 255, 255, 255), 1, false) 
    dxDrawLine(15, 296, 278, 296, tocolor(255, 255, 255, 255), 1, false) 
      dxDrawText("World Gaming Roleplay Hud", 14, 213, 277, 233, tocolor(255, 255, 255, 255), 0.90, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText("Bani: "..bani.." Lei",21.0,244.0,474.0,272.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Viata: "..tostring(math.floor(viata+0.5)).." %",20.0,264.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Armura: "..tostring(math.floor(armura+0.5)).." %",20.0,281.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Arma: "..arma.." | Munitie: "..clip.." / "..munitie,20.0,296.0,296.0,301.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
end 
addEventHandler("onClientRender",getRootElement(),hudComponents) 
addEventHandler("onClientPlayerSpawn",getRootElement(),) 

Link to comment

Client:

function hudComponents ( ) 
    munitie = getPedTotalAmmo ( getLocalPlayer() ) 
    clip = getPedAmmoInClip ( getLocalPlayer() ) 
    IDarma = getPedWeapon(getLocalPlayer()) 
    arma = getWeaponNameFromID(IDarma) 
    viata = getElementHealth (localPlayer) 
    armura = getPedArmor (localPlayer) 
    bani = getPlayerMoney(thePlayer) 
    end 
    addEventHandler("loginHudShow",getRootElement(), hudComponents) 
    addEvent ("loginHudShow", true) 
     
    addEventHandler("onClientRender",getRootElement(), 
    dxDrawRectangle(15, 240, 264, 78, tocolor(0, 0, 0, 209), false) 
    dxDrawLine(15, 260, 278, 260, tocolor(255, 255, 255, 255), 1, false) 
    dxDrawLine(15, 279, 278, 279, tocolor(255, 255, 255, 255), 1, false) 
    dxDrawLine(15, 296, 278, 296, tocolor(255, 255, 255, 255), 1, false) 
    dxDrawText("World Gaming Roleplay Hud", 14, 213, 277, 233, tocolor(255, 255, 255, 255), 0.90, "pricedown", "left", "top", false, false, true, false, false) 
    dxDrawText("Bani: "..bani.." Lei",21.0,244.0,474.0,272.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Viata: "..tostring(math.floor(viata+0.5)).." %",20.0,264.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Armura: "..tostring(math.floor(armura+0.5)).." %",20.0,281.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
    dxDrawText("Arma: "..arma.." | Munitie: "..clip.." / "..munitie,20.0,296.0,296.0,301.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) 
end 
) 

Server:

function showHudOnLogin () 
triggerClientEvent (source, "loginHudShow", source) 
end 
addEventHandler ("onPlayerLogin", getRootElement(), showHudOnLogin) 

(Not tested)

Link to comment

Look, onPlayerLogin is useless, is not a login like the ones on play servers, or LIKE the default /login... So this won't really work, this login is only a window where you put some details and click a button to close the window and be able to play (something like that) Doesn't matter anyway, did it which what johny46 recommended me. Thanks.

Link to comment
  • Moderators

Don't forget to make your variables local, especially when you use render functions. It simply will start lagging if you don't.

  
  
local renderHud = function () 
  
local munitie = getPedTotalAmmo ( localPlayer) 
local clip = getPedAmmoInClip ( localPlayer) 
local IDarma = getPedWeapon(localPlayer) 
local arma = getWeaponNameFromID(IDarma) 
local viata = getElementHealth (localPlayer) 
local armura = getPedArmor (localPlayer) 
local bani = getPlayerMoney()-- "thePlayer" this shouldn't be there. 
  
-- put your dx stuff here-- 
  
  
-------------------------------- 
  
end 
local handler = true 
addEventHandler("onClientRender",root,renderHud) 
  
addCommandHandler("showhud", 
function () 
if handler  then 
removeEventHandler("onClientRender",root,renderHud) 
handler = false 
else 
addEventHandler("onClientRender",root,renderHud) 
handler = true 
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...