Enkanet Posted April 5, 2015 Share Posted April 5, 2015 Hello, everyone! As I asked above, how can I get a random data from a gridlist? Well, I have a gridlist and 3 columns. First one is something like id. It is ordering the rows one by one. I can choose one of them randomly by math.random. I can randomly choose a row by that id which is first column. Now, I want to get the second column's data which is in the same row with the number that I randomly found via 1st column. How can I do it? Thanks in advance. Link to comment
Enkanet Posted April 5, 2015 Author Share Posted April 5, 2015 guiGridListGetItemData Well, I know this but I can not really use it. Here's my code: function getInfoVehlib(data) local row = guiGridListAddRow(Tickets) griditems = guiGridListGetRowCount(Tickets) for i,ticketitems in ipairs(data) do guiGridListSetItemText(Tickets, row, 1, griditems, false, false) guiGridListSetItemText(Tickets, row, 2, ticketitems[1], false, false) guiGridListSetItemText(Tickets, row, 3, ticketitems[2], false, false) end end addEvent("sendTicketInfo", true) addEventHandler("sendTicketInfo", getRootElement(), getInfoVehlib) function drawGui() local screenW, screenH = guiGetScreenSize() main = guiCreateWindow((screenW - 466) / 2, (screenH - 370) / 2, 466, 370, "Enkanet's System", false) guiWindowSetSizable(main, false) Tickets = guiCreateGridList(14, 31, 442, 236, false, main) local number = guiGridListAddColumn(Tickets, "#", 0.08) local biletNumarasi = guiGridListAddColumn(Tickets, "Ticket Number", 0.3) local biletSahibi = guiGridListAddColumn(Tickets, "Ticket Owner", 0.6) closeBtn = guiCreateButton(253, 277, 203, 42, "Close", false, main) rastgeleBtn = guiCreateButton(14, 277, 203, 42, "Random Player", false, main) odulMemo = guiCreateMemo(54, 329, 402, 31, "", false, main) odulLabel = guiCreateLabel(14, 333, 40, 21, "Prize:", false, main) addEventHandler("onClientGUIClick", closeBtn, function() guiSetVisible(main, false) end) addEventHandler("onClientGUIClick", rastgeleBtn, function() local luckyboy = math.random(1, griditems) -- Here I get the 1st column's data. end) triggerServerEvent("getTickets", resourceRoot) end addEvent("drawGui", true) addEventHandler("drawGui", root, drawGui) Link to comment
WhoAmI Posted April 5, 2015 Share Posted April 5, 2015 Well, If you can random from 1st id's, do it. You'll get row id, which is good. Then, use guiGridListSetSelectedItem Link to comment
Enkanet Posted April 5, 2015 Author Share Posted April 5, 2015 Well,If you can random from 1st id's, do it. You'll get row id, which is good. Then, use guiGridListSetSelectedItem Oh, thanks lol. I'll try it.. (Glad to see clever boys around here lol.) Link to comment
WhoAmI Posted April 5, 2015 Share Posted April 5, 2015 Well,If you can random from 1st id's, do it. You'll get row id, which is good. Then, use guiGridListSetSelectedItem Oh, thanks lol. I'll try it.. (Glad to see clever boys around here lol.) Dimos7 often doesn't understand what topic's maker wants to do. 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