Jump to content

Insert values from dbExec to a grid list


WiBox

Recommended Posts

function openGrid(plr)
    local tName = getElementData( plr, "t")
    local Test3 = getTlist1(tName, false)
    local Test4 = getTlist2(tName, false)
    data1 = {}
    data2 = {}
    for ind, col in ipairs(Test3) do
        data1[#data1+1] = {}
        data1[#data1+1] = col.account
    end
    for ind, col in ipairs(Test4) do
        data2[#data2+1] = {}
        data2[#data2+1] = col.T
    end
    if ( canPlayerDoActionInGroup( client, "editT") ) then
        triggerClientEvent( plr, "openGridList", plr, data1, data2)
    else
        return
    end
end
addEvent("viewGridList", true)
addEventHandler("viewGridList", root, openGrid)

Hello, now in some different ways, I could check if the data of (dbExec) get saved, it does... but the thing is I'm trying to add the data stored inside the (dbExec) in a GridList...

Does anyone know how? That is server side, and this is the Client Side:

function displayActions2(table)
    guiGridListClear(t)
    for k, v in ipairs(table) do
        local row = guiGridListAddRow(t)
        guiGridListSetItemText(t, row, 1, v[k].account, false, false)
    end
end

function displayActions3(table)
    guiGridListClear(TT)
    for k, v in ipairs(table) do
        local row = guiGridListAddRow(TT)
        guiGridListSetItemText(TT, row, 1, v[k].T, false, false)
    end
end

function window( table, table2 )
    guiSetVisible( window, true)
	guiBringToFront( window )
	displayActions2( table )
	displayActions3( table2 )	
end
addEvent("openGridList", true)
addEventHandler("openGridList", root, window)

to be honest I tried to remove v[k].T and add "test" so it wrote 3 times "test" and I already tried to add 3 different account names.. so I'm just having problem by getting the name and add it in this

v[k].T and v[k].account

Link to comment
function openGrid(plr)
    local tName = getElementData( plr, "t")
    local account = dbQuery(con, "SELECT * FROM tSys WHERE tName = ?", tName)
    local account2 = dbPoll(account, -1)
    
    local accountz = dbQuery(con, "SELECT * FROM tSys2 WHERE tName = ?", tName)
    local accountz2 = dbPoll(account, -1)
    data1 = {}
    data2 = {}
  
    for ind, col in ipairs(account2) do
        data1[#data1+1] = {}
        data1[#data1+1] = col.account
    end
    for ind, col in ipairs(accountz2) do
        data2[#data2+1] = {}
        data2[#data2+1] = col.T
    end
    if ( canPlayerDoActionInGroup( client, "editT") ) then
        triggerClientEvent( plr, "openGridList", plr, data1, data2)
    else
        return
    end
end
addEvent("viewGridList", true)
addEventHandler("viewGridList", root, openGrid)

I've made it a bit better.. I don't know if I did the "dbQuery right", but the part which I want to fix is taking the account2 and accountz2 from those 2 dbQuery, and add them in a grid list which is:

function displayActions2(table)
    guiGridListClear(t)
    for k, v in ipairs(table) do
        local row = guiGridListAddRow(t)
        guiGridListSetItemText(t, row, 1, v[k].account, false, false)
    end
end

function displayActions3(table)
    guiGridListClear(TT)
    for k, v in ipairs(table) do
        local row = guiGridListAddRow(TT)
        guiGridListSetItemText(TT, row, 1, v[k].T, false, false)
    end
end

function window( table, table2 )
    guiSetVisible( window, true)
    guiBringToFront( window )
    displayActions2( table )
    displayActions3( table2 )	
end
addEvent("openGridList", true)
addEventHandler("openGridList", root, window)

The error which I'm getting at /debugscript 3 is:

ERROR: Tsys.lua:1422: attempt to index field '?' (a nil value)

and the line 1422 is:

guiGridListSetItemText(t, row, 1, v[k].account, false, false)

Which is at the function displayActions2, the thing is I'm not sure if the v[k].account is wrong or the account2 and accountz2 name not working at the function openGrid()...

Sorry for my bad skills, I tried to explain as good as possible...

I've replace "v[k].account" and "v[k].T" with math.random, and it worked, so all what I know it's either from "v[k].account" or "v[k].T" either from the table "data1" and "data2" either from "dbQuery" ...

Edited by R.I.P Logic
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...