Jump to content

[Help] DrawHUD after logged


Wumbaloo

Recommended Posts

Hey, here's my problem: I've a loginGUI and I want to draw the HUD when I'm logged, I don't know how to do that

I tried with "export..", "dofile" but some errors, i tried with addEventHandler too..

client file for the hud is in: hud/client.lua

and the client file for joining is: join/c_join.lua

Also tried like that:

function fermerpanelconnexion(source) 
    guiSetEnabled(loginpanel, false) 
    destroyElement(loginpanel) 
    destroyElement(usernameInput) 
    destroyElement(passwordInput) 
    destroyElement(bouttonconnexion) 
    destroyElement(boutoncreercompte) 
    destroyElement(savemdp) 
    showCursor(false) 
    stopSound(soundmain) 
drawHud() 
end 

Can you help me?

Link to comment

Just create a simple function which will remove the render.

Here is a simple example,

  
  
setCustomHudVisible (no) 
  
function setCustomHudVisible (bool) 
    if not (bool) then  
        return  
    end 
     
    if (bool == yes) then 
        addEventHandler('onClientRender',root,nameOfTheFunction) 
    elseif (bool == no) then  
        removeEventHandler('onClientRender',root,nameOfTheFunction) 
    end 
end 

Link to comment

I deal with it:

function setCustomHudVisible(stateHud) 
    stateHud = not stateHud 
    if stateHud == true then 
        addEventHandler("onClientRender", getRootElement(), drawHud) 
    elseif stateHud == false then 
        removeEventHandler("onClientRender", getRootElement(), drawHud) 
    end 
end 
stateHud = false 
addEventHandler("onPlayerSpawn", getRootElement(), setCustomHudVisible(true)) 

But ingame warning "Expected function at argument 3, got none", and then, in the s_join.lua, i wrote it: "stateHud = true" when the player is logged, but error, i export the function in the meta but don't work

Link to comment

Tried with the MySQL data: "connect" but still not working..

No error messages..

Function:

datHud = getElementData(getLocalPlayer(), "connecter") 
function drawHud() 
    if datHud == "1" or 1 then 
        --HUD FUNCTION 
        addEventHandler("onClientRender", getRootElement(), drawHud) 
    else 
        removeEventHandler("onClientRender", getRootElement(), drawHud) 
    end 
end 

Link to comment

Still not working..

    function drawHud() 
        local isLoggedIn = getElementData(localPlayer, "connecter") 
        if not isLoggedIn then return end 
        
        -- DRAW HUD 
        
    end 
    addCommandHandler("onClientRender", root, drawHud) 

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