lag - OnPlayerUpdate? [application-optimize code]
#1

Well i came to point of hearing every people saying that's OnPlayerUpdate lags my server. Some people say to not use it. Well i probably don't know what to do. Ofc my server lags like hell but i didn't even thought that this code may lag it. So i decided to show my OnPlayerUpdate callback. This really lags? Or it's everything good?

To not being pointless i'll say you whats on this callback. It's just simple scripts for anti team kill, anti money hack and anti airbreak. OFC i wont show all the scripts variables etc. So i need to remove it and my server won't lag again?
Reply
#2

OnPlayerUpdate gets called very frequently each second depending on what the player is doing. This is a quote from the SA-MP wiki:
Quote:

This callback is called everytime a client/player updates the server with their status.

This could mean that OnPlayerUpdate gets called about 10-50 times in a second while the player is doing something meaning everything you have under OnPlayerUpdate is processed way more than you would possibly need to.

A solution to this is to move all the code you have under OnPlayerUpdate to a timer. This timer could be a single second timer or even a half second timer. Either way, it would be much better for your server's performance to use a timer instead of OnPlayerUpdate.
Reply
#3

Also why are you saving ALL the player's information like that at once?

Save what is changed at its time. I dont think that some vars needs saving at all ( admin stats / sex / age / orgin ... )
Reply
#4

Quote:
Originally Posted by Shetch
Посмотреть сообщение
OnPlayerUpdate gets called very frequently each second depending on what the player is doing. This is a quote from the SA-MP wiki:

This could mean that OnPlayerUpdate gets called about 10-50 times in a second while the player is doing something meaning everything you have under OnPlayerUpdate is processed way more than you would possibly need to.

A solution to this is to move all the code you have under OnPlayerUpdate to a timer. This timer could be a single second timer or even a half second timer. Either way, it would be much better for your server's performance to use a timer instead of OnPlayerUpdate.
Give me an example of a similar timer with the OnPlayerUpdate?
Reply
#5

up?!
Reply
#6

Код:
OnGameModeInit()
{
    SetTimer("OnPlayerUpdateEx", 1000, true);
}

foward OnPlayerUpdateEx();
public OnPlayerUpdateEx()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        // Paste the code from you OnPlayerUpdate callback in here.
        // Remember to replace 'playerid' with the iterator 'i'!
    }
}
Reply
#7

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Код:
OnGameModeInit()
{
    SetTimer("OnPlayerUpdateEx", 1000, true);
}

foward OnPlayerUpdateEx();
public OnPlayerUpdateEx()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        // Paste the code from you OnPlayerUpdate callback in here.
        // Remember to replace 'playerid' with the iterator 'i'!
    }
}
Lag?
PHP код:
foward OnPlayerUpdateEx();
public 
OnPlayerUpdateEx()
{
    for(new 
0MAX_PLAYERSi++)
    {
        if (
gPlayerLogged[i])
        {
            new 
string3[32], playername3[MAX_PLAYER_NAME];
            
GetPlayerName(iplayername3sizeof(playername3));
            
format(string3sizeof(string3), "Usuarios/%s.txt"playername3);
            new 
FilehFile fopen(string3io_write);
            if (
hFile)
            {
                new var[
32];
                
format(var,32,"Key=%s\n",PlayerInfo[playerid][pKey]);fwrite(hFile,var);
                
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                
format(var,32,"Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile,var);
                
format(var,32,"Funcao=%s\n",PlayerInfo[playerid][pFuncao]);fwrite(hFile, var);
                
format(var,32,"AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile,var);
                
format(var,32,"AdminStats=%d\n",PlayerInfo[playerid][pAdmDuty]);fwrite(hFile,var);
                
format(var,32,"HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);
                
format(var,32,"Premio=%d\n",PlayerInfo[playerid][pDonateRank]);fwrite(hFile,var);
                
format(var,32,"UpgradePoints=%d\n",PlayerInfo[playerid][gPupgrade]);fwrite(hFile,var);
                
format(var,32,"ConnectedTime=%d\n",PlayerInfo[playerid][pConnectTime]);fwrite(hFile,var);
                
format(var,32,"Capacete=%d\n",PlayerInfo[playerid][pCapacete]);fwrite(hFile,var);
                
format(var,32,"MatouEvento=%d\n",PlayerInfo[playerid][pMatou]);fwrite(hFile,var);
                
format(var,32,"Hospital=%d\n",Hospital[playerid]);fwrite(hFile,var);
                
format(var,32,"Sex=%d\n",PlayerInfo[playerid][pSex]);fwrite(hFile,var);
                
format(var,32,"Age=%d\n",PlayerInfo[playerid][pAge]);fwrite(hFile,var);
                
format(var,32,"Origin=%d\n",PlayerInfo[playerid][pOrigin]);fwrite(hFile,var);
                
format(var,32,"CK=%d\n",PlayerInfo[playerid][pCK]);fwrite(hFile,var);
                   
format(var,32,"Gorro=%d\n",PlayerInfo[playerid][pGorro]);fwrite(hFile,var);
                   
format(var,32,"Chapeu=%d\n",PlayerInfo[playerid][pChapeu]);fwrite(hFile,var);
                
format(var,32,"Muted=%d\n",PlayerInfo[playerid][pMuted]);fwrite(hFile,var);
                
format(var,32,"Respect=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile,var);
                
format(var,32,"Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile,var);
                
format(var,32,"Banco=%d\n",PlayerInfo[playerid][pAccount]);fwrite(hFile,var);
                
format(var,32,"Crimes=%d\n",PlayerInfo[playerid][pCrimes]);fwrite(hFile,var);
                
format(var,32,"Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile,var);
                
format(var,32,"Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile,var);
                
format(var,32,"Arrested=%d\n",PlayerInfo[playerid][pArrested]);fwrite(hFile,var);
                
format(var,32,"Procurado=%d\n",PlayerInfo[playerid][pWantedLevel]);fwrite(hFile,var);
                
format(var,32,"ListaTelefonica=%d\n",PlayerInfo[playerid][pListaTelefonica]);fwrite(hFile,var);
                
format(var,32,"Radio=%d\n",PlayerInfo[playerid][pRadio]);fwrite(hFile,var);
                
format(var,32,"RadioStats=%d\n",PlayerInfo[playerid][pRadioStats]);fwrite(hFile,var);
                
format(var,32,"Pilotar=%d\n",PlayerInfo[playerid][pPilotar]);fwrite(hFile,var);
                
format(var,32,"Loteria=%d\n",PlayerInfo[playerid][pLoteria]);fwrite(hFile,var);
                
format(var,32,"Peixes=%d\n",PlayerInfo[playerid][pFishes]);fwrite(hFile,var);
                
format(var,32,"BiggestPeixe=%d\n",PlayerInfo[playerid][pBiggestPeixe]);fwrite(hFile,var);
                
format(var,32,"Emprego=%d\n",PlayerInfo[playerid][pEmprego]);fwrite(hFile,var);
                
format(var,32,"Salario=%d\n",PlayerInfo[playerid][pSalario]);fwrite(hFile,var);
                
format(var,32,"HeadValue=%d\n",PlayerInfo[playerid][pHeadValue]);fwrite(hFile,var);
                
format(var,32,"Jailed=%d\n",PlayerInfo[playerid][pJailed]);fwrite(hFile,var);
                
format(var,32,"JailTime=%d\n",PlayerInfo[playerid][pJailTime]);fwrite(hFile,var);
                
format(var,32,"Materials=%d\n",PlayerInfo[playerid][pMats]);fwrite(hFile,var);
                
format(var,32,"Drogas=%d\n",PlayerInfo[playerid][pMaconha]);fwrite(hFile,var);
                
format(var,32,"Cocaina=%d\n",PlayerInfo[playerid][pCocaina]);fwrite(hFile,var);
                
format(var,32,"SafeMats=%d\n",PlayerInfo[playerid][pBoxMats]);fwrite(hFile,var);
                
format(var,32,"SafeDrogas=%d\n",PlayerInfo[playerid][pBoxDrogas]);fwrite(hFile,var);
                
format(var,32,"SafeDrogas2=%d\n",PlayerInfo[playerid][pBoxDrogas2]);fwrite(hFile,var);
                
format(var,32,"Leader=%d\n",PlayerInfo[playerid][pLider]);fwrite(hFile,var);
                
format(var,32,"Member=%d\n",PlayerInfo[playerid][pMembro]);fwrite(hFile,var);
                
format(var,32,"FMember=%d\n",PlayerInfo[playerid][pFMember]);fwrite(hFile,var);
                
format(var,32,"Cargo=%d\n",PlayerInfo[playerid][pCargo]);fwrite(hFile,var);
                
format(var,32,"Char=%d\n",PlayerInfo[playerid][pChar]);fwrite(hFile,var);
                
format(var,32,"EquipSkin=%d\n",PlayerInfo[playerid][pEquipSkin]);fwrite(hFile,var);
                
format(var,32,"ContractTime=%d\n",PlayerInfo[playerid][pContractTime]);fwrite(hFile,var);
                
format(var,32,"Painel=%d\n",PlayerInfo[playerid][pStatsPanel]);fwrite(hFile,var);
                
format(var,32,"VeiculoModelo=%d\n",PlayerInfo[playerid][pVeiculoModelo]);fwrite(hFile,var);
                
format(var,32,"DetSkill=%d\n",PlayerInfo[playerid][pDetSkill]);fwrite(hFile,var);
                
format(var,32,"SexSkill=%d\n",PlayerInfo[playerid][pSexSkill]);fwrite(hFile,var);
                
format(var,32,"BoxSkill=%d\n",PlayerInfo[playerid][pBoxSkill]);fwrite(hFile,var);
                
format(var,32,"LawSkill=%d\n",PlayerInfo[playerid][pLawSkill]);fwrite(hFile,var);
                
format(var,32,"MechSkill=%d\n",PlayerInfo[playerid][pMechSkill]);fwrite(hFile,var);
                
format(var,32,"JackSkill=%d\n",PlayerInfo[playerid][pJackSkill]);fwrite(hFile,var);
                
format(var,32,"NewsSkill=%d\n",PlayerInfo[playerid][pNewsSkill]);fwrite(hFile,var);
                
format(var,32,"DrogasSkill=%d\n",PlayerInfo[playerid][pDrogasSkill]);fwrite(hFile,var);
                
format(var,32,"Bilhete=%d\n",PlayerInfo[playerid][pBilhete]);fwrite(hFile,var);
                
format(var,32,"fishesSkill=%d\n",PlayerInfo[playerid][pFishesSkill]);fwrite(hFile,var);
                
format(var,32,"pSHealth=%.1f\n",PlayerInfo[playerid][pSHealth]);fwrite(hFile,var);
                
format(var,32,"Local=%d\n",PlayerInfo[playerid][pLocal]);fwrite(hFile,var);
                
format(var,32,"Model=%d\n",PlayerInfo[playerid][pModel]);fwrite(hFile,var);
                
format(var,32,"PhoneNr=%d\n",PlayerInfo[playerid][pPnumber]);fwrite(hFile,var);
                
format(var,32,"House=%d\n",PlayerInfo[playerid][pPhousekey]);fwrite(hFile,var);
                
format(var,32,"Bizz=%d\n",PlayerInfo[playerid][pPbiskey]);fwrite(hFile,var);
                
format(var,32,"Carro=%d\n",PlayerInfo[playerid][pVeiculo]);fwrite(hFile,var);
                
format(var,32,"Carro2=%d\n",PlayerInfo[playerid][pVeiculo2]);fwrite(hFile,var);
                
format(var,32,"Carro3=%d\n",PlayerInfo[playerid][pVeiculo3]);fwrite(hFile,var);
                
format(var,32,"Carro4=%d\n",PlayerInfo[playerid][pVeiculo4]);fwrite(hFile,var);
                
format(var,32,"Carro5=%d\n",PlayerInfo[playerid][pVeiculo5]);fwrite(hFile,var);
                
format(var,32,"CarLic=%d\n",PlayerInfo[playerid][pVeiculoLic]);fwrite(hFile,var);
                
format(var,32,"MotoLic=%d\n",PlayerInfo[playerid][pMotoLic]);fwrite(hFile,var);
                
format(var,32,"CaminhaoLic=%d\n",PlayerInfo[playerid][pCaminhaoLic]);fwrite(hFile,var);
                
format(var,32,"On‌ibusLic=%d\n",PlayerInfo[playerid][pOnibusLic]);fwrite(hFile,var);
                
format(var,32,"VooLic=%d\n",PlayerInfo[playerid][pVooLic]);fwrite(hFile,var);
                
format(var,32,"BarcoLic=%d\n",PlayerInfo[playerid][pBarcoLic]);fwrite(hFile,var);
                
format(var,32,"PeixeLic=%d\n",PlayerInfo[playerid][pPeixeLic]);fwrite(hFile,var);
                
format(var,32,"GunLic=%d\n",PlayerInfo[playerid][pGunLic]);fwrite(hFile,var);
                
format(var,32,"Gun1=%d\n",PlayerInfo[playerid][pGun1]);fwrite(hFile,var);
                
format(var,32,"Gun2=%d\n",PlayerInfo[playerid][pGun2]);fwrite(hFile,var);
                
format(var,32,"Gun3=%d\n",PlayerInfo[playerid][pGun3]);fwrite(hFile,var);
                
format(var,32,"Gun4=%d\n",PlayerInfo[playerid][pGun4]);fwrite(hFile,var);
                
format(var,32,"Gun5=%d\n",PlayerInfo[playerid][pGun5]);fwrite(hFile,var);
                
format(var,32,"Gun6=%d\n",PlayerInfo[playerid][pGun6]);fwrite(hFile,var);
                
format(var,32,"Gun7=%d\n",PlayerInfo[playerid][pGun7]);fwrite(hFile,var);
                
format(var,32,"Gun8=%d\n",PlayerInfo[playerid][pGun8]);fwrite(hFile,var);
                
format(var,32,"Gun11=%d\n",PlayerInfo[playerid][pGun11]);fwrite(hFile,var);
                
format(var,32,"Gun10=%d\n",PlayerInfo[playerid][pGun10]);fwrite(hFile,var);
                
format(var,32,"Ammo1=%d\n",PlayerInfo[playerid][pAmmo1]);fwrite(hFile,var);
                
format(var,32,"Ammo2=%d\n",PlayerInfo[playerid][pAmmo2]);fwrite(hFile,var);
                
format(var,32,"Ammo3=%d\n",PlayerInfo[playerid][pAmmo3]);fwrite(hFile,var);
                
format(var,32,"Ammo4=%d\n",PlayerInfo[playerid][pAmmo4]);fwrite(hFile,var);
                
format(var,32,"Ammo5=%d\n",PlayerInfo[playerid][pAmmo5]);fwrite(hFile,var);
                
format(var,32,"Ammo6=%d\n",PlayerInfo[playerid][pAmmo6]);fwrite(hFile,var);
                
format(var,32,"Ammo7=%d\n",PlayerInfo[playerid][pAmmo7]);fwrite(hFile,var);
                
format(var,32,"Ammo8=%d\n",PlayerInfo[playerid][pAmmo8]);fwrite(hFile,var);
                
format(var,32,"Ammo11=%d\n",PlayerInfo[playerid][pAmmo11]);fwrite(hFile,var);
                
format(var,32,"Ammo10=%d\n",PlayerInfo[playerid][pAmmo10]);fwrite(hFile,var);
                
format(var,32,"CarTime=%d\n",PlayerInfo[playerid][pCarTime]);fwrite(hFile,var);
                
format(var,32,"AdvogadoTime=%d\n",PlayerInfo[playerid][pAdvogadoTime]);fwrite(hFile,var);
                
format(var,32,"RouboTime=%d\n",PlayerInfo[playerid][pRouboTime]);fwrite(hFile,var);
                
format(var,32,"TimerUm=%d\n",PlayerInfo[playerid][pTimerUm]);fwrite(hFile,var);
                
format(var,32,"ContratoOrg=%d\n",PlayerInfo[playerid][pContOrg]);fwrite(hFile,var);
                
format(var,32,"Conce=%d\n",PlayerInfo[playerid][pConce]);fwrite(hFile,var);
                
format(var,32,"Fome=%d\n",FomePlayer[playerid]);fwrite(hFile,var);
                
format(var,32,"TimeCaixa=%d\n",PlayerInfo[playerid][pTimeCaixa]);fwrite(hFile,var);
                
format(var,32,"PayDay=%d\n",PlayerInfo[playerid][pPayDay]);fwrite(hFile,var);
                
format(var,32,"PayDayHad=%d\n",PlayerInfo[playerid][pPayDayHad]);fwrite(hFile,var);
                
format(var,32,"FGTS=%d\n",PlayerInfo[playerid][pFGTS]);fwrite(hFile,var);
                
format(var,32,"CDPlayer=%d\n",PlayerInfo[playerid][pCDPlayer]);fwrite(hFile,var);
                
format(var,32,"Wins=%d\n",PlayerInfo[playerid][pWins]);fwrite(hFile,var);
                
format(var,32,"Loses=%d\n",PlayerInfo[playerid][pLoses]);fwrite(hFile,var);
                
format(var,32,"AlcoholPerk=%d\n",PlayerInfo[playerid][pAlcoholPerk]);fwrite(hFile,var);
                
format(var,32,"DrugPerk=%d\n",PlayerInfo[playerid][pDrugPerk]);fwrite(hFile,var);
                
format(var,32,"MiserPerk=%d\n",PlayerInfo[playerid][pMiserPerk]);fwrite(hFile,var);
                
format(var,32,"PainPerk=%d\n",PlayerInfo[playerid][pPainPerk]);fwrite(hFile,var);
                
format(var,32,"TraderPerk=%d\n",PlayerInfo[playerid][pTraderPerk]);fwrite(hFile,var);
                
format(var,32,"Tutorial=%d\n",PlayerInfo[playerid][pTut]);fwrite(hFile,var);
                
format(var,32,"Warnings=%d\n",PlayerInfo[playerid][pWarns]);fwrite(hFile,var);
                
format(var,32,"Adjustable=%d\n",PlayerInfo[playerid][pAdjustable]);fwrite(hFile,var);
                
format(var,32,"Combustivel=%d\n",PlayerInfo[playerid][pCombustivel]);fwrite(hFile,var);
                
format(var,32,"Married=%d\n",PlayerInfo[playerid][pMarried]);fwrite(hFile,var);
                
format(var,32,"MarriedTo=%s\n",PlayerInfo[playerid][pMarriedTo]);fwrite(hFile,var);
                
format(var,32,"ContaBan=%d\n",PlayerInfo[playerid][pBanned]);fwrite(hFile,var);
                
format(var,32,"Saque=%d\n",PlayerInfo[playerid][pSaque]);fwrite(hFile,var);
                  
format(var,32,"Moedas=%d\n",PlayerInfo[playerid][pMoedasVIP]);fwrite(hFile,var);
                
format(var,32,"Luta=%d\n",PlayerInfo[playerid][pLuta]);fwrite(hFile,var);
                
format(var,32,"Multas=%d\n",PlayerInfo[playerid][pPrecoMulta]);fwrite(hFile,var);
                
format(var,32,"Ajustado=%d\n",PlayerInfo[playerid][pAjustado]);fwrite(hFile, var);
                
format(var,32,"CasaEntrada=%d\n",PlayerInfo[playerid][pCasaEntrada]);fwrite(hFile, var);
                
fclose(hFile);
            }
        }
    }

Reply
#8

Quote:
Originally Posted by SukMathcuck
Посмотреть сообщение
Lag?
PHP код:
foward OnPlayerUpdateEx();
public 
OnPlayerUpdateEx()
{
    for(new 
0MAX_PLAYERSi++)
    {
        if (
gPlayerLogged[i])
        {
            new 
string3[32], playername3[MAX_PLAYER_NAME];
            
GetPlayerName(iplayername3sizeof(playername3));
            
format(string3sizeof(string3), "Usuarios/%s.txt"playername3);
            new 
FilehFile fopen(string3io_write);
            if (
hFile)
            {
                new var[
32];
                
format(var,32,"Key=%s\n",PlayerInfo[playerid][pKey]);fwrite(hFile,var);
                
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                
format(var,32,"Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile,var);
                
format(var,32,"Funcao=%s\n",PlayerInfo[playerid][pFuncao]);fwrite(hFile, var);
                
format(var,32,"AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile,var);
                
format(var,32,"AdminStats=%d\n",PlayerInfo[playerid][pAdmDuty]);fwrite(hFile,var);
                
format(var,32,"HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);
                
format(var,32,"Premio=%d\n",PlayerInfo[playerid][pDonateRank]);fwrite(hFile,var);
                
format(var,32,"UpgradePoints=%d\n",PlayerInfo[playerid][gPupgrade]);fwrite(hFile,var);
                
format(var,32,"ConnectedTime=%d\n",PlayerInfo[playerid][pConnectTime]);fwrite(hFile,var);
                
format(var,32,"Capacete=%d\n",PlayerInfo[playerid][pCapacete]);fwrite(hFile,var);
                
format(var,32,"MatouEvento=%d\n",PlayerInfo[playerid][pMatou]);fwrite(hFile,var);
                
format(var,32,"Hospital=%d\n",Hospital[playerid]);fwrite(hFile,var);
                
format(var,32,"Sex=%d\n",PlayerInfo[playerid][pSex]);fwrite(hFile,var);
                
format(var,32,"Age=%d\n",PlayerInfo[playerid][pAge]);fwrite(hFile,var);
                
format(var,32,"Origin=%d\n",PlayerInfo[playerid][pOrigin]);fwrite(hFile,var);
                
format(var,32,"CK=%d\n",PlayerInfo[playerid][pCK]);fwrite(hFile,var);
                   
format(var,32,"Gorro=%d\n",PlayerInfo[playerid][pGorro]);fwrite(hFile,var);
                   
format(var,32,"Chapeu=%d\n",PlayerInfo[playerid][pChapeu]);fwrite(hFile,var);
                
format(var,32,"Muted=%d\n",PlayerInfo[playerid][pMuted]);fwrite(hFile,var);
                
format(var,32,"Respect=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile,var);
                
format(var,32,"Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile,var);
                
format(var,32,"Banco=%d\n",PlayerInfo[playerid][pAccount]);fwrite(hFile,var);
                
format(var,32,"Crimes=%d\n",PlayerInfo[playerid][pCrimes]);fwrite(hFile,var);
                
format(var,32,"Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile,var);
                
format(var,32,"Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile,var);
                
format(var,32,"Arrested=%d\n",PlayerInfo[playerid][pArrested]);fwrite(hFile,var);
                
format(var,32,"Procurado=%d\n",PlayerInfo[playerid][pWantedLevel]);fwrite(hFile,var);
                
format(var,32,"ListaTelefonica=%d\n",PlayerInfo[playerid][pListaTelefonica]);fwrite(hFile,var);
                
format(var,32,"Radio=%d\n",PlayerInfo[playerid][pRadio]);fwrite(hFile,var);
                
format(var,32,"RadioStats=%d\n",PlayerInfo[playerid][pRadioStats]);fwrite(hFile,var);
                
format(var,32,"Pilotar=%d\n",PlayerInfo[playerid][pPilotar]);fwrite(hFile,var);
                
format(var,32,"Loteria=%d\n",PlayerInfo[playerid][pLoteria]);fwrite(hFile,var);
                
format(var,32,"Peixes=%d\n",PlayerInfo[playerid][pFishes]);fwrite(hFile,var);
                
format(var,32,"BiggestPeixe=%d\n",PlayerInfo[playerid][pBiggestPeixe]);fwrite(hFile,var);
                
format(var,32,"Emprego=%d\n",PlayerInfo[playerid][pEmprego]);fwrite(hFile,var);
                
format(var,32,"Salario=%d\n",PlayerInfo[playerid][pSalario]);fwrite(hFile,var);
                
format(var,32,"HeadValue=%d\n",PlayerInfo[playerid][pHeadValue]);fwrite(hFile,var);
                
format(var,32,"Jailed=%d\n",PlayerInfo[playerid][pJailed]);fwrite(hFile,var);
                
format(var,32,"JailTime=%d\n",PlayerInfo[playerid][pJailTime]);fwrite(hFile,var);
                
format(var,32,"Materials=%d\n",PlayerInfo[playerid][pMats]);fwrite(hFile,var);
                
format(var,32,"Drogas=%d\n",PlayerInfo[playerid][pMaconha]);fwrite(hFile,var);
                
format(var,32,"Cocaina=%d\n",PlayerInfo[playerid][pCocaina]);fwrite(hFile,var);
                
format(var,32,"SafeMats=%d\n",PlayerInfo[playerid][pBoxMats]);fwrite(hFile,var);
                
format(var,32,"SafeDrogas=%d\n",PlayerInfo[playerid][pBoxDrogas]);fwrite(hFile,var);
                
format(var,32,"SafeDrogas2=%d\n",PlayerInfo[playerid][pBoxDrogas2]);fwrite(hFile,var);
                
format(var,32,"Leader=%d\n",PlayerInfo[playerid][pLider]);fwrite(hFile,var);
                
format(var,32,"Member=%d\n",PlayerInfo[playerid][pMembro]);fwrite(hFile,var);
                
format(var,32,"FMember=%d\n",PlayerInfo[playerid][pFMember]);fwrite(hFile,var);
                
format(var,32,"Cargo=%d\n",PlayerInfo[playerid][pCargo]);fwrite(hFile,var);
                
format(var,32,"Char=%d\n",PlayerInfo[playerid][pChar]);fwrite(hFile,var);
                
format(var,32,"EquipSkin=%d\n",PlayerInfo[playerid][pEquipSkin]);fwrite(hFile,var);
                
format(var,32,"ContractTime=%d\n",PlayerInfo[playerid][pContractTime]);fwrite(hFile,var);
                
format(var,32,"Painel=%d\n",PlayerInfo[playerid][pStatsPanel]);fwrite(hFile,var);
                
format(var,32,"VeiculoModelo=%d\n",PlayerInfo[playerid][pVeiculoModelo]);fwrite(hFile,var);
                
format(var,32,"DetSkill=%d\n",PlayerInfo[playerid][pDetSkill]);fwrite(hFile,var);
                
format(var,32,"SexSkill=%d\n",PlayerInfo[playerid][pSexSkill]);fwrite(hFile,var);
                
format(var,32,"BoxSkill=%d\n",PlayerInfo[playerid][pBoxSkill]);fwrite(hFile,var);
                
format(var,32,"LawSkill=%d\n",PlayerInfo[playerid][pLawSkill]);fwrite(hFile,var);
                
format(var,32,"MechSkill=%d\n",PlayerInfo[playerid][pMechSkill]);fwrite(hFile,var);
                
format(var,32,"JackSkill=%d\n",PlayerInfo[playerid][pJackSkill]);fwrite(hFile,var);
                
format(var,32,"NewsSkill=%d\n",PlayerInfo[playerid][pNewsSkill]);fwrite(hFile,var);
                
format(var,32,"DrogasSkill=%d\n",PlayerInfo[playerid][pDrogasSkill]);fwrite(hFile,var);
                
format(var,32,"Bilhete=%d\n",PlayerInfo[playerid][pBilhete]);fwrite(hFile,var);
                
format(var,32,"fishesSkill=%d\n",PlayerInfo[playerid][pFishesSkill]);fwrite(hFile,var);
                
format(var,32,"pSHealth=%.1f\n",PlayerInfo[playerid][pSHealth]);fwrite(hFile,var);
                
format(var,32,"Local=%d\n",PlayerInfo[playerid][pLocal]);fwrite(hFile,var);
                
format(var,32,"Model=%d\n",PlayerInfo[playerid][pModel]);fwrite(hFile,var);
                
format(var,32,"PhoneNr=%d\n",PlayerInfo[playerid][pPnumber]);fwrite(hFile,var);
                
format(var,32,"House=%d\n",PlayerInfo[playerid][pPhousekey]);fwrite(hFile,var);
                
format(var,32,"Bizz=%d\n",PlayerInfo[playerid][pPbiskey]);fwrite(hFile,var);
                
format(var,32,"Carro=%d\n",PlayerInfo[playerid][pVeiculo]);fwrite(hFile,var);
                
format(var,32,"Carro2=%d\n",PlayerInfo[playerid][pVeiculo2]);fwrite(hFile,var);
                
format(var,32,"Carro3=%d\n",PlayerInfo[playerid][pVeiculo3]);fwrite(hFile,var);
                
format(var,32,"Carro4=%d\n",PlayerInfo[playerid][pVeiculo4]);fwrite(hFile,var);
                
format(var,32,"Carro5=%d\n",PlayerInfo[playerid][pVeiculo5]);fwrite(hFile,var);
                
format(var,32,"CarLic=%d\n",PlayerInfo[playerid][pVeiculoLic]);fwrite(hFile,var);
                
format(var,32,"MotoLic=%d\n",PlayerInfo[playerid][pMotoLic]);fwrite(hFile,var);
                
format(var,32,"CaminhaoLic=%d\n",PlayerInfo[playerid][pCaminhaoLic]);fwrite(hFile,var);
                
format(var,32,"On‌ibusLic=%d\n",PlayerInfo[playerid][pOnibusLic]);fwrite(hFile,var);
                
format(var,32,"VooLic=%d\n",PlayerInfo[playerid][pVooLic]);fwrite(hFile,var);
                
format(var,32,"BarcoLic=%d\n",PlayerInfo[playerid][pBarcoLic]);fwrite(hFile,var);
                
format(var,32,"PeixeLic=%d\n",PlayerInfo[playerid][pPeixeLic]);fwrite(hFile,var);
                
format(var,32,"GunLic=%d\n",PlayerInfo[playerid][pGunLic]);fwrite(hFile,var);
                
format(var,32,"Gun1=%d\n",PlayerInfo[playerid][pGun1]);fwrite(hFile,var);
                
format(var,32,"Gun2=%d\n",PlayerInfo[playerid][pGun2]);fwrite(hFile,var);
                
format(var,32,"Gun3=%d\n",PlayerInfo[playerid][pGun3]);fwrite(hFile,var);
                
format(var,32,"Gun4=%d\n",PlayerInfo[playerid][pGun4]);fwrite(hFile,var);
                
format(var,32,"Gun5=%d\n",PlayerInfo[playerid][pGun5]);fwrite(hFile,var);
                
format(var,32,"Gun6=%d\n",PlayerInfo[playerid][pGun6]);fwrite(hFile,var);
                
format(var,32,"Gun7=%d\n",PlayerInfo[playerid][pGun7]);fwrite(hFile,var);
                
format(var,32,"Gun8=%d\n",PlayerInfo[playerid][pGun8]);fwrite(hFile,var);
                
format(var,32,"Gun11=%d\n",PlayerInfo[playerid][pGun11]);fwrite(hFile,var);
                
format(var,32,"Gun10=%d\n",PlayerInfo[playerid][pGun10]);fwrite(hFile,var);
                
format(var,32,"Ammo1=%d\n",PlayerInfo[playerid][pAmmo1]);fwrite(hFile,var);
                
format(var,32,"Ammo2=%d\n",PlayerInfo[playerid][pAmmo2]);fwrite(hFile,var);
                
format(var,32,"Ammo3=%d\n",PlayerInfo[playerid][pAmmo3]);fwrite(hFile,var);
                
format(var,32,"Ammo4=%d\n",PlayerInfo[playerid][pAmmo4]);fwrite(hFile,var);
                
format(var,32,"Ammo5=%d\n",PlayerInfo[playerid][pAmmo5]);fwrite(hFile,var);
                
format(var,32,"Ammo6=%d\n",PlayerInfo[playerid][pAmmo6]);fwrite(hFile,var);
                
format(var,32,"Ammo7=%d\n",PlayerInfo[playerid][pAmmo7]);fwrite(hFile,var);
                
format(var,32,"Ammo8=%d\n",PlayerInfo[playerid][pAmmo8]);fwrite(hFile,var);
                
format(var,32,"Ammo11=%d\n",PlayerInfo[playerid][pAmmo11]);fwrite(hFile,var);
                
format(var,32,"Ammo10=%d\n",PlayerInfo[playerid][pAmmo10]);fwrite(hFile,var);
                
format(var,32,"CarTime=%d\n",PlayerInfo[playerid][pCarTime]);fwrite(hFile,var);
                
format(var,32,"AdvogadoTime=%d\n",PlayerInfo[playerid][pAdvogadoTime]);fwrite(hFile,var);
                
format(var,32,"RouboTime=%d\n",PlayerInfo[playerid][pRouboTime]);fwrite(hFile,var);
                
format(var,32,"TimerUm=%d\n",PlayerInfo[playerid][pTimerUm]);fwrite(hFile,var);
                
format(var,32,"ContratoOrg=%d\n",PlayerInfo[playerid][pContOrg]);fwrite(hFile,var);
                
format(var,32,"Conce=%d\n",PlayerInfo[playerid][pConce]);fwrite(hFile,var);
                
format(var,32,"Fome=%d\n",FomePlayer[playerid]);fwrite(hFile,var);
                
format(var,32,"TimeCaixa=%d\n",PlayerInfo[playerid][pTimeCaixa]);fwrite(hFile,var);
                
format(var,32,"PayDay=%d\n",PlayerInfo[playerid][pPayDay]);fwrite(hFile,var);
                
format(var,32,"PayDayHad=%d\n",PlayerInfo[playerid][pPayDayHad]);fwrite(hFile,var);
                
format(var,32,"FGTS=%d\n",PlayerInfo[playerid][pFGTS]);fwrite(hFile,var);
                
format(var,32,"CDPlayer=%d\n",PlayerInfo[playerid][pCDPlayer]);fwrite(hFile,var);
                
format(var,32,"Wins=%d\n",PlayerInfo[playerid][pWins]);fwrite(hFile,var);
                
format(var,32,"Loses=%d\n",PlayerInfo[playerid][pLoses]);fwrite(hFile,var);
                
format(var,32,"AlcoholPerk=%d\n",PlayerInfo[playerid][pAlcoholPerk]);fwrite(hFile,var);
                
format(var,32,"DrugPerk=%d\n",PlayerInfo[playerid][pDrugPerk]);fwrite(hFile,var);
                
format(var,32,"MiserPerk=%d\n",PlayerInfo[playerid][pMiserPerk]);fwrite(hFile,var);
                
format(var,32,"PainPerk=%d\n",PlayerInfo[playerid][pPainPerk]);fwrite(hFile,var);
                
format(var,32,"TraderPerk=%d\n",PlayerInfo[playerid][pTraderPerk]);fwrite(hFile,var);
                
format(var,32,"Tutorial=%d\n",PlayerInfo[playerid][pTut]);fwrite(hFile,var);
                
format(var,32,"Warnings=%d\n",PlayerInfo[playerid][pWarns]);fwrite(hFile,var);
                
format(var,32,"Adjustable=%d\n",PlayerInfo[playerid][pAdjustable]);fwrite(hFile,var);
                
format(var,32,"Combustivel=%d\n",PlayerInfo[playerid][pCombustivel]);fwrite(hFile,var);
                
format(var,32,"Married=%d\n",PlayerInfo[playerid][pMarried]);fwrite(hFile,var);
                
format(var,32,"MarriedTo=%s\n",PlayerInfo[playerid][pMarriedTo]);fwrite(hFile,var);
                
format(var,32,"ContaBan=%d\n",PlayerInfo[playerid][pBanned]);fwrite(hFile,var);
                
format(var,32,"Saque=%d\n",PlayerInfo[playerid][pSaque]);fwrite(hFile,var);
                  
format(var,32,"Moedas=%d\n",PlayerInfo[playerid][pMoedasVIP]);fwrite(hFile,var);
                
format(var,32,"Luta=%d\n",PlayerInfo[playerid][pLuta]);fwrite(hFile,var);
                
format(var,32,"Multas=%d\n",PlayerInfo[playerid][pPrecoMulta]);fwrite(hFile,var);
                
format(var,32,"Ajustado=%d\n",PlayerInfo[playerid][pAjustado]);fwrite(hFile, var);
                
format(var,32,"CasaEntrada=%d\n",PlayerInfo[playerid][pCasaEntrada]);fwrite(hFile, var);
                
fclose(hFile);
            }
        }
    }

What??
Reply
#9

Quote:
Originally Posted by Shetch
Посмотреть сообщение
What??
Thus above may have lag? it saves the player's account every 1 second, just pulled it from OnPlayerUpdate, the "playerid" changed to "i" .. please ...
Reply
#10

This code is terrible. No wonder why your server lags.

Not only to mention about how slow fwrite is compared to MySQL but you also push it out of the limit. You can't just save 50 variables each second and expect your server to have a good performance.

If you're looking to improve this a bit, try to save player stats each 10 minutes and for each player separately. When the player logins to his account set a repeating timer each 10 minutes and do the above code you do. Although this way might not be the best, it's still better then what you're/were going to do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)