UnchiuDawg Posted April 13, 2017 Posted April 13, 2017 (edited) Hi, I'm new to lua and scripting itself. I'm trying to make a simple login panel. Almost everything works right, except this one thing: serverside: function loginHandler ( usernamelogin, passwordlogin ) local accountlogin = getAccount ( usernamelogin, passwordlogin ) if ( accountlogin ~= false ) then logIn ( client, accountlogin, passwordlogin ) fadeCamera(client, false, 1.5) setTimer(fadeCameraDelay,1500,1,client) else outputChatBox ( "Wrong username or password!", client, 255, 255, 0 ) -- the login failed end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) clientside: function clientSubmitLogin(button,state) if button == "left" and state == "up" then local usernamelogin = guiGetText(UserLogin) local passwordlogin = guiGetText(PassLogin) triggerServerEvent("submitLogin", getRootElement(), usernamelogin, passwordlogin) guiSetInputEnabled(false) -- should not happen if login failed guiSetVisible(LoginPanel, false) -- should not happen if login failed showCursor(false) -- should not happen if login failed stopSound(loginpanelsong) -- should not happen if login failed end end This is for the login button, but I don't know how to make some of the functions (the ones I put comments on) not happen when the login fails. I tried working around it but still couldn't figure it out and I kept looking on the wiki but couldn't find a way to do it. Any help is appreciated Edited April 13, 2017 by UnchiuDawg
NeXuS™ Posted April 13, 2017 Posted April 13, 2017 (edited) Server side function loginHandler ( usernamelogin, passwordlogin ) local accountlogin = getAccount ( usernamelogin, passwordlogin ) if ( accountlogin ~= false ) then logIn ( client, accountlogin, passwordlogin ) fadeCamera(client, false, 1.5) setTimer(fadeCameraDelay,1500,1,client) triggerClientEvent(client, "hideLogin", getRootElement()) else outputChatBox ( "Wrong username or password!", client, 255, 255, 0 ) -- the login failed end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) Client side function clientSubmitLogin(button,state) if button == "left" and state == "up" then local usernamelogin = guiGetText(UserLogin) local passwordlogin = guiGetText(PassLogin) triggerServerEvent("submitLogin", getRootElement(), usernamelogin, passwordlogin) end end addEvent("hideLogin", true) addEventHandler("hideLogin", getRootElement(), function() guiSetInputEnabled(false) guiSetVisible(LoginPanel, false) showCursor(false) stopSound(loginpanelsong) end Should work mate. Edited April 13, 2017 by NeXuS™ 1
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