Jump to content

getAccountData() CS


#Paper

Recommended Posts

Just trying to elaborate what JR10 said,

Server Side:

  
-- Server Side 
function fetchAccounts( ) 
     
    local accounts = getAccounts() 
    triggerClientEvent(source, "giveAccounts", source, accounts) 
end 
addEvent("fetchAccounts", true) 
addEventHandler("fetchAccounts", true) 
  
-- Client Side 
local gridList -- Lets consider you already have a gridList made 
function giveAccounts( accounts ) 
     
    -- Now we'll loop and populate the gridList with account names, 
  
    -- PS: I don't know the what each index holds in the 'getAccounts()' table,  
    -- so consider the first index to be storing the account name 
  
    for i = 1, #accounts do 
        local row = guiGridListAddRow(gridList) 
         
        guiGridListSetItemText(gridList, row, 1, tostring(accounts[i]), false, false) 
    end 
end 
addEvent("giveAccounts", true) 
addEventHandler("giveAccounts", getLocalPlayer(), giveAccounts) 
  

If there is any more detail you need, reply back to this topic.

Link to comment
Server side:
local accounts = getAccounts() 
triggerClientEvent("event", player, accounts) 

Client side:

addEvent("event", true) 
addEventHandler("event", root, 
function(accounts) 
--code 
end) 

thanks but i need to get some datas from that account, i have already an idea, but then how can i put the table in ascending order? :S

Link to comment

You can make a (server side) loop that will get the data from each account, and trigger a client event with that data.

And in the client event add a one grid list row.

Ascending, why?, won't matter sorting the table.

Link to comment
thanks but i need to get some datas from that account, i have already an idea, but then how can i put the table in ascending order? :S

Do you mean ascending order by the creation of account? I believe it will automatically populate in an ascending order if you use an ipairs loop or the one I suggested.

You can make a (server side) loop that will get the data from each account, and trigger a client event with that data.

And in the client event add a one grid list row.

I wouldn't call that a very efficient method JR10, because constant server-client calls can result in lag as well as increased bandwidth use, so I'd suggest sending the whole table at once and then using it client side.

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