ParadoxTR Posted April 19, 2017 Share Posted April 19, 2017 I make top level system, but server lagging. How can ı do? help me. sry my bad english Server function getPlayersSortByaData() local TopData = { } for i, v in ipairs( getAccounts() ) do if getAccountData ( v, 'level' ) then table.insert (TopData, { Name = i , Account = getAccountData ( v, 'nickname' ) or getAccountName(v) , aScore = getAccountData ( v, 'level' ) or 0 , aTecrube = tonumber(getAccountData ( v, 'level' ))+(tonumber(getAccountData ( v, 'experience' ))/100000) , } ) end end table.sort( TopData, function( a, b ) return( tonumber( a.aTecrube ) or 0 ) > ( tonumber( b.aTecrube ) or 0 ) end ) return TopData end addEvent("getTop2", true) addEventHandler("getTop2", root,function() triggerClientEvent(source, "SetData", source, getPlayersSortByaData()) end) addEvent("getTop3", true) addEventHandler("getTop3", root,function() createMoneySystem( source ) end) function createMoneySystem( player ) if not isElement( player ) then return end local Top = {} local CreatTop = executeSQLQuery( "SELECT * FROM FurkanBank" ) for i = 1, #CreatTop do table.insert(Top,{name = getAccountData(getAccount(CreatTop[i].hesap_adi),"nickname") or CreatTop[i].hesap_adi,score = CreatTop[i].para+getAccountData(getAccount(CreatTop[i].hesap_adi),"funmodev2-money")}) end if #CreatTop >0 then table.sort(Top, function(a,b) return (tonumber(a.score)or 0) > (tonumber(b.score)or 0) end) for k, data in ipairs(Top) do if k == 1 then triggerClientEvent (player,"deltTop2",player) end triggerClientEvent (player,"updateTopMoney",player,tostring(data.name),tostring(data.score),tonumber(k)) if k == 200 then table.remove(Top) break end end end end Client addEvent("SetData",true) addEventHandler("SetData",root,function ( Table ) guiGridListClear( WindowSiralamaList2 ) for i = 1,200 do local row = guiGridListAddRow ( WindowSiralamaList2 ) guiGridListSetColumnTitle(WindowSiralamaList2 ,column2, "Level") if ( Table [ i ].aScore ) then guiGridListSetItemText( WindowSiralamaList2, row, column, i , false, false ) guiGridListSetItemText( WindowSiralamaList2, row, column1, Table [i ].Account , false, false ) guiGridListSetItemText( WindowSiralamaList2, row, column2, Table [ i ].aScore , false, false ) guiGridListSetItemColor(WindowSiralamaList2, row, column1, 255, 255, 0) guiGridListSetItemColor(WindowSiralamaList2, row, column2, 0, 180, 255) guiGridListSetItemColor(WindowSiralamaList2, row, column, 255, 0, 0) end end end) addEvent("updateTopMoney",true) addEventHandler("updateTopMoney",root,function ( a,b,c ) local row = guiGridListAddRow ( WindowSiralamaList2 ) guiGridListSetItemText( WindowSiralamaList2, row, column, c , false, false ) guiGridListSetItemText( WindowSiralamaList2, row, column1, tostring(a) , false, false ) guiGridListSetItemText( WindowSiralamaList2, row, column2, "$"..formatNumber(tostring(b)).."" , false, false ) guiGridListSetItemColor(WindowSiralamaList2, row, column1, 255, 255, 0) guiGridListSetItemColor(WindowSiralamaList2, row, column2, 0, 180, 255) guiGridListSetItemColor(WindowSiralamaList2, row, column, 255, 0, 0) end) function deltTop2() guiGridListClear(WindowSiralamaList2) end addEvent("deltTop2", true) addEventHandler("deltTop2", root, deltTop2) Link to comment
NeXuS™ Posted April 20, 2017 Share Posted April 20, 2017 Try using executeSQLQuery instead of getAccounts. Link to comment
undefined Posted April 20, 2017 Share Posted April 20, 2017 You should use SQL. Sunucunuzda bunca kişi varken her birinin hesabını arayıp, teker teker verilerini toplamak sisteme çok ağır gelir. SQL ile bunun kolay yolları mevcut. Tüm kayıtları SQL sistemine çekersen, hem bu sorun giderilebilir hem de sunucunun diğer işlemleri daha az sistem harcayabilir. Tavsiyem bütün bilgileri veritabanı oluşturup oraya atman. 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