tommymaster Posted August 18, 2018 Posted August 18, 2018 Hi, is there a function, that loads the element data the player had, before quit? Or how can i save lua tables without using databases?
Discord Moderators Pirulax Posted August 18, 2018 Discord Moderators Posted August 18, 2018 (edited) If the resource doesn't get restarted then simply store the result from getAllElementData And when the player rejoins just reset his/her element data's from the table you saved. Edited August 18, 2018 by Pirulax 1
tommymaster Posted August 18, 2018 Author Posted August 18, 2018 (edited) i have to restart it sometimes, if i add a feature, or fix a bug Edited August 18, 2018 by tommymaster
Discord Moderators Pirulax Posted August 18, 2018 Discord Moderators Posted August 18, 2018 the file functions+JSON 1
tommymaster Posted August 18, 2018 Author Posted August 18, 2018 is there a way i can save a lua table in mysql?
keymetaphore Posted August 18, 2018 Posted August 18, 2018 21 minutes ago, tommymaster said: is there a way i can save a lua table in mysql? You can. toJSON and fromJSON will do the trick. 1
tommymaster Posted August 18, 2018 Author Posted August 18, 2018 how? could you please give me an example?
keymetaphore Posted August 18, 2018 Posted August 18, 2018 Sure thing. -- So, first we are going to create a table with any info. table = { } table[1] = "a" -- Tables cannot be stored to mysql, so we are converting it to JSON jsonTable = toJSON(table) -- Now it will be in the format of [ { "1": "a"} ] (something similar, writing by my head) -- This can be saved in mysql. -- When you want to use it as a lua table, use fromJSON(json string) 1
tommymaster Posted August 18, 2018 Author Posted August 18, 2018 (edited) the lua table is like this {{["item"] = 101, ["amount"] = 1}} would it work the same? Edited August 18, 2018 by tommymaster
keymetaphore Posted August 18, 2018 Posted August 18, 2018 So just use it like in my example, you supply a table to the toJSON(). 1
keymetaphore Posted August 18, 2018 Posted August 18, 2018 Supply the string to the query. https://dev.mysql.com/doc/ https://wiki.multitheftauto.com/wiki/DbConnect https://wiki.multitheftauto.com/wiki/DbQuery 1
tommymaster Posted August 18, 2018 Author Posted August 18, 2018 i already wrote my msql query resource, but what type should the column in the mysql table be?
Discord Moderators Pirulax Posted August 19, 2018 Discord Moderators Posted August 19, 2018 'text' should do the trick. 1
tommymaster Posted August 19, 2018 Author Posted August 19, 2018 thank you guys! you really helped a lot! you are all awesome!!!!!! 1 1
Discord Moderators Pirulax Posted August 19, 2018 Discord Moderators Posted August 19, 2018 Thanks for those reps m8 1
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