Miika Posted December 28, 2016 Posted December 28, 2016 (edited) Hello again. I have problem with table.insert. I have vehicle shop that saves data to tables and tables to element data. Always when you buy new vehicle, it should add sub-table to main-table and fill sub-table with data that i want to save. I also have panel where you can control your vehicles. Instead of showing data, the gridlist shows only number 1 in first column. Part of my code: [Server] local data = getElementData(client, "wangcars.data") if not data then setElementData(client, "wangcars.data", {}) end local data = getElementData(client, "wangcars.data") local ids = #data + 1 local x, y, z = getElementPosition(wangvehicle[client]) local rx, ry, rz = getElementRotation(wangvehicle[client]) local t = {} table.insert(t, getVehicleName(wangvehicle[client])) table.insert(t, tonumber(id)) table.insert(t, tonumber(ids)) table.insert(t, tonumber(price)) table.insert(t, c1 .. ", " .. c2 .. ", " .. c3 .. ", " .. c4 .. ", " .. c5 .. ", " .. c6) table.insert(t, x .. ", " .. y .. ", " .. z .. ", " .. rx .. ", " .. ry .. ", " .. rz) table.insert(t, "indrive") table.insert(data, t) setElementData(client, "wangcars.data", data) [Client] function refreshlist() guiGridListClear(vlist) guiGridListAddColumn(vlist, "Vehicle name", 0.3) guiGridListAddColumn(vlist, "Sell price", 0.3) guiGridListAddColumn(vlist, "ID", 0.3) local table = getElementData(localPlayer, "wangcars.data") if not table then setElementData(localPlayer, "wangcars.data", {}) end for i=1, #table do local row = guiGridListAddRow(vlist) guiGridListSetItemText(vlist, row, 1, table[i][1], false, false) guiGridListSetItemText(vlist, row, 1, table[i][4], false, false) guiGridListSetItemText(vlist, row, 1, table[i][3], false, false) end end The values are tested and they're working fine. No errors in debugscript. Edited December 28, 2016 by Miika822
Snow-Man Posted December 28, 2016 Posted December 28, 2016 try this table.insert(t, {id, ids, price, ...})
MR.GRAND Posted December 28, 2016 Posted December 28, 2016 I think this table is general table for all players, So you need to make special table for everyone .
Miika Posted December 28, 2016 Author Posted December 28, 2016 39 minutes ago, Snow-Man said: try this table.insert(t, {id, ids, price, ...}) Thanks, i'll try this next time when i go to computer. 39 minutes ago, MR.GRAND said: I think this table is general table for all players, So you need to make special table for everyone . This is local table and this is just part of the function. The function is called from clientside gui.
MR.GRAND Posted December 28, 2016 Posted December 28, 2016 2 minutes ago, Miika822 said: Thanks, i'll try this next time when i go to computer. This is local table and this is just part of the function. The function is called from clientside gui. Ok try the code which wrote by @Snow-Man and good luck . 1
Miika Posted December 28, 2016 Author Posted December 28, 2016 (edited) 9 minutes ago, MR.GRAND said: Ok try the code which wrote by @Snow-Man and good luck . I will And btw I just noticed something that can be issue too. I forgot to change different column numbers so it's just replacing same text every time guiGridListSetItemText(vlist, row, 1, table[i][1], false, false) guiGridListSetItemText(vlist, row, 1, table[i][4], false, false) guiGridListSetItemText(vlist, row, 1, table[i][3], false, false) They're all 1 instead of 2 and 3 Edited December 28, 2016 by Miika822 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