undefined Posted January 21, 2015 Posted January 21, 2015 Hi guys. I'm new on SQL. I am begin to write save system. But i have a problem local money, skin, armor, stats = 500, 286, 100, {{24,569}, {69,0},{70,0},{71,0},{72,0},{73,0},{74,0},{75,0},{76,0},{77,0},{78,0},{79,0}} executeSQLCreateTable("playersData", "account_name TEXT, money INTEGER, skin INTEGER, armor INTEGER, stats INTEGER") executeSQLQuery("INSERT INTO playersData(account_name,money,skin,armor,stats) VALUES(?,?,?,?,?)", tostring(account_name),money,skin,armor,stats) I'm do this but when I use this, outputChatBox(executeSQLQuery("SELECT stats FROM playersData WHERE account_name=?", tostring(account_name))[1].stats) this saying 100. But it must be table. Why number -,- Help me
Gallardo9944 Posted January 21, 2015 Posted January 21, 2015 You created a table with stats as integer. Even if you try to save a table, it will still be integer. You can use string as table type and save tables with toJSON - read further with fromJSON.
undefined Posted January 21, 2015 Author Posted January 21, 2015 (edited) You created a table with stats as integer. Even if you try to save a table, it will still be integer. You can use string as table type and save tables with toJSON - read further with fromJSON. I did your said. But it's not work. My all code. Code Removed Server Said: [ [ [ 24, 569 ], [ 69, 0 ], [ 70, 0 ], [ 71, 0 ], [ 72, 0 ], [ 73, 0 ], [ 74, 0 ], [ 75, 0 ], [ 76, 0 ], [ 77, 0 ], [ 78, 0 ], [ 79, 0 ] ] ] It's a string. But I need table. Edited January 21, 2015 by Guest
TAPL Posted January 21, 2015 Posted January 21, 2015 You didn't use fromJSON to convert the string back to table.
undefined Posted January 21, 2015 Author Posted January 21, 2015 OK. I removed this code. Now, outputChatBox(tostring(#getAccountStats(account))) -- said - 1 outputChatBox(tostring(#getAccountStats(account)[1])) -- said - 0 outputChatBox(tostring(getAccountStats(account)[1])) -- said - table: 05764310 outputChatBox(tostring(getAccountStats(account)[1].stats)) -- said - 100
TAPL Posted January 21, 2015 Posted January 21, 2015 You didn't understand. toJSON -- convert table to string. fromJSON -- convert string to table again. toJSON -- > string fromJSON -- > table
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