Wumbaloo Posted August 9, 2015 Share Posted August 9, 2015 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
GTX Posted August 9, 2015 Share Posted August 9, 2015 Put them in same resource or file. Or you can use triggerEvent Link to comment
Wumbaloo Posted August 9, 2015 Author Share Posted August 9, 2015 But, how can I hide my hud? Like, it's turn off and if i log on, my hud appeared Link to comment
Wumbaloo Posted August 9, 2015 Author Share Posted August 9, 2015 How can I hide the HUD first of all, when i do that, i can call it Link to comment
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 Nah, my Hud that i do with directX dxDrawText dxDrawImage .. Link to comment
xeon17 Posted August 11, 2015 Share Posted August 11, 2015 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
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 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
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 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
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 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
GTX Posted August 11, 2015 Share Posted August 11, 2015 Note that element data "connecter" must be boolean. Link to comment
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 It return 1 if the player is spawned, else, return 0 Link to comment
GTX Posted August 11, 2015 Share Posted August 11, 2015 if isLoggedIn == 0 then return end Link to comment
Wumbaloo Posted August 11, 2015 Author Share Posted August 11, 2015 Finally work! Thanks! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now