Charlie_Jefferson Posted October 22, 2011 Share Posted October 22, 2011 (edited) Hai, I'm tryina' make a login system. No idea how to say that if username and password are in a .xml file, then login. This is the code cut into a piece. I've got the usern and passw defined and they are added when registered. Or should be. Didn't test it yet. function login( thePlayer, command, username, password ) load = xmlLoadFile ( "accl.xml" ) child = xmlFindChild ( group, "user", 0 ) if (usern and passw == load) then menu else label[2] = guiCreateLabel(insertcoordshere, "Please type a correct username/password!") setTimer(label[2], 5000, 3) end end And this is the whole code: showCursor(true) fadeCamera(true) setCameraMatrix(insertCityHall/PDcoordshere) user = guiCreateEdit(insertcoordshere) pass = guiCreateEdit(insertcoordshere) register = guiCreateButton(insertcoordshere) login = guiCreateButton(insertcoordshere) addEventHandler( "onClientGUIClick", register, register ) addEventHandler( "onClientGUIClick", login, login ) function register() local usern = guiGetText( user ) local passw = guiGetText( pass ) if (username>3 or password>3) then label[1] = guiCreateLalbel(insertcoordshere, "Please write a longer username/password!") setTimer(label[1], 5000, 3) else xmlLoad = xmlLoadFile ( "accl.xml" ) end if xmlRootTree then xmlNodeSetValue ( "user", usern, passw ) else return end end function login( thePlayer, command, username, password ) load = xmlLoadFile ( "accl.xml" ) child = xmlFindChild ( group, "user", 0 ) if (usern and passw == load) then menu else label[2] = guiCreateLabel(insertcoordshere,"Please type a correct username/password!") setTimer(label[2], 5000, 3) end end Note: where it's written "insertcoordshere" or anything to do with that, it means I will write the coordinates later. Edited October 22, 2011 by Guest Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 What ?? why are you loading acl.xml ? Link to comment
Charlie_Jefferson Posted October 22, 2011 Author Share Posted October 22, 2011 So it can get the username and password from it and check if they exist. Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 Well thats not needed acl.xml is acces control list wich means eaxample supermoderator, admin , etc Link to comment
Charlie_Jefferson Posted October 22, 2011 Author Share Posted October 22, 2011 Then where do I store them and how do I get them? >.> Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 You want to get the account info so you can read it ? Link to comment
Charlie_Jefferson Posted October 22, 2011 Author Share Posted October 22, 2011 I want to store them, with the register button and check if they are true and if they are, then login the player with the login button. Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 kimmis, you didn't get what he's trying to do. If I'm right, he's trying to save and load the account details from a CLIENT SIDE XML fiel called "acl.xml", but that doesn't mean is the access control list. Link to comment
Charlie_Jefferson Posted October 22, 2011 Author Share Posted October 22, 2011 Well, yeah. Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 Oh ok ... EDIT: Why do you need that ? Link to comment
Charlie_Jefferson Posted October 22, 2011 Author Share Posted October 22, 2011 ... I need the accl.xml so I can store usernames and passwords and so that the player can login. Are you making fun of me? Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 No, I guess he's just trying to increase the post count, or he's just stupid. Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 What im not trying to increase my stupid post count ... and im not making fun of you but for a normal login panel you dont need a xml file to store them ... Link to comment
Castillo Posted October 22, 2011 Share Posted October 22, 2011 He's trying to save the USERNAME and PASSWORD so when he joins again, he doesn't have to type it AGAIN AND AGAIN. What you say makes no sense. Link to comment
mjau Posted October 22, 2011 Share Posted October 22, 2011 Thanks castillo now i understand XDD i see what i said made no sense now sorry for it... But idk what the probelm is here im a bit to tired now since i dont understand a shit Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 Actually this is my basic login GUI. What you do is write your username and password on the GUI edits, click register, which saves your username and account into my account list(accl.xml) and then, you login. I'm trying to make it search the username and password, when you input something into the edits and click login and if the username and password exist, then it logs you in. THAT'S ALL. And I'm stuck on ONE BIT of problem. How do I make the script search the accl.xml. If you can help me with that, you are so helpful and you will be the most epic person in the world. Sorry for exaggerating, I just want my script to work ;P. Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 Also, for some reason, the camera matrix setting and the fade camera and the show cursor don't work. I did add source, true and the coords needed to them, but they just won't work. Link to comment
mjau Posted October 23, 2011 Share Posted October 23, 2011 Ah ok well i never worked with more advanced xml than one node so i think u should wait for someone else than me to answer Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 Okay... Link to comment
Castillo Posted October 23, 2011 Share Posted October 23, 2011 function saveLoginToXML(username, password) xmlFile = xmlLoadFile ("userdata.xml") if not xmlFile then xmlFile = xmlCreateFile("userdata.xml", "login") end local usernameNode = xmlFindChild (xmlFile, "username", 0) local passwordNode = xmlFindChild (xmlFile, "password", 0) local success = xmlNodeSetValue (usernameNode, tostring(username)) local success2 = xmlNodeSetValue (passwordNode, tostring(password)) if success and success2 then xmlSaveFile(xmlFile) end xmlUnloadFile (xmlFile) end function loadLoginFromXML() xmlFile = xmlLoadFile ("userdata.xml") if not xmlFile then xmlFile = xmlCreateFile("userdata.xml", "login") end local usernameNode = xmlFindChild (xmlFile, "username", 0) local passwordNode = xmlFindChild (xmlFile, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile (xmlFile) end Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 Right. Now... How do I make it so that the player logins, when he clicks on a login button which I'll create? The loadlogin thing should be the login function. And if the username and password are entered correctly, the player should login into his account and some other GUI, which I'll make later will be shown and he can select and do stuff. No point in going further. Just help. Link to comment
Castillo Posted October 23, 2011 Share Posted October 23, 2011 These two functions should be used like this: On login button clicked -> saveLoginToXML(username, password) When player joins(onClientResourceStart) -> loadLoginFromXML() which returns two values (username and password). Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 Then how does the register button help? I think that the register button should be saveToXML and login would be the loadFromXML. Link to comment
Castillo Posted October 23, 2011 Share Posted October 23, 2011 Now I'm lost, what are you trying to achieve? I don't understand. Link to comment
Charlie_Jefferson Posted October 23, 2011 Author Share Posted October 23, 2011 I'll say it clearly: this IS a login system made by me. I'm trying to make the "Register" and "Login" buttons work. I made a GUI which has two edit boxes: Username and Password. You write your username and password in those two boxes and press register. The register button send the username and password to the .xml file, which stores them. I need to make it so that if the username and password are in the .xml file, you can login. That's ALL. 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