MrKAREEM Posted February 25, 2018 Share Posted February 25, 2018 Hello Guis I Want Help In Save Data The Original Code Save Data For The First Time Only And When Login Again It Get The Information That I Login From First Join So I Get Code That Update Data But Didont Work The Original Code executeSQLQuery("CREATE TABLE IF NOT EXISTS players_save( serial TEXT, user TEXT, pass TEXT)") function AddPlayer(serial,user,pass) executeSQLQuery("INSERT INTO players_save(serial,user,pass) VALUES(?,?,?)",serial,user,pass) end function isPlayerSave(serial) local sel = executeSQLQuery("SELECT serial FROM players_save WHERE serial=?",serial) if sel == 0 then return false else return true end end function getUserAndPass(serial) local user,pass = "","" if isPlayerSave(serial) then local sel = executeSQLQuery("SELECT * FROM players_save WHERE serial=?",serial) for i,player in ipairs(sel) do if i == 1 then user = player.user pass = player.pass end end return user,pass end return false end addEvent("onGetSave",true) addEventHandler("onGetSave",root, function () local serial = getPlayerSerial(source) if isPlayerSave(serial) then local user,pass = getUserAndPass(serial) triggerClientEvent(source,"onPutSave",source,user,pass) end end ) The Code That I Get executeSQLQuery("CREATE TABLE IF NOT EXISTS players_save( serial TEXT, user TEXT, pass TEXT)") function AddPlayer(serial,user,pass) local result = executeSQLQuery("SELECT serial,user,pass FROM players_save WHERE serial =?",serial) if ( result == 0 ) or ( not result ) then executeSQLQuery("INSERT INTO players_save(serial,user,pass) VALUES(?,?,?)",serial,user,pass) else executeSQLQuery("UPDATE players_save SET user =? , pass ? WHERE serial =?",user,pass,serial) end end function isPlayerSave(serial) local sel = executeSQLQuery("SELECT serial FROM players_save WHERE serial=?",serial) if sel == 0 then return false else return true end end function getUserAndPass(serial) local user,pass = "","" if isPlayerSave(serial) then local sel = executeSQLQuery("SELECT * FROM players_save WHERE serial=?",serial) for i,player in ipairs(sel) do if i == 1 then user = player.user pass = player.pass end end return user,pass end return false end addEvent("onGetSave",true) addEventHandler("onGetSave",root, function () local serial = getPlayerSerial(source) if isPlayerSave(serial) then local user,pass = getUserAndPass(serial) triggerClientEvent(source,"onPutSave",source,user,pass) end end ) I Wish Any One Help Me Link to comment
MrKAREEM Posted July 2, 2018 Author Share Posted July 2, 2018 There was no one help me ? Link to comment
JeViCo Posted July 4, 2018 Share Posted July 4, 2018 check it again: https://wiki.multitheftauto.com/wiki/ExecuteSQLQuery it says that function returns table this is not correct if ( result == 0 ) or ( not result ) then try to use this: if ( #result == 0 ) or ( not result ) then same problem here: function isPlayerSave(serial) local sel = executeSQLQuery("SELECT serial FROM players_save WHERE serial=?",serial) if #sel == 0 then return false else return true end end var = {} #var means that you are counting table's indexes. For example: namelist = { {"food","drink"}, {"weapons"}, {"cars"} } outputChatBox( #namelist ) you will see number 3 in chat 1 Link to comment
MrKAREEM Posted July 5, 2018 Author Share Posted July 5, 2018 22 hours ago, Juuve said: check it again: https://wiki.multitheftauto.com/wiki/ExecuteSQLQuery it says that function returns table this is not correct if ( result == 0 ) or ( not result ) then try to use this: if ( #result == 0 ) or ( not result ) then same problem here: function isPlayerSave(serial) local sel = executeSQLQuery("SELECT serial FROM players_save WHERE serial=?",serial) if #sel == 0 then return false else return true end end var = {} #var means that you are counting table's indexes. For example: namelist = { {"food","drink"}, {"weapons"}, {"cars"} } outputChatBox( #namelist ) you will see number 3 in chat Thnx Bro I Will Check it 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