Can someone help me about login thingy?
#1

When I tried to login and other do too,., it's like when we type our right password it says, invalid password,..
when I start to type random passwords like,... adwawjn, 2, 2eda2da, 2adoa3kd, wadia, it gets in..
-.-'
Reply
#2

post your login system code
Reply
#3

I bet, It would be the mistake of "!" or "==0".
Reply
#4

Код:
    else if(dialogid == 2) // Login
    {
        if(response)
        {
            new file[64], password[256], IP[16], password2[256];
            format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
            WP_Hash(password2, sizeof(password2), inputtext);
            format(password, sizeof(password), "%s", dini_Get(file, "Password"));
            if(!strcmp(dini_Get(file, "Password"), password2))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}Invalid password.");
                ShowDialog(playerid, 2);
                return 1;
            }
            if(dini_Int(file, "AdminAccount") == 1)
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}You can't login directly from an admin account.");
                Kick(playerid);
                return 1;
            }
            else if(strlen(inputtext) > 256 || strlen(inputtext) <= 0)
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}You must enter a password to procceed.");
                ShowDialog(playerid, 2);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIME, "");
                SendClientMessage(playerid, COLOR_LIME, "");
                SendClientMessage(playerid, COLOR_LIME, "");
                format(PlayerInfo[playerid][pIP], 16, "%s", dini_Get(file, "IP"));
                GetPlayerIp(playerid, IP, sizeof(IP));
                dini_Set(file, "IP", IP);
                PlayerInfo[playerid][pGender] = dini_Int(file, "Gender");
                PlayerInfo[playerid][pAge] = dini_Int(file, "Age");
                if(!PlayerInfo[playerid][pGender] || !PlayerInfo[playerid][pAge])
                {
                    ShowDialog(playerid, 3);
                }
                else
                {
                    LoadChar(playerid);
                    SpawnPlayer(playerid);
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}You have chosen to quit the server.");
            Kick(playerid);
        }
    }
Reply
#5

This string is incorrect:

pawn Код:
if(!strcmp(dini_Get(file, "Password"), password2))
If you wish to see if the password is invalid, you have to remove the "!" because strcmp returns 0 if the strings are the same (for the matched length). That means you inverted the checks.

https://sampwiki.blast.hk/wiki/Strcmp
Reply
#6

Quote:
Originally Posted by Jardzskiiz
Посмотреть сообщение
pawn Код:
if(!strcmp(dini_Get(file, "Password"), password2))
As said.

Quote:
Originally Posted by RyanPetersons
Посмотреть сообщение
I bet, It would be the mistake of "!" or "==0".
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)