Overkillz Posted March 20, 2014 Share Posted March 20, 2014 Hey everyone, I tried to fix the problem with login, but I couldn't I put my ID and Password correctly but doesnt work, always is showing me "Wrong login or/and password" I hope you can help me: -Client: sX,sY = guiGetScreenSize() scale = (sX/1920) local loginData = { checkbox = false, login = { pos = {sX*0.35,sY*0.35}, size = {sX*0.35,sY*0.3}, edits = {createElement("dxEdit"),createElement("dxEdit")}, buttons = {createElement("dxButton"),createElement("dxButton"),createElement("dxButton")}, alpha = 1, }, register = { pos = {-sX*0.35,sY*0.35}, size = {sX*0.35,sY*0.3}, edits = {createElement("dxEdit"),createElement("dxEdit"),createElement("dxEdit")}, buttons = {createElement("dxButton"),createElement("dxButton"),createElement("dxButton")}, alpha = 1, }, currentTab = 1, tick = getTickCount(), } function loadRenderData() showChat(true) callServerFunction("checkPlayerLogin",localPlayer) dxLibCreateEdit(loginData.login.edits[1],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.1,sX*0.3,sY*0.04,"Your login","person",20,20,20,loginData.login.alpha*255,true) dxLibCreateEdit(loginData.login.edits[2],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.15,sX*0.3,sY*0.04,"Your password","password",20,20,20,loginData.login.alpha*255,true,true) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loadRenderData) function unloadRenderData() removeEventHandler("onClientRender",getRootElement(),renderLoginPanelInterface) setElementData(localPlayer,"loginEnabled",false) end addEventHandler("onClientResourceStop",getResourceRootElement(getThisResource()),unloadRenderData) function displayLoginPanel() showCursor(true) showChat(false) loginData.currentTab = 1 addEventHandler("onClientRender",getRootElement(),renderLoginPanelInterface) readLoginXML() end function hideLoginInterface() loginData.tick = getTickCount() loginData.currentTab = false showCursor(false) showChat(true) end function renderLoginPanelInterface() setElementData(localPlayer,"loginEnabled",true) if loginData.currentTab == 1 then local tick = getTickCount() - loginData.tick local progress = tick/1000 if progress>=1 then progress = 1 end loginData.login.pos[1] = interpolateBetween(loginData.login.pos[1],0,0,sX*0.35,0,0,progress,"Linear") loginData.register.pos[1] = interpolateBetween(loginData.register.pos[1],0,0,-sX*0.35,0,0,progress,"Linear") loginData.login.alpha = 1 elseif loginData.currentTab == 2 then local tick = getTickCount() - loginData.tick local progress = tick/1000 if progress>=1 then progress = 1 end loginData.login.pos[1] = interpolateBetween(loginData.login.pos[1],0,0,sX,0,0,progress,"Linear") loginData.register.pos[1] = interpolateBetween(loginData.register.pos[1],0,0,sX*0.35,0,0,progress,"Linear") loginData.login.alpha = 1 else local tick = getTickCount() - loginData.tick local progress = tick/1000 if progress>=1 then progress = 1 unloadRenderData() end loginData.login.alpha = interpolateBetween(1,0,0,0,0,0,progress,"Linear") end dxDrawRectangle(loginData.login.pos[1],loginData.login.pos[2],loginData.login.size[1],loginData.login.size[2],tocolor(30,30,30,100*loginData.login.alpha),true) dxDrawRectangle(loginData.login.pos[1],loginData.login.pos[2],loginData.login.size[1],sY*0.08,tocolor(126,126,126,100*loginData.login.alpha),true) setElementData(resourceRoot,'checkboxSelected',false,false) if loginData.checkbox then if isCursorHover(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,sX*0.14,33*scale) then setElementData(resourceRoot,'checkboxSelected',true,false) dxDrawImageSection(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,50*scale,33*scale,100,0,100,66,"data/img/dxInterface/checkbox.png",0,0,0,tocolor(255,255,255,150*loginData.login.alpha),true) else dxDrawImageSection(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,50*scale,33*scale,100,0,100,66,"data/img/dxInterface/checkbox.png",0,0,0,tocolor(255,255,255,255*loginData.login.alpha),true) end else if isCursorHover(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,sX*0.14,33*scale) then setElementData(resourceRoot,'checkboxSelected',true,false) dxDrawImageSection(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,50*scale,33*scale,0,0,100,66,"data/img/dxInterface/checkbox.png",0,0,0,tocolor(255,255,255,150*loginData.login.alpha),true) else dxDrawImageSection(loginData.login.pos[1]+sX*0.2,loginData.login.pos[2]+sY*0.2,50*scale,33*scale,0,0,100,66,"data/img/dxInterface/checkbox.png",0,0,0,tocolor(255,255,255,255*loginData.login.alpha),true) end end dxDrawText("Remember password?",loginData.login.pos[1]+sX*0.225,loginData.login.pos[2]+sY*0.2,loginData.login.pos[1]+sX*0.33,loginData.login.pos[2]+sY*0.2+33*scale,tocolor(220,220,220,255*loginData.login.alpha),s(0.1),menu.font,"left","center",true,false,true) dxLibCreateEdit(loginData.login.edits[1],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.1,sX*0.3,sY*0.04,"Your login","person",20,20,20,loginData.login.alpha*255,true) dxLibCreateEdit(loginData.login.edits[2],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.15,sX*0.3,sY*0.04,"Your password","password",20,20,20,loginData.login.alpha*255,true,true) dxDrawImage(loginData.login.pos[1],loginData.login.pos[2]+sY*0.08,loginData.login.size[1],sY*0.01,"data/img/shadow_r.png",0,0,0,tocolor(255,255,255,255*loginData.login.alpha),true) dxDrawImage(loginData.login.pos[1],loginData.login.pos[2],loginData.login.size[1]/1.5,sY*0.08,"data/img/logo.png",0,0,0,tocolor(255,255,255,255*loginData.login.alpha),true) dxDrawText("Login",loginData.login.pos[1],loginData.login.pos[2],loginData.login.pos[1]+loginData.login.size[1]-sX*0.01,loginData.login.pos[2]+sY*0.08,tocolor(220,220,220,255*loginData.login.alpha),s(0.2),menu.font,"right","center",true,false,true) dxLibCreateButton(loginData.login.buttons[1],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.2,sX*0.1,sY*0.03,"Join as guest!",sY/700,menu.color[1],menu.color[2],menu.color[3],220,220,220,255*loginData.login.alpha,true,false) dxLibCreateButton(loginData.login.buttons[2],loginData.login.pos[1]+sX*0.025,loginData.login.pos[2]+sY*0.24,sX*0.145,sY*0.04,"Register new account!",sY/700,menu.color[1],menu.color[2],menu.color[3],220,220,220,255*loginData.login.alpha,true,false) dxLibCreateButton(loginData.login.buttons[3],loginData.login.pos[1]+sX*0.18,loginData.login.pos[2]+sY*0.24,sX*0.145,sY*0.04,"Login now!",sY/700,menu.color[1],menu.color[2],menu.color[3],220,220,220,255*loginData.login.alpha,true,false) --- Register dxDrawRectangle(loginData.register.pos[1],loginData.register.pos[2],loginData.register.size[1],loginData.register.size[2],tocolor(30,30,30,100*loginData.login.alpha),true) dxDrawRectangle(loginData.register.pos[1],loginData.register.pos[2],loginData.register.size[1],sY*0.08,tocolor(126,126,126,100*loginData.login.alpha),true) dxLibCreateEdit(loginData.register.edits[1],loginData.register.pos[1]+sX*0.025,loginData.register.pos[2]+sY*0.1,sX*0.3,sY*0.04,"Your login","person",20,20,20,loginData.register.alpha*255,true) dxLibCreateEdit(loginData.register.edits[2],loginData.register.pos[1]+sX*0.025,loginData.register.pos[2]+sY*0.15,sX*0.3,sY*0.04,"Your password","password",20,20,20,loginData.register.alpha*255,true,true) dxLibCreateEdit(loginData.register.edits[3],loginData.register.pos[1]+sX*0.025,loginData.register.pos[2]+sY*0.2,sX*0.3,sY*0.04,"Repeat your password","password",20,20,20,loginData.register.alpha*255,true,true) dxDrawImage(loginData.register.pos[1],loginData.register.pos[2]+sY*0.08,loginData.register.size[1],sY*0.01,"data/img/shadow_r.png",0,0,0,tocolor(255,255,255,255*loginData.register.alpha),true) dxDrawImage(loginData.register.pos[1],loginData.register.pos[2],loginData.register.size[1]/1.5,sY*0.08,"data/img/logo.png",0,0,0,tocolor(255,255,255,255*loginData.register.alpha),true) dxDrawText("Register",loginData.register.pos[1],loginData.register.pos[2],loginData.register.pos[1]+loginData.register.size[1]-sX*0.01,loginData.register.pos[2]+sY*0.08,tocolor(220,220,220,255*loginData.register.alpha),s(0.2),menu.font,"right","center",true,false,true) dxLibCreateButton(loginData.register.buttons[1],loginData.register.pos[1]+sX*0.025,loginData.register.pos[2]+sY*0.25,sX*0.145,sY*0.04,"Back to login",sY/700,menu.color[1],menu.color[2],menu.color[3],220,220,220,255*loginData.register.alpha,true,false) dxLibCreateButton(loginData.register.buttons[2],loginData.register.pos[1]+sX*0.18,loginData.register.pos[2]+sY*0.25,sX*0.145,sY*0.04,"Try to register",sY/700,menu.color[1],menu.color[2],menu.color[3],220,220,220,255*loginData.register.alpha,true,false) end function onDxButtonLoginClick(dxButton) if dxButton == loginData.login.buttons[1] then hideLoginInterface() elseif dxButton == loginData.login.buttons[2] then loginData.currentTab = 2 loginData.tick = getTickCount() elseif dxButton == loginData.login.buttons[3] then tryToLogin() elseif dxButton == loginData.register.buttons[1] then loginData.currentTab = 1 loginData.tick = getTickCount() elseif dxButton == loginData.register.buttons[2] then tryToRegister() end end addEventHandler("onDxLibButtonClick",getRootElement(),onDxButtonLoginClick) function onClientClickInLoginWindow(button,state) if button == "left" and state == "down" then if getElementData(resourceRoot,'checkboxSelected') then loginData.checkbox = not loginData.checkbox end end end addEventHandler("onClientClick",getRootElement(),onClientClickInLoginWindow) function tryToLogin() local login = dxLibEditGetText(loginData.login.edits[1]) local password = dxLibEditGetText(loginData.login.edits[2]) if login ~= "" then if string.len(password)>=4 then callServerFunction("loginPlayer",localPlayer,login,password) else displayNotification("Login","ERROR: Minimal length of password is 4 chars!",30,30,30) end else displayNotification("Login","ERROR: Bad login!",30,30,30) end end function tryToRegister() local login = dxLibEditGetText(loginData.register.edits[1]) local password = dxLibEditGetText(loginData.register.edits[2]) local confirm = dxLibEditGetText(loginData.register.edits[3]) if login and password and confirm then if string.len(password)>=4 and string.len(confirm)>=4 then callServerFunction("registerPlayer",localPlayer,login,password,confirm) else displayNotification("Register","ERROR: Minimal length of password is 4 chars!",30,30,30) end else displayNotification("Register","ERROR: Full all fields!",30,30,30) end end function successfullyLogin() displayNotification("Login","You successfully logged in!",30,30,30) saveLoginXML() hideLoginInterface() end function successfullyRegister() displayNotification("Register","You successfully registered new account!",30,30,30) loginData.currentTab = 1 loginData.tick = getTickCount() end function readLoginXML() local xmlFile = xmlLoadFile('data/login.xml','login') if not xmlFile then xmlFile = xmlCreateFile('data/login.xml','login') xmlNodeSetAttribute(xmlFile,'login',"") xmlNodeSetAttribute(xmlFile,'password',"") xmlNodeSetAttribute(xmlFile,'remember','false') xmlSaveFile(xmlFile) end if xmlNodeGetAttribute(xmlFile,'remember') == "true" then dxLibEditSetText(loginData.login.edits[1],xmlNodeGetAttribute(xmlFile,'login')) dxLibEditSetText(loginData.login.edits[2],xmlNodeGetAttribute(xmlFile,'password')) loginData.checkbox = true end xmlUnloadFile(xmlFile) end function saveLoginXML() local xmlFile = xmlLoadFile('data/login.xml','login') if not xmlFile then xmlFile = xmlCreateFile('data/login.xml','login') xmlNodeSetAttribute(xmlFile,'login',"") xmlNodeSetAttribute(xmlFile,'password',"") xmlNodeSetAttribute(xmlFile,'remember','false') xmlSaveFile(xmlFile) end if loginData.checkbox then xmlNodeSetAttribute(xmlFile,'login',dxLibEditGetText(loginData.login.edits[1])) xmlNodeSetAttribute(xmlFile,'password',dxLibEditGetText(loginData.login.edits[2])) xmlNodeSetAttribute(xmlFile,'remember','true') xmlSaveFile(xmlFile) else xmlNodeSetAttribute(xmlFile,'login',dxLibEditGetText(loginData.login.edits[1])) xmlNodeSetAttribute(xmlFile,'password',dxLibEditGetText(loginData.login.edits[2])) xmlNodeSetAttribute(xmlFile,'remember','false') xmlSaveFile(xmlFile) end xmlUnloadFile(xmlFile) end - Server: function checkPlayerLogin(thePlayer) if not isPlayerLogged(thePlayer) then callClientFunction(thePlayer,"displayLoginPanel") end end function loginPlayer(thePlayer,username,password) local account = getAccount ( username, password ) if ( account ~= false ) then logIn (thePlayer, account, password) callClientFunction(thePlayer,"successfullyLogin") else displayNotification(thePlayer,"Login","Wrong login or/and password",100,30,0) end end function registerPlayer(thePlayer,username,password,passwordConfirm) if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then callClientFunction(thePlayer,"successfullyRegister") logIn(thePlayer, accountAdded, password) else displayNotification(thePlayer,"Register","Please choose a different username/password and try again",100,30,0) end else displayNotification(thePlayer,"Register","This name is already in use",100,30,0) end else displayNotification(thePlayer,"Register","Password with confirmed passowrd is not this same!",100,30,0) end end end end end Regards. Link to comment
Overkillz Posted March 20, 2014 Author Share Posted March 20, 2014 function loadRenderData() showChat(true) callServerFunction("checkPlayerLogin",localPlayer) ================================== function tryToLogin() local login = dxLibEditGetText(loginData.login.edits[1]) local password = dxLibEditGetText(loginData.login.edits[2]) if login ~= "" then if string.len(password)>=4 then callServerFunction("loginPlayer",localPlayer,login,password) else displayNotification("Login","ERROR: Minimal length of password is 4 ========================================= function loadRenderData() showChat(true) callServerFunction("checkPlayerLogin",localPlayer) ======================================== It is on Client, i put it. Regards. Link to comment
WhoAmI Posted March 20, 2014 Share Posted March 20, 2014 In loginPlayer function, before 8 line put outputChatbox (username .. password ) to check if values are triggered correctly Link to comment
Overkillz Posted March 21, 2014 Author Share Posted March 21, 2014 In loginPlayer function, before 8 line put outputChatbox (username .. password ) to check if values are triggered correctly Without the outputchatbox: - http://puu.sh/7DzBW.png With outputchatbox: - http://puu.sh/7DzCF.png Link to comment
denny199 Posted March 21, 2014 Share Posted March 21, 2014 Does the account excist? Have you added the resource to the ACL.xml? Is this your script? Link to comment
Overkillz Posted March 21, 2014 Author Share Posted March 21, 2014 Does the account excist?Have you added the resource to the ACL.xml? Is this your script? Yes, the account exist Yes, the resource has been added to the ACL Isnt my script, but i have rights to use it. Link to comment
Overkillz Posted March 22, 2014 Author Share Posted March 22, 2014 Anyone can't help me ? ;( Link to comment
JR10 Posted March 22, 2014 Share Posted March 22, 2014 If the image is correct and while the chatbox is visible nothing was output, then it might be because of the username and password being blank. The function dxLibEditGetText might be the problem. Try to check and debug if it returns correct values. Link to comment
Overkillz Posted March 22, 2014 Author Share Posted March 22, 2014 If the image is correct and while the chatbox is visible nothing was output, then it might be because of the username and password being blank. The function dxLibEditGetText might be the problem. Try to check and debug if it returns correct values. I have on dx_lib.lua this: function dxLibEditGetText(editElement) if isElement(editElement) or not getElementData(editElement,"dxEditCreated") then return tostring(getElementData(editElement,"dxEditTextCache")) else outputDebugString("dxLib: Bad element!") end end function dxLibEditSetText(editElement,stringToSet) if isElement(editElement) then setElementData(editElement,"dxEditTextCache",stringToSet,false) else outputDebugString("dxLib: Bad element!") end end function dxLibGridlistGetSelectedRowText(gridlistElement) if isElement(gridlistElement) or not getElementData(gridlistElement,"dxGridlistCreate") then if getElementData(gridlistElement,"dxGridlistSelected") and getElementData(gridlistElement,"dxGridlistSelected") ~= 0 then local data = getElementData(gridlistElement,"dxGridlistDatatable") local row = tonumber(getElementData(gridlistElement,"dxGridlistSelected")) local gridlistData = data[row] return gridlistData else return false end else outputDebugString("dxLib: Bad element!") end end function dxLibGridlistGetSelectedRowNumber(gridlistElement) if isElement(gridlistElement) or not getElementData(gridlistElement,"dxGridlistCreate") then if getElementData(gridlistElement,"dxGridlistSelected") then local row = tonumber(getElementData(gridlistElement,"dxGridlistSelected")) if row then return row else return false end else return false end else outputDebugString("dxLib: Bad element!") end end function findFontSize(dxFont,toSize) local fontSize = 0 local relativeSize = 0 local perLoop = 0.01 repeat fontSize = fontSize+perLoop relativeSize = dxGetFontHeight(fontSize,dxFont) until relativeSize>=toSize fontSize = fontSize - perLoop return fontSize end This and more, but I don't need to put all the script ... - Debuscript 3: http://puu.sh/7FAtU.png Regards 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