#Paper Posted August 8, 2011 Share Posted August 8, 2011 Is there a way to use getAccountData() in Client Side? Link to comment
Castillo Posted August 8, 2011 Share Posted August 8, 2011 No, but you can use triggerServerEvent, triggerClientEvent. Link to comment
#Paper Posted August 9, 2011 Author Share Posted August 9, 2011 I want to make a ranking in a gridList but i need to take the data from the table returned by getAccounts() Any example? Link to comment
JR10 Posted August 9, 2011 Share Posted August 9, 2011 Server side: local accounts = getAccounts() triggerClientEvent("event", player, accounts) Client side: addEvent("event", true) addEventHandler("event", root, function(accounts) --code end) Link to comment
Dev Posted August 9, 2011 Share Posted August 9, 2011 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
#Paper Posted August 9, 2011 Author Share Posted August 9, 2011 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? Link to comment
JR10 Posted August 9, 2011 Share Posted August 9, 2011 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
Dev Posted August 9, 2011 Share Posted August 9, 2011 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? 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
#Paper Posted August 9, 2011 Author Share Posted August 9, 2011 Ascending, why?, won't matter sorting the table. I want to make a ranking... So @ the 1° place tha player who have more cash than all etc etc, btw i have another question: table.sort function what does? Link to comment
JR10 Posted August 9, 2011 Share Posted August 9, 2011 http://lua-users.org/wiki/TableLibraryTutorial You will find table.sort 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