mint3d Posted May 5, 2016 Share Posted May 5, 2016 I have a script, that someone gave of me of the basicRP gamemode, although it had been modified, he had gave me it to learn scripting and to develop it, I was confused when I checked his login screen, I realised a code which I had never encountered, could anyone tell me how this code works? local result, numrows, errmsg = dbPoll(queryCreds, 0) if result and numrows == 1 then result = result[1] local rPass = string.lower(md5(string.lower(md5(password)) .. result.salt)) Link to comment
Saml1er Posted May 5, 2016 Share Posted May 5, 2016 dbPoll - It is used for querying. Use -1 which will wait till result is ready and then return. Currently there is 0 which will instantly return and may sometimes return nil. So use -1. Line 2 checks if result is success and checks only if 1 row is returned. Line 4 result variable is set to first row or in other words, result variable has the first row data. Line 6 string.lower will make convert the string to lower case letters. For md5, check https://wiki.multitheftauto.com/wiki/Md5 Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 Saml1er, can I add you on skype or speak with you in private chat? Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 How would this be stored in the database? My friend used a php website for a UCP to register, I have created a IG register button, although I have no idea how to store it regarding the md5 salt and password.. Link to comment
Saml1er Posted May 5, 2016 Share Posted May 5, 2016 How would this be stored in the database? My friend used a php website for a UCP to register, I have created a IG register button, although I have no idea how to store it regarding the md5 salt and password.. You need to use dbQuery first. Please check the second post: https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203 My skype is: majid.sheikh95 Keep in mind, I'll only reply when I'm free. Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 I have a piece of code which is used to fetch the Login Results... connection = dbConnect("mysql", "dbname=" .. get("@MYSQL_DB") .. ";host=" .. get("#MYSQL_HOST"), get("#MYSQL_USER"), get("#MYSQL_PASS")) dbQuery(loginCallback1, { player, username, password, rememberMe }, connection, "SELECT userid, username, usergroupid, password, salt FROM user WHERE username = ?", username) Link to comment
Saml1er Posted May 5, 2016 Share Posted May 5, 2016 I have a piece of code which is used to fetch the Login Results... connection = dbConnect("mysql", "dbname=" .. get("@MYSQL_DB") .. ";host=" .. get("#MYSQL_HOST"), get("#MYSQL_USER"), get("#MYSQL_PASS")) dbQuery(loginCallback1, { player, username, password, rememberMe }, connection, "SELECT userid, username, usergroupid, password, salt FROM user WHERE username = ?", username) You can use UPDATE. Check w3school sql tutorial. Google it. You will find everything you need to know. Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 Can you give me some function I'll need to be able to add it into a DB as I'm really unsure Link to comment
Saml1er Posted May 5, 2016 Share Posted May 5, 2016 Can you give me some function I'll need to be able to add it into a DB as I'm really unsure What do you want to save in DB? tell me exactly what you're trying to achieve. Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 I want add a new record in the column for when I register My database is something like; dbQuery( connection, "INSERT INTO user (userid, username, usergroupid, password, salt, online, admin) VALUES(?, ?, 1, ?, ?, 1, 0)") When I click register it sends this to my server side... function registerClick(btn, state) local username = tostring(guiGetText(loginGUI.username)) local password = tostring(guiGetText(loginGUI.password)) if btn == "left" and state == "up" then triggerServerEvent("tryRegister", username, password) end end Link to comment
mint3d Posted May 5, 2016 Author Share Posted May 5, 2016 I sent you a private message. 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