strcmp not working. Y_INI Saved Pass.
#1

I load password here :
pawn Код:
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
    PlayerInfo[playerid][Pass] = 0;
    PlayerInfo[playerid][Kills] = 0;
    PlayerInfo[playerid][Score] = 0;
    PlayerInfo[playerid][Team] = 0;
    PlayerInfo[playerid][Skin] = 0;
    PlayerInfo[playerid][W][0] = 0;
    PlayerInfo[playerid][W][1] = 0;
    PlayerInfo[playerid][W][2] = 0;
    PlayerInfo[playerid][W][3] = 0;
    PlayerInfo[playerid][A][0] = 0;
    PlayerInfo[playerid][A][1] = 0;
    PlayerInfo[playerid][A][2] = 0;
    PlayerInfo[playerid][A][3] = 0;
    INI_String("Pass", PlayerInfo[playerid][Pass], 300);
    INI_Int("Kills", PlayerInfo[playerid][Kills]);
    INI_Int("Score", PlayerInfo[playerid][Score]);
    INI_Int("Team", PlayerInfo[playerid][Team]);
    INI_Int("Skin", PlayerInfo[playerid][Skin]);
    INI_Int("W1", PlayerInfo[playerid][W][0]);
    INI_Int("W2", PlayerInfo[playerid][W][1]);
    INI_Int("W3", PlayerInfo[playerid][W][2]);
    INI_Int("W4", PlayerInfo[playerid][W][3]);
    INI_Int("A1", PlayerInfo[playerid][A][0]);
    INI_Int("A1", PlayerInfo[playerid][A][1]);
    INI_Int("A3", PlayerInfo[playerid][A][2]);
    INI_Int("A4", PlayerInfo[playerid][A][3]);
    return 1;
}
And then when checking for it here :
pawn Код:
case DIALOG_LOGIN:
        {
            if(!response) Kick(playerid);
            new password[300];
            WP_Hash(password, 300, inputtext);
            if(strcmp(PlayerInfo[playerid][Pass], password, true, sizeof(password)) == 0)
            {
                if(PlayerInfo[playerid][Team] == 0)
                {
                    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], 2495.2119, -1687.0591, 13.5148, 3.5209, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                    SetPlayerTeam(playerid, 0);
                    SetPlayerColor(playerid, COLOR_GREEN);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][0], PlayerInfo[playerid][A][0]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][1], PlayerInfo[playerid][A][1]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][2], PlayerInfo[playerid][A][2]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][3], PlayerInfo[playerid][A][3]);
                    return 1;
                }
                else if(PlayerInfo[playerid][Team] == 1)
                {
                    SetSpawnInfo(playerid, 1, PlayerInfo[playerid][Skin], 1080.7883, -1744.3995, 13.4606, 0.1209, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                    SetPlayerTeam(playerid, 1);
                    SetPlayerColor(playerid, COLOR_VIOLET);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][0], PlayerInfo[playerid][A][0]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][1], PlayerInfo[playerid][A][1]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][2], PlayerInfo[playerid][A][2]);
                    GivePlayerWeapon(playerid, PlayerInfo[playerid][W][3], PlayerInfo[playerid][A][3]);
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "Wrong Password, You Have Been Kicked");
                Kick(playerid);
                return 1;
            }
        }
I spawn even if the password is wrong, What's the wrong ?
Reply
#2

u spawn but does it kick you?
Reply
#3

Nope
Reply
#4

I'll assume it doesn't load the password correctly and it's empty so strcmp returns 0 (that they're same).

Debug it:
pawn Код:
printf("PlayerInfo[playerid][Pass]: \"%s\" & password: \"%s\"", PlayerInfo[playerid][Pass], password);
if(strcmp(PlayerInfo[playerid][Pass], password, true, sizeof(password)) == 0)
Reply
#5

Why do you set variables to 0 and then load them?
Reply
#6

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
u spawn but does it kick you?
Its fixed now, IDK what was wrong, I just rewrited the code.
But there is other problem, When reading the hash from the file, I get the hash without the last character for example :


Quote:

Saved Pass : 344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BB D1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB4 48194B9305311AFF038A834A079

Quote:

Entered Pass : 344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BB D1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB4 48194B9305311AFF038A834A079F

Please note that the above passwords are encrypted.
Reply
#7

Bump, Please help !!!
Reply
#8

Are you sure that when a player registers, you don't use WP_Hash with size of 299 instead of 300?

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
Bump, Please help !!!
It's against the forum rules to bump within 24 hours.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Are you sure that when a player registers, you don't use WP_Hash with size of 299 instead of 300?



It's against the forum rules to bump within 24 hours.
Sorry, And after testing it again, The problem isn't in loading but saving, It saves it without the last character, Why ?
Reply
#10

Post the register part.
Reply


Forum Jump:


Users browsing this thread: