HustraDev Posted August 17, 2014 Share Posted August 17, 2014 Hello All, i have some question i made new script and i need create a table with this values { ID,name,price } and show it in GUI gridlist i have written code But it does not work GUIEditor = { gridlist = {}, window = {}, button = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(374, 208, 541, 361, "CarShow", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.gridlist[1] = guiCreateGridList(9, 24, 522, 242, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Price", 0.3) GUIEditor.button[1] = guiCreateButton(11, 295, 200, 56, "X", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "sa-header") GUIEditor.button[2] = guiCreateButton(217, 295, 314, 56, "use", false, GUIEditor.window[1]) end ) cars = {{402,'',price},{331,'',price},{333,'',price},{404,'',price},{413,'carname',price}} --- { ID,name,price } for i,v in pairs (cars) do local carName = (v[2]) local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, carName, false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, tostring(v[2]), false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 3, tostring(v[3]), false, true) end Link to comment
iPrestege Posted August 18, 2014 Share Posted August 18, 2014 GUIEditor = { gridlist = {}, window = {}, button = {} } cars = { { 402,'Car Name 1',199 }, { 331,'Car Name 2',299 }, { 333,'Car Name 3',399 }, { 404,'Car Name 4',499 }, { 413,'Car Name 5',599 }, { 411,'Car Name 6',999 }, } addEventHandler('onClientResourceStart', resourceRoot, function ( ) GUIEditor.window[1] = guiCreateWindow(374, 208, 541, 361, 'CarShow', false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) GUIEditor.gridlist[1] = guiCreateGridList(9, 24, 522, 242, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], 'ID', 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], 'Name', 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], 'Price', 0.3) GUIEditor.button[1] = guiCreateButton(11, 295, 200, 56, 'X', false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], 'sa-header') GUIEditor.button[2] = guiCreateButton(217, 295, 314, 56, 'use', false, GUIEditor.window[1]) for k,v in ipairs ( cars ) do local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1,v [1] , false, false) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v [2], false, false) guiGridListSetItemText (GUIEditor.gridlist[1], row, 3, v [3] , false, false) end end ) You can try that. 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