Jump to content

Table and Loops


roaddog

Recommended Posts

What's up,

Look I need help with this loops of my table.

Server:

addEvent("getDetailsofReferral", true) 
addEventHandler("getDetailsofReferral", root, function(p) 
    if isElement(p) then 
        local data = {} 
        local player = {} 
        local acc = getPlayerAccount(p) 
        local accname = getAccountName(acc) 
        local refpts = getAccountData(acc, "referalpts") or 0 
        local accs = getAccounts() 
            for c, acc in pairs(accs) do 
                local referral = getAccountData(acc, "referral") 
                if tostring(referral) == accname then 
                    local accntname = getAccountName(acc) 
                    local session = exports.AGlogin:checkColumnValue(getAccountName(acc), "loginSession") or 0 
                    local localpts = getAccountData(getAccount(referral), tostring(accntname)) or 0 
                    player = { name = tostring(accntname), login = tostring(session), pts = tostring(localpts)} -- This table stores referrer's clients. 
                    outputChatBox(player.name) 
                    outputChatBox(player.login) 
                    outputChatBox(player.pts) 
                end 
            end 
        local data = { name=tostring(accname), pts = tostring(refpts), players = player } -- This table stores referrer details + clients 
        triggerClientEvent(p, "callBackDetailsofReferral", p, data) 
    end 
end) 

This screenshot shows you what the player table stored:

2015_04_15_045439.png

but before that, does my table look visually like this :

Referralspng.png

Client:

addEvent("callBackDetailsofReferral", true) 
addEventHandler("callBackDetailsofReferral", root, function(d) 
    if guiGetVisible(Referral.window[1]) then 
        row = guiGridListAddRow(Referral.gridlist[1]) 
        guiGridListSetItemText(Referral.gridlist[1], row, 1, "Getting players", false, false) 
        guiGridListSetItemText(Referral.gridlist[1], row, 2, "  whom you", false, false) 
        guiGridListSetItemText(Referral.gridlist[1], row, 3, "invited..", false, false) 
        setTimer(function(d) guiSetText(Referral.label[1], "Name: "..tostring(d.name).."\nSerial: "..getPlayerSerial(localPlayer).."\nReferralPoints: "..tostring(d.pts).."\nMoney Earn: $") 
        guiGridListClear(Referral.gridlist[1]) 
        if type(d) == "table" then 
            for i, v in pairs(d) do 
                if i == "players" then 
                    for k, c in pairs(v) do 
                        local row = guiGridListAddRow(Referral.gridlist[1]) 
                        guiGridListSetItemText(Referral.gridlist[1], row, 1, v.name, false, false) 
                        guiGridListSetItemText(Referral.gridlist[1], row, 2, v.login, false, false) 
                        guiGridListSetItemText(Referral.gridlist[1], row, 3, v.pts, false, false) 
                    end 
                end 
            end 
        end 
        end, 3000, 1, d) 
    end 
end) 

This is what I got, please correct my loops :

2015_04_15_045428.png

Thanks

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