Login System Not Working
#1

I have a login system and when I login it just says that the password is wrong, even when it is right?

Whats the matter?

pawn Код:
else if(dialogid == 1) // Register
    {

        if(response)
        {
            if(strlen(inputtext) < 4)
            {
             SendClientMessage(playerid, COLOR_GREY, "Password can't be shorter than 4 characters.");
             ShowDialog(playerid, 1);
             return 1;
            }
            if(strlen(inputtext) > 256)
            {
                SendClientMessage(playerid, COLOR_GREY, "Password can't be longer than 256 characters.");
                ShowDialog(playerid, 1);
                return 1;
            }
            new file[64], IP[16], string[128], password[256];
            format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
            if(!dini_Exists(file))
            {
                GetPlayerIp(playerid, IP, sizeof(IP));
                dini_Create(file);
                WP_Hash(password, sizeof(password), inputtext);
                dini_Set(file, "Password", password);
                dini_Set(file, "IP", IP);
                PlayerInfo[playerid][pLevel] = 1;
                PlayerInfo[playerid][pTips] = 1;
                PlayerInfo[playerid][pBank] = 10000;
                PlayerInfo[playerid][pMoney] = 100;
                PlayerInfo[playerid][pWeed] = 10;
                PlayerInfo[playerid][pcocaine] = 5;
                //Anti bug
                PlayerInfo[playerid][vModel] = 0;
                PlayerInfo[playerid][vVModel] = 0;
                PlayerInfo[playerid][vVVModel] = 0;
                PlayerInfo[playerid][vVVVModel] = 0;
                dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
                format(string, sizeof(string), "SERVER: {FFFFFF}You are now registered on {FF6347}Server Name{FFFFFF} [Password: %s]", inputtext);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                ShowDialog(playerid, 2);
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    else if(dialogid == 2) // Login
    {
        if(response)
        {
            new file[64], password[256], IP[16];
            WP_Hash(password, sizeof(password), inputtext);
            format(password, sizeof(password), "%s", dini_Get(file, "Password"));
            format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
            if(!strcmp(dini_Get(file, "Password"), password))
            {
                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_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                SendClientMessage(playerid, COLOR_WHITE, "");
                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])
                {
                    SSSShowDialog(playerid, 3);
                }
                else
                {
                    LoadChar(playerid);
                    SpawnPlayer(playerid);
                    TogglePlayerControllable(playerid, 0);
                    SetTimerEx("EnterExitTimer", 5000, false, "i", playerid);
                }
                return 1;
            }
        }
        else
        {
            Kick(playerid);
            return 1;
        }
    }
Reply
#2

Anyone? I really need this fixed.
Reply
#3

pawn Код:
new file[64], password[256], IP[16];
            WP_Hash(password, sizeof(password), inputtext);
            //format(password, sizeof(password), "%s", dini_Get(file, "Password"));
            format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
            if(strcmp(dini_Get(file, "Password"), password))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}Invalid password.");
                ShowDialog(playerid, 2);
                return 1;
            }
Reply
#4

Quote:
Originally Posted by Matess
Посмотреть сообщение
pawn Код:
new file[64], password[256], IP[16];
            WP_Hash(password, sizeof(password), inputtext);
            //format(password, sizeof(password), "%s", dini_Get(file, "Password"));
            format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
            if(strcmp(dini_Get(file, "Password"), password))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: {FFFFFF}Invalid password.");
                ShowDialog(playerid, 2);
                return 1;
            }
I F**king love you man. Such a simple thing and I didn't realize it. Thanks a lot.

+ Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)