Ajuda pesa muito o GM
#1

Galera queria um ajuda aki tipo o meu gm tem o registro e login do thug que eu tirei so que eli pesa muito na hora de salvar e carregar
da uma olhada ai '.'
pawn Код:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
            new string3[32];
            new playername3[MAX_PLAYER_NAME];
            new plname[MAX_PLAYER_NAME];
            new string[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
                new var[32];
                PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
                format(var, 32, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
                format(var, 32, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
                format(var, 32, "SocioLevel=%d\n",PlayerInfo[playerid][pSocio]);fwrite(hFile, var);
                format(var, 32, "Registered=%d\n",PlayerInfo[playerid][pReg]);fwrite(hFile, var);
                format(var, 32, "Suicideo=%d\n",PlayerInfo[playerid][pSematou]);fwrite(hFile, var);
                format(var, 32, "Matou=%d\n",PlayerInfo[playerid][pMatou]);fwrite(hFile, var);
                format(var, 32, "Morreu=%d\n",PlayerInfo[playerid][pMorreu]);fwrite(hFile, var);
                format(var, 32, "Dominou=%d\n",PlayerInfo[playerid][pDominou]);fwrite(hFile, var);
                format(var, 32, "TK=%d\n",PlayerInfo[playerid][pTeamkill]);fwrite(hFile, var);
                format(var, 32, "Vip=%d\n",PlayerInfo[playerid][pVip]);fwrite(hFile, var);
                format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
                format(var, 32, "Score=%d\n",PlayerInfo[playerid][pScore]);fwrite(hFile, var);
                fclose(hFile);
                SendClientMessage(playerid, 0x4847FFAA, "Conta registrada digite : (/logar (Senha)).");
                if(gPlayerLogged[playerid] == 0)
                {
                GetPlayerName(playerid, plname, sizeof(plname));
                format(string, sizeof(string), "%s.ini", plname);
                if(fexist(string))
                {
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Brasil Combate KIller's\nDigite sua Senha para Logar!", "Logar", "Sair");
                }
                return 1;
              }
         }
    return 1;
}
public OnPlayerLogin(playerid,password[])
{
    new tmp2[256];
    new string2[64];
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), "%s.ini", playername2);
    new File: UserFile = fopen(string2, io_read);
    if ( UserFile )
    {
        new PassData[256];
        new keytmp[256], valtmp[256];
        fread( UserFile , PassData , sizeof( PassData ) );
        keytmp = ini_GetKey( PassData );
        if( strcmp( keytmp , "Key" , true ) == 0 )
        {
            valtmp = ini_GetValue( PassData );
            strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
        }
        if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
        {
                new key[ 256 ] , val[ 256 ];
                new Data[ 256 ];
                while ( fread( UserFile , Data , sizeof( Data ) ) )
                {
                    key = ini_GetKey( Data );
                    if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
                    if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
                    if( strcmp( key , "AdmBrasil" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSocio] = strval( val ); }
                    if( strcmp( key , "SocioLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSocio] = strval( val ); }
                    if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pReg] = strval( val ); }
                    if( strcmp( key , "Suicideo" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSematou] = strval( val ); }
                    if( strcmp( key , "Matou" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMatou] = strval( val ); }
                    if( strcmp( key , "Morreu" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMorreu] = strval( val ); }
                    if( strcmp( key , "Dominou" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDominou] = strval( val ); }
                    if( strcmp( key , "TK" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pTeamkill] = strval( val ); }
                    if( strcmp( key , "Vip" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pVip] = strval( val ); }
                    if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
                    if( strcmp( key , "Score" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pScore] = strval( val ); }
                    logouagora[playerid] = 1;
                }//end while
                fclose(UserFile);//close the file after everything has been read in the while
        }
        else
        {
            new string[156];
            if(fexist(string))
            {
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Brasil Combate KIller's\nDigite sua Senha para Logar!", "Logar", "Sair");
            }
            SendClientMessage(playerid, 0xFFF540AA, "Senha errada! - Se errar a senha 3 vezes й Kick.");
            fclose(UserFile);
            gPlayerLogTries[playerid] += 1;
            if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
            return 1;
        }
        if(PlayerInfo[playerid][pReg] == 0)
        {
            PlayerInfo[playerid][pLevel] = 2;
            PlayerInfo[playerid][pPos_x] = 2246.6;
            PlayerInfo[playerid][pPos_y] = -1161.9;
            PlayerInfo[playerid][pPos_z] = 1029.7;
            PlayerInfo[playerid][pReg] = 1;
        }
        ResetPlayerMoney(playerid);
        format(string2, sizeof(string2), "Bem vindo %s",playername2);
        SendClientMessage(playerid, 0x4847FFAA,string2);
        printf("%s Foi Logado.",playername2);
        format(string2, sizeof(string2), "~y~Bem Vindo ~n~~b~%s.", playername2);
        GameTextForPlayer(playerid, string2, 5000, 1);
        gPlayerLogged[playerid] = 1;
//      SpawnPlayer(playerid);
        format(tmp2, sizeof(tmp2), "~p~Bem vindo ~n~~b~   %s", playername2);
        GameTextForPlayer(playerid, tmp2, 5000, 1);
        SendClientMessage(playerid, 0xFFF540AA, motd);
        TempoLogin = SetTimerEx("LoginAgora", 10000, 0, "i", playerid);
        ApplyAnimation(playerid, "Dancing", "Dan_Loop_A", 5.0, 1, 0, 0, 0, 0);
    }
    return 1;
}
public OnPlayerUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
        {
            new string3[32];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                new var[32];
                PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
                format(var, 32, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
                format(var, 32, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
                format(var, 32, "SocioLevel=%d\n",PlayerInfo[playerid][pSocio]);fwrite(hFile, var);
                format(var, 32, "Registered=%d\n",PlayerInfo[playerid][pReg]);fwrite(hFile, var);
                format(var, 32, "Morreu=%d\n",PlayerInfo[playerid][pMorreu]);fwrite(hFile, var);
                format(var, 32, "Matou=%d\n",PlayerInfo[playerid][pMatou]);fwrite(hFile, var);
                format(var, 32, "Suicideo=%d\n",PlayerInfo[playerid][pSematou]);fwrite(hFile, var);
                format(var, 32, "Dominou=%d\n",PlayerInfo[playerid][pDominou]);fwrite(hFile, var);
                format(var, 32, "TK=%d\n",PlayerInfo[playerid][pTeamkill]);fwrite(hFile, var);
                format(var, 32, "Vip=%d\n",PlayerInfo[playerid][pVip]);fwrite(hFile, var);
                format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
                format(var, 32, "Score=%d\n",PlayerInfo[playerid][pScore]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    return 1;
}
Tem jeito de salvar outra forma que nao pese tanto ? mais salvar os dados e pode deligar e ligar o server denovo e fica salvo os dados ou intao de tirar um pouco de peso aki?
vlw eu tentei mais so sei que salva mais se reinicciar volta ao normal
Reply
#2

bom, usa esse que o speli fez usando pgd e psf:


Speli Sistema de registro simples [SSRS]


Bem, criei este pequeno e simples filterscript, com o intuito inicial de ajudar quem ainda tem problemas para entender como fazer um sistema de registro para salvar dados. Usei o include PGD (Protioso Gerenciamento de Dados) para o salvamento de dados e um pouco do PSF (Protioso String Funзхes) para codificar senhas e outras coisas.


Versгo 1.0 - Ele й bem simples, sу salva a quantidade de vezes que o player morreu, matou e salva suas armas.

Versгo 1.5a - Adicionado salvamento de Dinheiro, Score, Vida, Colete e a Skin do jogador. Agora ele salva as informaзхes tambйm a cada 2 minutos! Evitando assim, a perda de dados caso o servidor crash, ou algo do tipo.

Funзхes do FS
pawn Код:
native ArquivoJogador(playerid);
native SalvarDados(playerid);
native CarregarArmas(playerid);
native LogarJogador(playerid);
native RegistrarJogador(playerid, senha[]);
Links:
PSF http://forum.sa-mp.com/index.php?topic=132830.0

PGD http://forum.sa-mp.com/index.php?topic=132831.0

Download: Versгo 1.5a(Atual) http://solidfiles.com/d/63yB/
Reply
#3

vlw pela forзa '.' mais eu passei pra um Filter
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)