Password Problem [REP++]
#1

Hello, i have some problem users passwords just dissapear and you can login with whatever account.
When i open user folder in server files key aka passwords is like this key= then nothing no password.
All others files are good in user.ini but only password dissapears you can just /account changepassword and set new then it will be there sometime and then will be dissapear again.

pawn Код:
enum pInfo
{
    pKey[128],
    other enums down.
};
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
            new string3[64];
            new string[128];
            new playername3[MAX_PLAYER_NAME];
            new playersip[24];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            GetPlayerIp(playerid, playersip, sizeof(playersip));
            format(string3, sizeof(string3), "ERP/Users/%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
                new var[176];
                format(var, 128, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
                format(var, 128, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 128, "Spawn=%d\n",PlayerInfo[playerid][pSpawn]);fwrite(hFile, var);
                fclose(hFile);
                ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_PASSWORD,"Welcome, Please Login","Account successfully Registered in our datebase!\nWrite your password down in order to Login","Log-in","Quit");
                new y, m, d;
                new h,mi,s;
                getdate(y,m,d);
                gettime(h,mi,s);
                format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has registred in under IP %s.",d,m,y,h,mi,s,playername3,playersip);
                LoginLog(string);
            }
    }
    return 1;
}
pawn Код:
public OnPlayerUpdateEx(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
        {
            new string3[64];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "ERP/Users/%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                new var[176];
                format(var, 128, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
                format(var, 128, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    }
    return 1;
}

pawn Код:
public OnPlayerLogin(playerid,password[])
{
    new tmp2[256];
    new string2[64];
    new string[128];
    new playersip[24];
    new playername2[MAX_PLAYER_NAME];
    new playernamesplit[3][MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    GetPlayerIp(playerid, playersip, sizeof(playersip));
    split(playername2, playernamesplit, '_');
    format(string2, sizeof(string2), "ERP/Users/%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 , "Spawn" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSpawn] = strval( val ); }
                }
                fclose(UserFile);
        }
        else
        {
            fclose(UserFile);
            gPlayerLogTries[playerid] += 1;
            ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_PASSWORD,"Try again, Please Log-In","Wrong password\nWrite your pasword down in order to Log-In","Log-in","Quit");
            if(gPlayerLogTries[playerid] == 3) { SetTimerEx("KickPlayerOut",500,false,"i",playerid); }
            return 1;
        }
        new y, m, d;
        new h,mi,s;
        getdate(y,m,d);
        gettime(h,mi,s);
        format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has logged in under IP %s.",d,m,y,h,mi,s,playername2,playersip);
        LoginLog(string);
    }
    return 1;
}
and stock to getkey

pawn Код:
stock ini_GetKey( line[] )
{
    new keyRes[256];
    keyRes[0] = 0;
    if ( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
}
Reply
#2

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
When i open user folder in server files key aka passwords is like this key= then nothing no password.
So you should show us your registering codes not log in
Reply
#3

Quote:
Originally Posted by amirab
Посмотреть сообщение
So you should show us your registering codes not log in
I gave it already

pawn Код:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
            new string3[64];
            new string[128];
            new playername3[MAX_PLAYER_NAME];
            new playersip[24];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            GetPlayerIp(playerid, playersip, sizeof(playersip));
            format(string3, sizeof(string3), "ERP/Users/%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
                new var[176];
                format(var, 128, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
                format(var, 128, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 128, "Spawn=%d\n",PlayerInfo[playerid][pSpawn]);fwrite(hFile, var);
                fclose(hFile);
                ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_PASSWORD,"Welcome, Please Login","Account successfully Registered in our datebase!\nWrite your password down in order to Login","Log-in","Quit");
                new y, m, d;
                new h,mi,s;
                getdate(y,m,d);
                gettime(h,mi,s);
                format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has registred in under IP %s.",d,m,y,h,mi,s,playername3,playersip);
                LoginLog(string);
            }
    }
    return 1;
}
Reply
#4

Well obviously you have to show us the dialog once the player responds with your "Log-in" button.

EDIT: Nvm you edited your first post.
Reply
#5

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Well obviously you have to show us the dialog once the player responds with your "Log-in" button.

EDIT: Nvm you edited your first post.
I didnt edit first post it was there i allready did posted it.
You have all infos about registration/login i guess
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)