Doffy Posted January 25, 2020 Share Posted January 25, 2020 hello, how i can save table in account data with json and add rows in table and make it save my try it's not working : --server addEventHandler("onResourceStart",resourceRoot, function( ) for i,v in ipairs ( getElementsByType("player") ) do local dd = getAccountData(getPlayerAccount(v),"SkinsT") if dd == false then setAccoountData(getPlayerAccount(v),"SkinsT", toJSON({"TT", "DF"})) else local s = fromJSON(dd) table.insert(dd, s) setAccoountData(getPlayerAccount(v),"SkinsT", toJSON(s)) end end end ) addCommandHandler("df", function( plr ) local dd = getAccountData(getPlayerAccount(plr),"SkinsT") local s = fromJSON(dd) triggerClientEvent(plr, "getSkins", plr, s ) end ) --client addEvent("getSkins",true) addEventHandler("getSkins",root, function( s ) guiGridListClear(myd) for i,v in ipairs( s ) do local row = guiGridListAddRow(myd) guiGridListSetItemText(myd,row, 1, v,false,false) end end ) Link to comment
Moderators IIYAMA Posted January 25, 2020 Moderators Share Posted January 25, 2020 58 minutes ago, !#DesTroyeR_,) said: setAccoountData Shouldn't you receive this error? Because it looks like there is a typo. input:*: attempt to call a nil value (global 'setAccoountData') Link to comment
Doffy Posted January 26, 2020 Author Share Posted January 26, 2020 5 hours ago, IIYAMA said: Shouldn't you receive this error? Because it looks like there is a typo. input:*: attempt to call a nil value (global 'setAccoountData') yep it's in debug now 1 Link to comment
Moderators IIYAMA Posted January 26, 2020 Moderators Share Posted January 26, 2020 I am not sure what the problem is. But you can assign data to a grid item. https://wiki.multitheftauto.com/wiki/GuiGridListSetItemData Including tables. Link to comment
Doffy Posted January 26, 2020 Author Share Posted January 26, 2020 3 minutes ago, IIYAMA said: I am not sure what the problem is. But you can assign data to a grid item. https://wiki.multitheftauto.com/wiki/GuiGridListSetItemData Including tables. i wanna to save data in a account and show it in the grid list Link to comment
Moderators IIYAMA Posted January 26, 2020 Moderators Share Posted January 26, 2020 4 minutes ago, !#DesTroyeR_,) said: i wanna to save data in a account and show it in the grid list And which part of the code doesn't work? The saving part? The loading part? The sending part? The grid display part? You know better than me that you have to debug each individual part in order to figure out were the issue is located. Link to comment
Doffy Posted January 26, 2020 Author Share Posted January 26, 2020 Just now, IIYAMA said: And which part of the code doesn't work? The saving part? The loading part? The sending part? The grid display part? You know better than me that you have to debug each individual part in order to figure out were the issue is located. Just now, IIYAMA said: The saving part? Just now, IIYAMA said: The grid display part? this two Link to comment
Moderators IIYAMA Posted January 26, 2020 Moderators Share Posted January 26, 2020 You are inserting the JSON string inside of a table, which you convert back to a JSON string. Which ends up in ??? local s = fromJSON(dd) table.insert(dd, s) setAccoountData(getPlayerAccount(v),"SkinsT", toJSON(s)) Link to comment
Doffy Posted January 26, 2020 Author Share Posted January 26, 2020 14 minutes ago, IIYAMA said: You are inserting the JSON string inside of a table, which you convert back to a JSON string. Which ends up in ??? local s = fromJSON(dd) table.insert(dd, s) setAccoountData(getPlayerAccount(v),"SkinsT", toJSON(s)) I can't fully understand JSON Link to comment
N3xT Posted January 26, 2020 Share Posted January 26, 2020 toJSON does convert a given table into a string, fromJSON is the vice versa. Link to comment
Moderators IIYAMA Posted January 26, 2020 Moderators Share Posted January 26, 2020 (edited) 39 minutes ago, !#DesTroyeR_,) said: up I will lock your topic if you keep making useless bumps. If nobody answers your question or the answers are not satisfying, then you didn't ask the right question as simple as that. Edited January 26, 2020 by IIYAMA 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