SA-MP Forums Archive
Error password when login using y_ini - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Error password when login using y_ini (/showthread.php?tid=513335)



Error password when login using y_ini - Deviant96 - 15.05.2014

It would not login if I enter the right or wrong password (Showing dialog incorrect password).

I'm also doing a debug. It's look like it's not loading user's data when a user is connected. Here u can see

First we're on OnPlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
        printf("Password check : %d",PlayerInfo[playerid][Password]); //This is my debug code. This should displaying password, right?
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}
Then it's going here
pawn Код:
case DIALOG_LOGIN: //for loging
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SetSpawnInfo(playerid,-1,1,2000.6132,1560.1454,15.3672,0.7534,0,0,0,0,0,0);
                    SpawnPlayer(playerid);
                    SetPlayerMoneyEx(playerid, PlayerInfo[playerid][Money]);
                    SetPlayerScoreEx(playerid, PlayerInfo[playerid][Score]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                    return 1;
                }
            }
        }
Next, it load this
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][Password]);
    INI_Int("Score",PlayerInfo[playerid][Score]);
    INI_Int("Money",PlayerInfo[playerid][Money]);
    INI_Int("Skin",PlayerInfo[playerid][Skin]);
    INI_Int("Money",PlayerInfo[playerid][Money]);
    INI_Int("Language",PlayerInfo[playerid][Language]);
    INI_Int("Admin",PlayerInfo[playerid][Admin]);
    INI_Int("DMKills",PlayerInfo[playerid][DMKills]);
    INI_Int("DMDeaths",PlayerInfo[playerid][DMDeaths]);
    INI_Int("OWin",PlayerInfo[playerid][OWin]);
    INI_Int("OLoose",PlayerInfo[playerid][OLoose]);
    INI_Int("RWin",PlayerInfo[playerid][RWin]);
    INI_Int("RLoose",PlayerInfo[playerid][RLoose]);
    INI_Int("VIP",PlayerInfo[playerid][VIP]);
    INI_Int("TimeOnline",PlayerInfo[playerid][TimeOnline]);
    INI_Int("Warns",PlayerInfo[playerid][Warns]);
    INI_Int("Banned",PlayerInfo[playerid][Banned]);
    INI_Int("IP",PlayerInfo[playerid][IP]);
    return 1;
}



Re: Error password when login using y_ini - Beckett - 15.05.2014

pawn Код:
printf("Password check : %d",PlayerInfo[playerid][Password]); //This is my debug code. This should displaying password, right?
It wont disable the password it will disable the HASHED one since you're hashing it.


Re: Error password when login using y_ini - Affan - 16.05.2014

Note: I'm using whirlpool.

pawn Код:
forward GetPassword(playerid, name[], value[]);
public GetPassword(playerid, name[], value[])
{
  INI_String("Password", PlayerInfo[playerid][Password],129);
  return 1;
}
pawn Код:
if( response )
{
    INI_ParseFile(Path(playerid), "GetPassword", .bExtra = true, .extra = playerid);
    new hashpass[129];
    WP_Hash(hashpass,sizeof(hashpass),inputtext);
    if(!strcmp(hashpass, PlayerInfo[playerid][Password], true))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        SetSpawnInfo(playerid,-1,1,2000.6132,1560.1454,15.3672,0.7534,0,0,0,0,0,0);
        SpawnPlayer(playerid);
        SetPlayerMoneyEx(playerid, PlayerInfo[playerid][Money]);
        SetPlayerScoreEx(playerid, PlayerInfo[playerid][Score]);
        ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
        return 1;
    }
}
Use whirlpool. It's more safer than udb_hash