Bilal135 Posted December 4, 2018 Share Posted December 4, 2018 Wanted to fill up a grid list with locations that are specified in a table, based on a team that was selected in another grid list, but I can't seem to get it right. No errors in the debug. Any help regarding this would be appreciated. Thanks. addEventHandler("onClientGUIClick", resourceRoot, function(button, state) if button == "left" and state == "up" then local LALocations = {"LA Test 1", "LA Test 2", "LA Test 3"} local IFLocations = {"IF Test 1", "IF Test 2", "IF Test 3"} local row, col = guiGridListGetSelectedItem(team_gridlist) if row and col and row ~= -1 and col ~= -1 then local team = guiGridListGetItemText(team_gridlist, row, col) if team == "Liberation Army" then outputChatBox("Test successful", 100, 255, 100) for _, locations_LA in ipairs(LALocations) do local location_row_LA = guiGridListAddRow(location_gridlist) guiGridListSetItemText(location_gridlist, location_row_LA, location_col, locations_LA, false, false) end if team == "Imperial Forces" then for _, locations_IF in ipairs(IFLocations) do local location_row_IF = guiGridListAddRow(location_gridlist) guiGridListSetItemText(location_gridlist, location_row_IF, location_col, locations_IF, false, false) end end end end end end) Here's the complete client sided code; https://pastebin.com/NL7YfyZ4 Link to comment
Mahlukat Posted December 4, 2018 Share Posted December 4, 2018 can you try this? teams = {"Liberation Army", "Imperial Forces"} function getPos() local x, y ,z = getElementPosition(localPlayer) local pos = tostring(x..", "..y..", "..z) outputChatBox(pos, 255, 100, 100, false) setClipboard(pos) end addCommandHandler("pos", getPos) ---- GUI Creation addEventHandler("onClientResourceStart", resourceRoot, function() window = guiCreateWindow(0.57, 0.25, 0.19, 0.37, "Spawn Menu", true) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetAlpha(window, 1.00) team_gridlist = guiCreateGridList(10, 32, 284, 98, false, window) column = guiGridListAddColumn(team_gridlist, "Team", 0.9) for i,teamtext in pairs(teams) do local row = guiGridListAddRow(team_gridlist,teamtext) end -- rowA = guiGridListAddRow(team_gridlist) -- rowB = guiGridListAddRow(team_gridlist) -- guiGridListSetItemText(team_gridlist, 0, 1, "Liberation Front", false, false) -- guiGridListSetItemText(team_gridlist, 1, 1, "Imperial Forces", false, false) skin_label = guiCreateLabel(58, 248, 71, 15, "Select a skin", false, window) skin_btn_next = guiCreateButton(96, 273, 33, 16, ">", false, window) skin_btn_previous = guiCreateButton(58, 273, 33, 16, "<", false, window) location_gridlist = guiCreateGridList(10, 140, 284, 98, false, window) location_col = guiGridListAddColumn(location_gridlist, "Location", 0.9) weapon_label = guiCreateLabel(155, 248, 96, 15, "Select a weapon", false, window) weapon_btn_next = guiCreateButton(165, 273, 33, 16, ">", false, window) weapon_btn_previous = guiCreateButton(204, 273, 33, 16, "<", false, window) spawn_btn = guiCreateButton(114, 299, 67, 24, "Spawn", false, window) guiSetVisible(window, false) end ) ---- GUI functions function isGUIVisible(gui) return (guiGetVisible(gui) == true) end -- Make the GUI appear on login. addEvent("onClientPlayerLoginn", true) addEventHandler("onClientPlayerLoginn", root, function() if isGUIVisible(window) then return end guiSetVisible(window, true) -- Set the camera to the desired location. setCameraMatrix(-2610.9792480469, 1445.4840087891, 7.1875, -2610.9792480469, 1445.4840087891, 7.1875) -- Make a ped with default skin (0). local ped = createPed(0, -2614.0212402344, 1451.1651611328, 7.1875, 180) end) -- Team addEventHandler("onClientGUIClick", resourceRoot, function() if (source == spawn_btn) then local team = getSelectedTeam() if team then triggerServerEvent("setTeam", localPlayer, team) end end end) function getSelectedTeam() local row, col = guiGridListGetSelectedItem(team_gridlist) if row and col and row ~= -1 and col ~= -1 then return guiGridListGetItemText(team_gridlist, row, col) else return false end end local LALocations = {"LA Test 1", "LA Test 2", "LA Test 3"} local IFLocations = {"IF Test 1", "IF Test 2", "IF Test 3"} -- Location (according to the team) addEventHandler("onClientGUIClick", resourceRoot, function(button, state) if source == team_gridlist then local team = getSelectedTeam() if team then guiGridListClear(location_gridlist) if team == "Liberation Army" then outputChatBox("Test successful", 100, 255, 100) for _, locations_LA in ipairs(LALocations) do local location_row_LA = guiGridListAddRow(location_gridlist,locations_LA) --guiGridListSetItemText(location_gridlist, location_row_LA, location_col, locations_LA, false, false) end elseif team == "Imperial Forces" then for _, locations_IF in ipairs(IFLocations) do local location_row_IF = guiGridListAddRow(location_gridlist,locations_IF) --guiGridListSetItemText(location_gridlist, location_row_IF, location_col, locations_IF, false, false) end end end end end) -- Skin -- Weapon Link to comment
Bilal135 Posted December 5, 2018 Author Share Posted December 5, 2018 Thank you very much @Mahlukat. Problem is fixed. 1 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