SA-MP Forums Archive
strcmp - 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: strcmp (/showthread.php?tid=331750)



strcmp - Cowboy - 05.04.2012

I get an incorrect password even if the password is correct. Password's hash prints the correct output which is in the file, I think I am using strcmp wrong.

pawn Код:
case 2:
        {
            if(!response)
            {
                Kick(playerid);
            }
            else
            {
                new buf[129];
                INI_ParseFile(UserPath(playerid), "LoadUserData_%s", .bExtra = true, .extra = playerid);
                WP_Hash(buf, sizeof (buf), inputtext);
                if(strcmp(PlayerInfo[playerid][pPassword], buf, true))
                {
                    SendClientMessage(playerid, Green, "Logged");
                }
                else
                {
                    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account", "Login to your account\n\nWrong password\n\nEnter your password:", "Login", "Quit");
                }
                printf("Password: %s | %s", buf, inputtext);
                return 1;
            }
        }
Please help.


Re: strcmp - [HiC]TheKiller - 05.04.2012

strcmp returns 0 rather than 1 if the strings match.


Re: strcmp - Toreno - 05.04.2012

pawn Код:
if(!strcmp(PlayerInfo[playerid][pPassword], buf, false))



Re: strcmp - Cowboy - 05.04.2012

Toreno, now it logs me in even if the password is incorrect.


Re: strcmp - BlackBank - 05.04.2012

Код:
if(strcmp(inputtext, buf, true) == 0)
EDIT:
My fault, can you print PlayerInfo[playerid][pPassword], and check if it is encrypted/hashed.


Re: strcmp - Cowboy - 05.04.2012

It is empty, and that piece of line didn't work.


Re: strcmp - BlackBank - 05.04.2012

Quote:
Originally Posted by Cowboy
Посмотреть сообщение
It is empty, and that piece of line didn't work.
You have saved the hashed password into your ini account?


Re: strcmp - Cowboy - 05.04.2012

Yes, it is written correctly and this: printf("Password: %s | %s", buf, inputtext); prints out the exact same string as in the file.


Re: strcmp - BlackBank - 05.04.2012

But if you print this:
Код:
printf("PlayerInfo[Password]: %s", PlayerInfo[playerid][pPassword]);
Does it says that pPassword is empty?


Re: strcmp - Cowboy - 05.04.2012

Yes, do you want me to show how I load the password?