thund3rbird23 Posted July 4, 2023 Share Posted July 4, 2023 My problem is, when I click on the button 2 which is register then it's click twice on the button, but I only click once, why? function Panel:loginClick(button, state) if self.show and self.hovered == 'buttons' and self.selectedbutton == 1 then for key, value in pairs(self.loginGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.ml_notification:addNotification('All fields are required!', 'warning') destroyAnimation() break else triggerServerEvent('loginaccount', localPlayer, localPlayer, self.loginGuis[1].text, self.loginGuis[2].text) destroyAnimation() end end elseif self.show and self.hovered == 'buttons' and self.selectedbutton == 2 then for key, value in ipairs(self.registerGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.notification:addNotification('All fields are required!', 'warning') break else if self.registerGuis[2].text == self.registerGuis[3].text then if isValidMail(self.registerGuis[4].text) then outputChatBox(self.registerGuis[1].text) triggerServerEvent("registeraccount", localPlayer, localPlayer, self.registerGuis[1].text, self.registerGuis[2].text, self.registerGuis[4].text) break else exports.notification:addNotification('Wrong email!', 'warning') break end else exports.notification:addNotification('The passwords do not match!', 'warning') break end end end end end The registeraccount server side: function registerAcc(player, username, password, email) outputChatBox("register clicked") local password = base64Encode(password) local registerQuery = dbPoll(dbQuery(sql, "SELECT * FROM account"), -1) for _, row in ipairs(registerQuery) do if row["username"] == username then exports.notification:addNotification(player, 'This username is already taken!', 'warning') return end if row["serial"] == getPlayerSerial(player) then exports.notification:addNotification(player, 'You already have an account!', 'warning') return end end local registerInsert = dbQuery(sql, "INSERT INTO account SET username = ?, password = ?, email = ?, serial = ?", username, password, email, getPlayerSerial(player)) local result, num, insertID = dbPoll(registerInsert, -1) if insertID then exports.notification:addNotification(player, 'Register success!', 'info') end end addEvent("registeraccount", true) addEventHandler("registeraccount", root, registerAcc) The problem is because it's clicking on the button twice then always getting a warning notification when I register "You already have an account" Link to comment
_SAXI_ Posted July 5, 2023 Share Posted July 5, 2023 Your error is not using the "state" parameter. Try this: function Panel:loginClick(button, state) if state == "down" then if self.show and self.hovered == 'buttons' and self.selectedbutton == 1 then for key, value in pairs(self.loginGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.ml_notification:addNotification('All fields are required!', 'warning') destroyAnimation() break else triggerServerEvent('loginaccount', localPlayer, localPlayer, self.loginGuis[1].text, self.loginGuis[2].text) destroyAnimation() end end elseif self.show and self.hovered == 'buttons' and self.selectedbutton == 2 then for key, value in ipairs(self.registerGuis) do if value.text == '' then if clickTick + (5000) > getTickCount() then return end exports.notification:addNotification('All fields are required!', 'warning') break else if self.registerGuis[2].text == self.registerGuis[3].text then if isValidMail(self.registerGuis[4].text) then outputChatBox(self.registerGuis[1].text) triggerServerEvent("registeraccount", localPlayer, localPlayer, self.registerGuis[1].text, self.registerGuis[2].text, self.registerGuis[4].text) break else exports.notification:addNotification('Wrong email!', 'warning') break end else exports.notification:addNotification('The passwords do not match!', 'warning') break end end end end end end Link to comment
thund3rbird23 Posted July 5, 2023 Author Share Posted July 5, 2023 Yes, I realized it a few hours later after I posted it but thank you 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