roaddog Posted April 15, 2015 Share Posted April 15, 2015 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: but before that, does my table look visually like this : 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 : Thanks Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now