Hi guys.
Im trying to make an inventory system, but i cant save the table that contains the items. So the code is:
local inv = {
[1] = {{1,false,false,100},{2,false,false,100},{3,false,false,90},{4,false,false,100},{5,false,false,95},{6,false,1000,99},{7,false,1001,100},{8,false,1002,100},{9,false,1003,100},{10,false,1004,30},{11,false,1005,45},{12,false,1006,55},{13,false,1007,60},{14,false,1008,65},{15,false,1009,70},{16,false,1010,75},{17,false,1011,80},{18,false,1012,90},{19,false,1013,99},{13,false,1014,100},{15,false,1015,100}},
[2] = {{1,20,false,false},{2,30,false,false},{3,30,false,false},{4,110,false,false},{5,100,false,false},{6,2,false,false},{7,1,false,false},{8,1,false,false},{9,1,false,false}},
[3] = {},
[4] = {},
[5] = {},
[6] = {},
[7] = {},
[8] = {},
}
dbExec(con,"update characters set inventory=? where id=?",toJSON(inv),1)
local qh = dbQuery(con,"select * from characters where id=?",1)
local invent = dbPoll(qh,100)
invent = fromJSON(invent[1]["inventory"])
outputChatBox(#invent)
setElementData(getElementsByType("player")[1],"inventory",invent)
and the invent variable is not a table. If i save only the first 2 table in the "inv" table then it works so its probably something with the empty tables.
Probably i dont know something about mysql or JSON, i would be very glad if someone could help me with this.
Thanks