Jump to content

[HELP] Get all rows from gridlist


Recommended Posts

Hello, I got a quick question, how do I get all the rows from a gridlist?

I got this gridlist:

Inter.grid.list = guiCreateGridList(9, 181, 452, 369, false, Inter.window) 

and I want to get all the rows instead of using:

local row, _ = guiGridListGetSelectedItem ( Inter.grid.list ); 

Link to comment

Ok, I did what you said and got this:

elseif ( source == Inter.btn.downloadAll ) then  
            for i, v in pairs ( Inter.rows ) do  
                local row = unpack(v) 
                local name = guiGridListGetItemText ( Inter.grid.list, row, 1) 
                local dtxd = Downloader.Mods[ name ].txd 
                local ddff = Downloader.Mods[ name ].dff 
                triggerEvent("startDownloadModSelected", root, dtxd, ddff) 
                Inter.refresh ( ); 
            end  

The thing is that MTA freezes as it downloads all the mods at the same time. How can I make the mods add to the download at an interval of 5 seconds? What I mean is, how can I get each row at an interval of 5 seconds? I was thinking of setTimer but it doesn't seem to be the right thing to do :P

Link to comment

[quote name=..:D&G:..]Ok, I did what you said and got this:

elseif ( source == Inter.btn.downloadAll ) then  
            for i, v in pairs ( Inter.rows ) do  
                local row = unpack(v) 
                local name = guiGridListGetItemText ( Inter.grid.list, row, 1) 
                local dtxd = Downloader.Mods[ name ].txd 
                local ddff = Downloader.Mods[ name ].dff 
                triggerEvent("startDownloadModSelected", root, dtxd, ddff) 
                Inter.refresh ( ); 
            end  

The thing is that MTA freezes as it downloads all the mods at the same time. How can I make the mods add to the download at an interval of 5 seconds? What I mean is, how can I get each row at an interval of 5 seconds? I was thinking of setTimer but it doesn't seem to be the right thing to do :P

Yes, you can use setTiemr to do this.

Try this:

        elseif ( source == Inter.btn.downloadAll ) then 
            for i, v in pairs ( Inter.rows ) do 
                setTimer ( function ( v ) 
                    local row = unpack(v) 
                    local name = guiGridListGetItemText ( Inter.grid.list, row, 1) 
                    local dtxd = Downloader.Mods[ name ].txd 
                    local ddff = Downloader.Mods[ name ].dff 
                    triggerEvent("startDownloadModSelected", root, dtxd, ddff) 
                    Inter.refresh ( ); 
                end, (i-1)*5000, 1, v ); 
            end 

Link to comment

Yes, you can use setTiemr to do this.

Try this:

        elseif ( source == Inter.btn.downloadAll ) then 
            for i, v in pairs ( Inter.rows ) do 
                setTimer ( function ( v ) 
                    local row = unpack(v) 
                    local name = guiGridListGetItemText ( Inter.grid.list, row, 1) 
                    local dtxd = Downloader.Mods[ name ].txd 
                    local ddff = Downloader.Mods[ name ].dff 
                    triggerEvent("startDownloadModSelected", root, dtxd, ddff) 
                    Inter.refresh ( ); 
                end, (i-1)*5000, 1, v ); 
            end 

Lol, I always think of noobish way to do them, and look stupid may I know what this means?

end, (i-1)*5000, 1, v ); 

Link to comment

If you want 5s interval,

            for i, v in pairs ( Inter.rows ) do 
                local row = unpack(v) 
                local name = guiGridListGetItemText ( Inter.grid.list, row, 1) 
                local dtxd = Downloader.Mods[ name ].txd 
                local ddff = Downloader.Mods[ name ].dff 
                 
                local t = ( i - 1 ) * 5000 
                setTimer ( 
                    function ( ) 
                        triggerEvent("startDownloadModSelected", root, dtxd, ddff) 
                    end, 
                ( t == 0 ) and 50 or t, 1 ); 
                Inter.refresh ( ); 
            end 

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...