Dimos7 Posted October 23, 2016 Share Posted October 23, 2016 (edited) local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSstVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow, false) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerSeverEvent("submitLogin", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor[3]) local password = guiGetText(GUIEditor[4]) if username ~= "" and password ~= "" then triggerSeverEvent("submitRegister", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerSeverEvent("submitChangepw", root, localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) function passwordHandler(thePlayer, password, rpassword) local account = getPlayerAccount(thePlayer) if account then if isGuestAccount(account) then outputChatBox("You must be logged in to change password!", thePlayer, 255, 0, 0) return end if password == rpassword then if string.len(password) >= 5 then setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePasswordWindow", root) else outputChatBox("Your new password must be at least 5 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("Your passwords aren't the same!", thePlayer, 255, 0, 0) end end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end else outputChatBox("Username or password are incorrect!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then outputChatBox("This username is already exist!", thePlayer, 255, 0, 0) else account = addAccount(username, password) outputChatBox("You succefuly registered!", thePlayer, 0, 255, 0) if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) When i press button for login nothing happend event if is empty same with register Edited October 23, 2016 by Dimos7 Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Line 75 + 99 You are missing 'r' in the ' triggerSeverEvent' so should be 'triggerServerEvent'. Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 thanks but still not working Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Post the errors in the debug use /debugscript 3 to show errors warnings is there anything in there? Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 (edited) nothing in debugscript 3 not working at all the buttons of loginpanel not even the error given if are empty the edits local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor[3]) local password = guiGetText(GUIEditor[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerServerEvent("submitChangepw", root, localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) Edited October 23, 2016 by Dimos7 Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Try this : Client : local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSstVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow, false) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor[3]) local password = guiGetText(GUIEditor[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerServerEvent("submitChangepw", localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) Server : function passwordHandler(password, rpassword) local account = getPlayerAccount(source) if account then if isGuestAccount(account) then outputChatBox("You must be logged in to change password!", source, 255, 0, 0) return end if password == rpassword then if string.len(password) >= 5 then setAccountPassword(account, password) triggerClientEvent(source, "hidePasswordWindow",source ) else outputChatBox("Your new password must be at least 5 characters long!", source, 255, 0, 0) end else outputChatBox("Your passwords aren't the same!", source, 255, 0, 0) end end end function loginHandler(username, password) local account = getAccount(username, password) if account ~= false then if (logIn(source, account, password) == true) then outputChatBox("You succefuly logged in!", source, 0, 255, 0) triggerClientEvent(source, "hideLoginWindow", source) else outputChatBox("An error please report it to forum!", source, 255, 0, 0) end else outputChatBox("Username or password are incorrect!", source, 255, 0, 0) end end function registerHandler(username, password) local account = getAccount(username, password) if account ~= false then outputChatBox("This username is already exist!", source, 255, 0, 0) else account = addAccount(username, password) outputChatBox("You succefuly registered!", source, 0, 255, 0) if (logIn(source, account, password) == true) then outputChatBox("You succefuly logged in!", source, 0, 255, 0) triggerClientEvent(source, "hideLoginWindow", source) else outputChatBox("An error please report it to forum!", source, 255, 0, 0) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) Please make sure to add this resource to 'Admin' Group to add accounts. Ex. resource.MyResourceName Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 (edited) already did on admin <group name="Admin"> <acl name="Moderator"></acl> <acl name="SuperModerator"></acl> <acl name="Admin"></acl> <acl name="RPC"></acl> <object name="resource.admin"></object> <object name="resource.webadmin"></object> <object name="resource.loginpanel"></object> local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow, false) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerServerEvent("submitChangepw", localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) function passwordHandler(thePlayer, password, rpassword) local account = getPlayerAccount(thePlayer) if account then if isGuestAccount(account) then outputChatBox("You must be logged in to change password!", thePlayer, 255, 0, 0) return end if password == rpassword then if string.len(password) >= 5 then setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePasswordWindow", root) else outputChatBox("Your new password must be at least 5 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("Your passwords aren't the same!", thePlayer, 255, 0, 0) end end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end else outputChatBox("Username or password are incorrect!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then outputChatBox("This username is already exist!", thePlayer, 255, 0, 0) else account = addAccount(username, password) outputChatBox("You succefuly registered!", thePlayer, 0, 255, 0) if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) nothing the server function is fine the client side is the problem Edited October 23, 2016 by Dimos7 Link to comment
3aGl3 Posted October 23, 2016 Share Posted October 23, 2016 Quote from the Wiki: Quote state: the state of the mouse button, will be down if the mouse button was pushed, or up if it was released. Please note currently only the up state is supported. Yet you are using state == "down" Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Try it this way : local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow, false) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) -- if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) --end end end function clientSubmitRegister(button, state) -- if button == "left" and state == "down" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) --end end end function clientSubmitChangepw(button, state) --if button == "left" and state == "down" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerServerEvent("submitChangepw", localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) --end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 ahah now apear error at line 31 server side execpt elemnt agrument 2 get srting Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Copy my server side i post above in this topic your server side has a lot of mistakes. Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 Yes because thePlayer is not a localPlayer it's edit value . Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 (edited) function passwordHandler(thePlayer, password, rpassword) local account = getPlayerAccount(thePlayer) if account then if isGuestAccount(account) then outputChatBox("You must be logged in to change password!", thePlayer, 255, 0, 0) return end if password == rpassword then if string.len(password) >= 5 then setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePasswordWindow", root) else outputChatBox("Your new password must be at least 5 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("Your passwords aren't the same!", thePlayer, 255, 0, 0) end end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end else outputChatBox("Username or password are incorrect!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, password) local account = getAccount(username, password) if account ~= false then outputChatBox("This username is already exist!", thePlayer, 255, 0, 0) else account = addAccount(username, password) outputChatBox("You succefuly registered!", thePlayer, 0, 255, 0) if (logIn(thePlayer, account, password) == true) then outputChatBox("You succefuly logged in!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("An error please report it to forum!", thePlayer, 255, 0, 0) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) local GUIEditor = { window = { }, label = { }, edit = { }, button= { } } function createPasswordWindow() GUIEditor.window[1] = guiCreateWindow(693, 268, 303, 307, "Change Password", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(7, 75, 289, 24, " New Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[1], "top") guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiSetFont(GUIEditor.label[1], "clear-normal") GUIEditor.edit[1] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2] = guiCreateLabel(7, 140, 289, 24, " Repeat Password:", false, GUIEditor.window[1]) guiLabelSetVerticalAlign(GUIEditor.label[2], "top") guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiSetFont(GUIEditor.label[2], "clear-normal") GUIEditor.edit[2] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(9, 254, 143, 53, "Change", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(153, 254, 143, 53, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], hidePasswordWindow, false) end function createLoginWindow() GUIEditor.window[2] = guiCreateWindow(693, 268, 303, 307, "login Panel", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(7, 75, 289, 24, " Username:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[3], "top") guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiSetFont(GUIEditor.label[3], "clear-normal") GUIEditor.edit[3] = guiCreateEdit(9, 100, 285, 25, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(7, 140, 289, 24, " Password:", false, GUIEditor.window[2]) guiLabelSetVerticalAlign(GUIEditor.label[4], "top") guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiSetFont(GUIEditor.label[4], "clear-normal") GUIEditor.edit[4] = guiCreateEdit(9, 168, 285, 25, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) GUIEditor.button[3] = guiCreateButton(9, 254, 143, 53, "Login", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(153, 254, 143, 53, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occupied.") end showCursor(true) guiSetInputEnabled(true) end function changepw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[3]) local password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", root, localPlayer, username, password) else outputChatBox("Enter username and password.", 255, 0, 0) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "up" then local password = guiGetText(GUIEditor.edit[1]) local rpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and rpassword ~= "" then triggerServerEvent("submitChangepw", root, localPlayer, password, rpassword) else outputChatBox("Enter new password and repeat it", 255, 0, 0) end end end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", changepw) every time i press register is auto login the account Edited October 23, 2016 by Dimos7 Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 For sure because line 42 after register you login the player with the new account. Link to comment
Dimos7 Posted October 23, 2016 Author Share Posted October 23, 2016 yes i put that for when press the login not the register button i have make this way again and worked perfectly Link to comment
iPrestege Posted October 23, 2016 Share Posted October 23, 2016 So you want only register and the player manual login? Remove the login function. @Dimos7 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