Bean666 Posted June 10, 2016 Share Posted June 10, 2016 why is it like this? cost = { "1000$", "1000$", "1000$", "1000$" } spawnG = guiCreateGridList(0.02, 0.04, 0.56, 0.94, true, window) guiGridListSetSelectionMode ( spawnG, 2 ) local column1 = guiGridListAddColumn(spawnG, "Weapons:", 0.5) local column2 = guiGridListAddColumn(spawnG, "Cost:", 0.5) Cost part: for key,cost in pairs(cost) do local row = guiGridListAddRow ( spawnG ) guiGridListSetItemText ( spawnG, row, 2, cost, false, false ) end Link to comment
Anubhav Posted June 10, 2016 Share Posted June 10, 2016 Don't add different rowsfor cost. You are making more rows causing the gridlist to make more rays. Link to comment
Bean666 Posted June 10, 2016 Author Share Posted June 10, 2016 it's not what i mean, i want the all the 1000$ up there, they're not the same line as the other rows. how to fix it? here is the gridlist/rows part: skins = { {"M4", 31}, {"AK47", 30}, {"Shotgun", 25}, {"Sniper", 34}, } cost = { "1000$", "1000$", "1000$", "1000$" } window = guiCreateWindow(0.31, 0.21, 0.38, 0.63, "Weapon Shop", true) guiWindowSetSizable(window, false) guiSetVisible(window, false) spawnG = guiCreateGridList(0.02, 0.04, 0.56, 0.94, true, window) guiGridListSetSelectionMode ( spawnG, 2 ) local column1 = guiGridListAddColumn(spawnG, "Weapons:", 0.5) local column2 = guiGridListAddColumn(spawnG, "Cost:", 0.5) for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG) guiGridListSetItemText(spawnG, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG, row, 1, tostring(skins[2])) end for key,cost in pairs(cost) do local row = guiGridListAddRow(spawnG) guiGridListSetItemText ( spawnG, row, 2, cost, false, false ) end guiGridListAddRow(spawnG) spawnbtn = guiCreateButton(0.63, 0.31, 0.30, 0.11, "Buy", true, window) cancel = guiCreateButton(0.63, 0.54, 0.30, 0.11, "Cancel", true, window) function buyweapon() if ( source == spawnbtn ) then local row, col = guiGridListGetSelectedItem( spawnG ) local name = guiGridListGetItemText( spawnG, row, col ) if name == "M4" then local id = 31 triggerServerEvent("spawn", getLocalPlayer(), id) elseif name == "AK47" then local id = 30 triggerServerEvent("spawn2", getLocalPlayer(), id) elseif name == "Shotgun" then local id = 25 triggerServerEvent("spawn3", getLocalPlayer(), id) elseif name == "Sniper" then local id = 34 triggerServerEvent("spawn4", getLocalPlayer(), id) end end end addEventHandler("onClientGUIClick",root,buyweapon) Link to comment
فاّرس Posted June 10, 2016 Share Posted June 10, 2016 (edited) are you making another grid list rows in another table or outside the loop? edit # do it in one table : skins = { {"M4", 31, "1000$"}, {"AK47", 30, "1000$"}, {"Shotgun", 25, "1000$"}, {"Sniper", 34, "1000$"}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG) guiGridListSetItemText(spawnG, row, 1, skins[1], false, false) guiGridListSetItemText ( spawnG, row, 2, skins[3], false, false ) guiGridListSetItemData(spawnG, row, 1, skins[2]) end and remove line 35 . Edited June 10, 2016 by Guest Link to comment
Bean666 Posted June 10, 2016 Author Share Posted June 10, 2016 nah that's all the tables in the script. Link to comment
فاّرس Posted June 10, 2016 Share Posted June 10, 2016 edited^ and you can do this : -- Client side # function buyweapon() if ( source == spawnbtn ) then if guiGridListGetSelectedItem( spawnG ) ~= -1 then local name = guiGridListGetItemText( spawnG, guiGridListGetSelectedItem( spawnG ), 1 ) local data = guiGridListGetItemData ( spawnG, guiGridListGetSelectedItem( spawnG ),1 ) triggerServerEvent("spawn", getLocalPlayer(), name, data ) end end end addEventHandler("onClientGUIClick",root,buyweapon) -- Server Side # addEvent ( 'spawn', true) addEventHandler('spawn', root,function (name, data) outputChatBox ( 'you have been giving a '..name..' weapon', client) giveWeapon ( client, data ) end) and you can do this with money too. 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