Problem with DIALOG_LOGIN
#1

Hello, my problem today is that my Login script won't accept any password, it just returns the incorrect password message.

pawn Код:
case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                new password[256];
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Server Registration","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                WP_Hash(password, sizeof(password), inputtext);
                INI_WriteString(File,"Password",password);
                INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash] = 5000);//$5000 at registration
                INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin] = 0);
                INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills] = 0);
                INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths] = 0);
                for(new i; i < 12; i++)
                {
                    new var[10];
                    format(var,sizeof(var),"Weapon%d", i);
                    INI_WriteInt(File,var,PlayerInfo[playerid][pWeapon][i] = 0);
                }
                for(new i; i < 12; i++)
                {
                    new var[10];
                    format(var,sizeof(var),"Ammo%d", i);
                    INI_WriteInt(File,var,PlayerInfo[playerid][pAmmo][i] = 0);
                }
                INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths] = 0);
                INI_WriteString(File,"Origin",PlayerInfo[playerid][pOrigin]);
                INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTutorial] = 0);
                INI_WriteInt(File,"Mask",PlayerInfo[playerid][pMask] = 0);
                INI_WriteString(File,"Flag",PlayerInfo[playerid][pFlag]);
                INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator] = 0);
                INI_WriteInt(File,"Watch",PlayerInfo[playerid][pWatch] = 0);
                INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge] = 0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Immigration","Welcome to the Republic of San Andreas\nPlease answer a few questions to become a Legal Citizen.","Ok","Quit");
            }
        }

        case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                new HashedPassword[256];
                WP_Hash(HashedPassword, sizeof(HashedPassword), inputtext);
                if(!strcmp(PlayerInfo[playerid][pPass], HashedPassword))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    OnPlayerLogin(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
        ....
Reply
#2

Why would you use WP_Hash on login dialog?
Use WP_Hash only when player register to save hashed password.

What you are trying to do now is when player enter a password in login box, hash it and then compare it with one in the file.
Reply
#3

Quote:
Originally Posted by Rockk
Посмотреть сообщение
Why would you use WP_Hash on login dialog?
Use WP_Hash only when player register to save hashed password.
I'm using WP_Hash to compare the hashed password in that is in the file.
Reply
#4

Quote:
Originally Posted by seanny
Посмотреть сообщение
I'm using WP_Hash to compare the hashed password in that is in the file.
WP_Hash doesen't return always the same hashed string.

Try remove it and login to see if it works without it.
Reply
#5

Quote:
Originally Posted by Rockk
Посмотреть сообщение
WP_Hash doesen't return always the same hashed string.

Try remove it and login to see if it works without it.
It won't work, trust me, it'll never work.
Reply
#6

What is the value of PlayerInfo[playerid][pPass] when player connects?
Reply
#7

Quote:
Originally Posted by Rockk
Посмотреть сообщение
What is the value of PlayerInfo[playerid][pPass] when player connects?
129. (which is the size Whirl Pool needs to be effective)
Reply
#8

Make sure that pPass is hashed. Otherwise make sure the password you enter is case-sensitive.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)