Jump to content

[Help/GUI] Store, read and use data from a gridlist


Recommended Posts

Posted

You can store them on a lua table, then when re-open the GUI, loop the table and insert them into the grid list.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I got the XML file made, but now it doesn't read or misses the table, nor does it add rows/values into the gridlist.

  
function setRadioChannel(button, state) 
    local channel = xmlNodeGetChildren(xmlRootTree) 
    if (source == bChanSet) then 
        for k, v in ipairs(channel) do 
        local channelFreq = guiGetText(eChanFreq) 
        local channelDesc = guiGetText(eChanDesc) 
        local row = guiGridListAddRow(gRadioGrid) 
            if channelFreq then 
                guiGridListSetItemText( gRadioGrid, row, colFreq, channelFreq, false, false) 
                guiGridListSetItemData( gRadioGrid, row, colFreq, channelFreq) 
                outputDebugString("channelFreq Read, value " .. tostring(channelFreq) "set to row " .. tostring(row)) 
            end 
            if channelDesc then 
                guiGridListSetItemText( gRadioGrid, row, colDesc, channelDesc, false, false) 
                guiGridListSetItemData( gRadioGrid, row, colDesc, channelDesc) 
                outputDebugString("channelFreq Read, value " .. tostring(channelDesc) "set to row " .. tostring(row)) 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), setRadioChannel) 
  

Posted

Post the full code.

P.S: Never name a function like a native MTA function ( setRadioChannel ), unless you want to replace it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

How you want to load something that doesn't exist? you aren't writting anything on the file, also, you should load them on start, not when you add it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No, they don't.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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