Jump to content

GUI functions


WiBox

Recommended Posts

addEventHandler("onClientGUIChanged", resourceRoot,
    function()
        local text = guiGetText(search)
        local data1Items = { }
        local data2Items = { }
        local data3Items = { }
        local data4Items = { }
        local data5Items = { }
        local data6Items = { }
        if source == search then
            for i, v in pairs(vehInfo) do
                if not (text == "" ) then
                    if (string.find(string.upper(v[3]), string.upper(text), 1, true)) then
                        table.insert(data1Items, v[1])
                        table.insert(data2Items, v[2])
                        table.insert(data3Items, v[3])
                        table.insert(data4Items, v[4])
                        table.insert(data5Items, v[5])
                        table.insert(data6Items, v[6])
                    end	            
                end
            end
            if ( text == "" ) then
                guiGridListClear(grid)
                    for index, vehs in ipairs(vehInfo) do
                    local row = guiGridListAddRow(grid)
                    if (getSetting(vehs[1])) then
                        guiGridListSetItemText(grid, row, name, getSetting(vehs[1]), false, false)
                    end
                    if (getSetting(vehs[2])) then
                        guiGridListSetItemText(grid, row, ID, getSetting(vehs[2]), false, false)
                    end
                    if (getSetting(vehs[3])) then
                        guiGridListSetItemText(grid, row, replaces, getSetting(vehs[3]), false, false)
                    end
                    if (getSetting(vehs[4])) then
                        guiGridListSetItemText(grid, row, Size, getSetting(vehs[4]), false, false)
                    end
                    if (getSetting(vehs[5])) then
                        guiGridListSetItemText(grid, row, Downloaded, getSetting(vehs[5]), false, false)
                    end
                    if (getSetting(vehs[6])) then
                        guiGridListSetItemText(grid, row, Enabled, getSetting(vehs[6]), false, false)
                    end  	
                end	
            else	
                -- Here is my problem:
                guiGridListClear(grid)
                row = guiGridListAddRow(grid)
                for i, v in pairs(data1Items) do
                    guiGridListSetItemText(grid, row, 1, v, false, false)				
                end
                for i, v in pairs(data2Items) do
                    guiGridListSetItemText(grid, row, 6, v, false, false)
                end
                for i, v in pairs(data3Items) do
                    guiGridListSetItemText(grid, row, 2, v, false, false)
                end
                for i, v in pairs(data4Items) do
                    guiGridListSetItemText(grid, row, 3, v, false, false)
                end
                for i, v in pairs(data5Items) do
                    guiGridListSetItemText(grid, row, 4, v, false, false)
                end
                for i, v in pairs(data6Items) do
                    guiGridListSetItemText(grid, row, 5, v, false, false)
                end
            end
        end
    end
)

I know where's my mistake, but I don't know how to fix, I tried but I don't have the idea how to fix it, 

in those tables( data1Items, data2Items, data3Items...) I need each one on a line, but the thing is when I search for the vehicle name, it search only at the first row ( Row ID 0 ) so I tried to use 

for i, v in pairs(data1Items) do
    local row = guiGridListAddRow(grid)
    guiGridListSetItemText(grid, row, 1, v, false, false)
end

Worked because each data is getting on a line because I add the 

local row = guiGridListAddRow(grid)

in the 

for i, v in pairs() do
end

but I need to make for multi tables( data1Items, data2Items, data3Items...), I didn't know who to do it..

Any ideas?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...