Can't load the password
#1

pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    //new strLoc[8];
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("IP",PlayerInfo[playerid][IP]);
    INI_Int( "weaponSlot0", weapons[playerid][0][0]);
    INI_Int( "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_Int( "weaponSlot1", weapons[playerid][1][0]);
    INI_Int( "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_Int( "weaponSlot2", weapons[playerid][2][0]);
    INI_Int( "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_Int( "weaponSlot3", weapons[playerid][3][0]);
    INI_Int( "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_Int( "weaponSlot4", weapons[playerid][4][0]);
    INI_Int( "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_Int( "weaponSlot5", weapons[playerid][5][0]);
    INI_Int( "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_Int( "weaponSlot6", weapons[playerid][6][0]);
    INI_Int( "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_Int( "weaponSlot7", weapons[playerid][7][0]);
    INI_Int( "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_Int( "weaponSlot8", weapons[playerid][8][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_Int( "weaponSlot9", weapons[playerid][9][0]);
    INI_Int( "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_Int( "weaponSlot10", weapons[playerid][10][0]);
    INI_Int( "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_Int( "weaponSlot11", weapons[playerid][11][0]);
    INI_Int( "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_Int( "weaponSlot12", weapons[playerid][12][0]);
    INI_Int( "weaponSlot12Ammo", weapons[playerid][12][1]);
    return 1;
}
OnPlayerConnect
pawn Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLW"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""CLW"Registering...",""CLW"Type your password below to register a new account.","Register","Quit");
    }
OnDialog
pawn Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                new ip;
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""CLW"Registering...",""CLR"You have entered an invalid password.\n"CLW"Type your password below to register a new account.","Register","Quit");
                ip = GetPlayerIp(playerid, PlayerInfo[playerid][IP], 16);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"PlayerData");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",ip);
                INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
                INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
                INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
                INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
                INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
                INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
                INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
                INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
                INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
                INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
                INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
                INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
                INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
                INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
                INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
                INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
                INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
                INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
                INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
                INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
                INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
                INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
                INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
                INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
                INI_Close(File);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX,""CLW"Success!",""CLG"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLR"You have entered an incorrect password.\n"CLW"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
pawn Код:
forward SavePlayer(playerid);
public SavePlayer(playerid)
{
    //new strLoc[8];
    new INI:File = INI_Open(UserPath(playerid));
    for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteString(File,"IP", PlayerInfo[playerid][IP]);
    INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
    INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
    INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
    INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
    INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
    INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
    INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
    INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
    INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
    INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
    INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
    INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
    INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
    INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
    INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
    INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
    INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
    INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
    INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
    INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
    INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
    INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
    INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
    INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
    INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
    INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
    INI_Close(File);
}
OnPlayerDisconnect
pawn Код:
SavePlayer(playerid);
When I register a new account then logout, and when i login back, it says wrong password, any fix? I'm using Y_INI.
Would be nice if someone could tell me how to change udb_hash to whirlpool
Reply
#2

Put this under your includes - Above public OnGameModeInit or OnFilterScriptInit
pawn Код:
native WP_Hash(buffer[], len, const str[]);
Edit your enum pInfo
pawn Код:
pPass[129]
public LoadUserdata:
pawn Код:
INI_String("Password",PlayerInfo[playerid][pPass],129);
Your dialogs
pawn Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                new ip,hashpass[129]
                WP_Hash(hashpass,sizeof(hashpass),inputtext);;
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""CLW"Registering...",""CLR"You have entered an invalid password.\n"CLW"Type your password below to register a new account.","Register","Quit");
                ip = GetPlayerIp(playerid, PlayerInfo[playerid][IP], 16);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"PlayerData");
                INI_WriteString(File,"Password",hashpass);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",ip);
                INI_WriteInt(File, "weaponSlot0", weapons[playerid][0][0]);
                INI_WriteInt(File, "weaponSlot0Ammo", weapons[playerid][0][1]);
                INI_WriteInt(File, "weaponSlot1", weapons[playerid][1][0]);
                INI_WriteInt(File, "weaponSlot1Ammo", weapons[playerid][1][1]);
                INI_WriteInt(File, "weaponSlot2", weapons[playerid][2][0]);
                INI_WriteInt(File, "weaponSlot2Ammo", weapons[playerid][2][1]);
                INI_WriteInt(File, "weaponSlot3", weapons[playerid][3][0]);
                INI_WriteInt(File, "weaponSlot3Ammo", weapons[playerid][3][1]);
                INI_WriteInt(File, "weaponSlot4", weapons[playerid][4][0]);
                INI_WriteInt(File, "weaponSlot4Ammo", weapons[playerid][4][1]);
                INI_WriteInt(File, "weaponSlot5", weapons[playerid][5][0]);
                INI_WriteInt(File, "weaponSlot5Ammo", weapons[playerid][5][1]);
                INI_WriteInt(File, "weaponSlot6", weapons[playerid][6][0]);
                INI_WriteInt(File, "weaponSlot6Ammo", weapons[playerid][6][1]);
                INI_WriteInt(File, "weaponSlot7", weapons[playerid][7][0]);
                INI_WriteInt(File, "weaponSlot7Ammo", weapons[playerid][7][1]);
                INI_WriteInt(File, "weaponSlot8", weapons[playerid][8][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][8][1]);
                INI_WriteInt(File, "weaponSlot9", weapons[playerid][9][0]);
                INI_WriteInt(File, "weaponSlot8Ammo", weapons[playerid][9][1]);
                INI_WriteInt(File, "weaponSlot10", weapons[playerid][10][0]);
                INI_WriteInt(File, "weaponSlot10Ammo", weapons[playerid][10][1]);
                INI_WriteInt(File, "weaponSlot11", weapons[playerid][11][0]);
                INI_WriteInt(File, "weaponSlot11Ammo", weapons[playerid][11][1]);
                INI_WriteInt(File, "weaponSlot12", weapons[playerid][12][0]);
                INI_WriteInt(File, "weaponSlot12Ammo", weapons[playerid][12][1]);
                INI_Close(File);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
        new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!strcmp(hashpass, PlayerInfo[playerid][pPass], false))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX,""CLW"Success!",""CLG"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""CLW"Login",""CLR"You have entered an incorrect password.\n"CLW"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
When running the server, Include Whirlpool plugin in your server.cfg, otherwise it won't work.
Hope it works,
Good luck!
Reply
#3

Edit: biker answered before me,by the way mine was better.. if you need help tell me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)