Jump to content

[ Help ] toJSON + setAccountData


Doffy

Recommended Posts

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
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
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

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
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
  • Moderators
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 by IIYAMA
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...