BenceDev Posted December 15, 2022 Share Posted December 15, 2022 Hi everyone! I have a problem, so my problem is i want to get a number from table (example: i save player skin id to database when he register it [it works for me], and after he logged in set player skin to his saved id), but i dont know how to do it. This is from my server sided script when he log in: addEvent("loginRequest", true) function loginRequest(player, username, password) local check = exports.fs_sql:_QuerySingle("select * from users where username = ? ", username) if check then local checkPass = check.password if (checkPass == password) then logIn(player, getAccount(username), tostring(password)) triggerClientEvent(player, "showHide", getRootElement()) local skinID = exports.fs_sql:_QuerySingle("select * from users where pSkin = ?", SkinTable) local toNumberExsSkin = tonumber(skinID) setElementModel(source, skinID) outputChatBox ( "#34bf49Successful login!", source, 255, 255, 255, true ) fadeCamera(source, true) setCameraTarget(source,source) else outputChatBox ( "#ff4c4cWrong password!", source, 255, 255, 255, true ) end end end addEventHandler("loginRequest", getRootElement(), loginRequest) and this is my debugscript 3 says: WARNING: [Core]\fs_loginSystemGui\server.lua:39: Bad argument @ 'setElementModel' [Expected number at argument 2, got nil] and this is my database: and in red square i want this number for skin id Thanks for all help! Link to comment
AaroN⍩ Posted December 15, 2022 Share Posted December 15, 2022 (edited) Test SELECT pSkin FROM users WHERE username = ? It would stay that way, I think: local skinID = exports.fs_sql:_QuerySingle("SELECT pSkin FROM users WHERE username = ?", username) Edited December 15, 2022 by AaroN⍩ - Link to comment
BenceDev Posted December 15, 2022 Author Share Posted December 15, 2022 34 minutes ago, AaroN⍩ said: Test SELECT pSkin FROM users WHERE username = ? It would stay that way, I think: local skinID = exports.fs_sql:_QuerySingle("SELECT pSkin FROM users WHERE username = ?", username) this is not working debugscript says: warning: bad argument @ 'setElementModel' [Expected number at argument 2, got table] Link to comment
AaroN⍩ Posted December 15, 2022 Share Posted December 15, 2022 change to: setElementModel(player, skinID) Link to comment
BenceDev Posted December 15, 2022 Author Share Posted December 15, 2022 3 minutes ago, AaroN⍩ said: change to: setElementModel(player, skinID) same error he got table Link to comment
AaroN⍩ Posted December 15, 2022 Share Posted December 15, 2022 Send me a private message so I can help you. 1 Link to comment
BenceDev Posted December 15, 2022 Author Share Posted December 15, 2022 Just now, AaroN⍩ said: Send me a private message so I can help you. okay Link to comment
alex17" Posted December 16, 2022 Share Posted December 16, 2022 (edited) local skinID = exports.fs_sql:_QuerySingle("select * from users where pSkin = ? and username = ?", SkinTable, username) or local skinID = exports.fs_sql:_QuerySingle("select * from users where username = ? and pSkin = ?", username, SkinTable) or more simple local check = exports.fs_sql:_QuerySingle("select * from users where username = ? ", username) if check then local checkPass = check.password if (checkPass == password) then local pSkin = check.pSkin ... simple Edited December 16, 2022 by alex17" 1 Link to comment
BenceDev Posted December 16, 2022 Author Share Posted December 16, 2022 12 hours ago, alex17" said: local skinID = exports.fs_sql:_QuerySingle("select * from users where pSkin = ? and username = ?", SkinTable, username) or local skinID = exports.fs_sql:_QuerySingle("select * from users where username = ? and pSkin = ?", username, SkinTable) or more simple local check = exports.fs_sql:_QuerySingle("select * from users where username = ? ", username) if check then local checkPass = check.password if (checkPass == password) then local pSkin = check.pSkin ... simple thanks and i test it now Link to comment
BenceDev Posted December 16, 2022 Author Share Posted December 16, 2022 UPDATE: It works! @AaroN⍩ and @alex17" thanks for the help! 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