Jump to content

Gridlist and SQLite help


Recommended Posts

--Client 
function openPanel(result4) 
for h=1,#result4 do 
            guiGridListClear(manageGridList) 
            row = guiGridListAddRow(manageGridList) 
            guiGridListSetItemText(manageGridList, row, 1, result4[h]["accName"], false, false) 
            guiGridListSetItemText(manageGridList, row, 2, result4[h]["rank"], false, false) 
end 
addEvent("openGroupPanel", true) 
addEventHandler("openGroupPanel", root, openPanel)  
--Server 
executeSQLQuery("CREATE TABLE IF NOT EXISTS groupMembers (groupName TEXT, accName TEXT, rank TEXT)") 
function openServerPanel(thePlayer) 
    local accName = getAccountName(getPlayerAccount(thePlayer)) 
    local group = getElementData(thePlayer, "Group") 
    local result4 = executeSQLQuery("SELECT * FROM groupMembers WHERE groupName=?", group) 
    triggerClientEvent(thePlayer, "openGroupPanel", thePlayer, result4) 
end 

The problem; as when I open the gridlist it only displays the last result found.

P.S: I obviously didn't post all of the code, just the part that isn't working properly.

Link to comment

Try this one.

-- Client Side 
function openPanel(result4) 
    guiGridListClear(manageGridList) 
    for i , v in pairs (result4) do  
        local row = guiGridListAddRow(manageGridList) 
        guiGridListSetItemText(manageGridList, row, 1, v["accName"], false, false) 
        guiGridListSetItemText(manageGridList, row, 2, v["rank"], false, false) 
    end 
end 
addEvent("openGroupPanel", true) 
addEventHandler("openGroupPanel", root, openPanel)  
  
-- Server Side 
executeSQLQuery("CREATE TABLE IF NOT EXISTS groupMembers (groupName TEXT, accName TEXT, rank TEXT)") 
  
function openServerPanel(thePlayer) 
    local accName = getAccountName(getPlayerAccount(thePlayer)) 
    local group = getElementData(thePlayer, "Group") 
    local result4 = executeSQLQuery("SELECT * FROM groupMembers WHERE groupName=?", group) 
    triggerClientEvent(thePlayer, "openGroupPanel", thePlayer, result4) 
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...