Jump to content

Gridlist and SQLite help


Recommended Posts

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

Posted

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 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Works like a charm, thanks a lot for helping. :)

np.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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