crabby Posted September 15, 2015 Share Posted September 15, 2015 i use this function function gridlist(clan) theTable = {} for index, ac in pairs(getAccounts()) do local keyclan = getAccountData(ac,"ortakveri") if keyclan and keyclan == clan then local nick = getAccountData(ac,"nick") table.insert(theTable, {nick}) triggerClientEvent(source,"gridlist",source,theTable) end end end Link to comment
Chaos Posted September 15, 2015 Share Posted September 15, 2015 why do you store it in table ? Link to comment
crabby Posted September 15, 2015 Author Share Posted September 15, 2015 Where do you suggest I store? Link to comment
Chaos Posted September 15, 2015 Share Posted September 15, 2015 directly trigger it triggerClientEvent(source,"gridlist",source,nick) Link to comment
crabby Posted September 15, 2015 Author Share Posted September 15, 2015 Is there a reason I'm storage of lag? Link to comment
JR10 Posted September 16, 2015 Share Posted September 16, 2015 You're triggering the client event with the table for each account. function gridlist(clan) theTable = {} for index, ac in pairs(getAccounts()) do local keyclan = getAccountData(ac,"ortakveri") if keyclan == clan then local nick = getAccountData(ac,"nick") table.insert(theTable, {nick}) end end triggerClientEvent(source,"gridlist",resourceRoot,theTable) end I doubt source is defined here, make sure it is. Also, you don't need to store each 'nick' in a table, since there are no other values added. Link to comment
crabby Posted September 17, 2015 Author Share Posted September 17, 2015 thx but still have lag and i have 4000+ account. i use this function but i again have a problem. clan have more member but just view a member. I want to get members loop clan data only once and members use this clan data tables on client side --Serverside function gridlist(clan) theTable = {} for index, ac in pairs(getAccounts()) do local keyclan = getAccountData(ac,"ortakveri") if keyclan and keyclan == clan then local nick = getAccountData(ac,"nick") local accname= getAccountName(ac) table.insert(theTable, {nick,accname}) triggerClientEvent(source,"gridlist",resourceRoot,theTable,clan) end end end --Clientside local clanTable = {} addEvent("gridlist",true) addEventHandler("gridlist",root, function(theTable,clan) clanTable[clan] = theTable -- i use this table on gridlist end) Link to comment
Dealman Posted September 17, 2015 Share Posted September 17, 2015 Well of course if you have over 4000 accounts and loop through them all, while triggering a client event with every entry it's gonna lag. Lets say you have 4500 accounts, for every 1 account it founds it will do this; local nick = getAccountData(ac,"nick") local accname= getAccountName(ac) table.insert(theTable, {nick,accname}) triggerClientEvent(source,"gridlist",resourceRoot,theTable,clan) Now you repeat this for the remaining 4499 accounts. Hardly very efficient. And since I don't know what you're trying to do, I can't really help you make it any better. First of all, trigger the client event ONCE and not 4000+ times. To do that, simply move the event out of the loop - it makes no sense to have it inside the loop. function gridlist(clan) theTable = {} for index, ac in pairs(getAccounts()) do local keyclan = getAccountData(ac, "ortakveri") if keyclan and keyclan == clan then local nick = getAccountData(ac, "nick") local accname= getAccountName(ac) table.insert(theTable, {nick, accname}) end end -- Loop stops executing here triggerClientEvent(source,"gridlist", resourceRoot, theTable, clan) end Edit: You might have to make the table theTable global instead of local, I can't recall how strict Lua is with local variables. Link to comment
Moderators IIYAMA Posted September 17, 2015 Moderators Share Posted September 17, 2015 For large amount of data, I recommend: triggerLatentClientEvent Else the client might timed-out, triggerClientEvent has a high priority over the MTA network. Link to comment
JR10 Posted September 18, 2015 Share Posted September 18, 2015 thx but still have lag You did not use my code at all. Link to comment
crabby Posted September 18, 2015 Author Share Posted September 18, 2015 i dont have 4000+ users accounts and this users number just example but my friend in server have users and i make for him this script and we have lag. everybody thank you very much for help. i did not know resourceRoot and Loop stops executing but now teach its. Link to comment
Dealman Posted September 18, 2015 Share Posted September 18, 2015 i dont have 4000+ users accounts and this users number just example but my friend in server have users and i make for him this script and we have lag.everybody thank you very much for help. i did not know resourceRoot and Loop stops executing but now teach its. Why would you say you have over 4 000 accounts when you don't? Did you manage to fix it, or is it still lagging? Did you apply our changes to the loop or not? Link to comment
crabby Posted February 7, 2016 Author Share Posted February 7, 2016 yes I did thx. my problem is I have to ask again and again getAccounts() but now just a ask to getAccounts() and make clan tables to trigger list. now im fine 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