Logging in problem
#1

I've started to create a RP gamemode and need some help with my register/login script. I managed to get it working without any pawno errors but when I load the game up, it tells me that I have the wrong password. (Even if the password is correct.)

Here is the login command:

pawn Код:
CMD:login(playerid, params[])
{
    if(fexist(UserPath(playerid)))
        {
            if(gPlayerLogged[playerid] == 0){
            ShowPlayerDialog(playerid, 667, DIALOG_STYLE_INPUT, "Login", "Type your password here.", "Submit", "Cancel");
        }
        else
            {
                SCM(playerid, COLOR_RED, "You are already logged in.");
            }
            return 1;}
        else
            {
            SCM(playerid, COLOR_RED, "Account not found. Please use /register.");
            }
    return 1;
}
and here is the 667 dialog box:

pawn Код:
if(dialogid == 667)
    {
        if(response)
        {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                gPlayerLogged[playerid] = 1;
                GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                SCM(playerid, COLOR_RED, "You have logged in. You may now spawn.");
            }
           
    else
            {
               
                gPlayer[playerid] += 1;
                if(gPlayer[playerid] == 1)
                {
                SCM(playerid, COLOR_RED, "Wrong Password. 1/3");
               
                }
               
                if(gPlayer[playerid] == 2)
                {
                SCM(playerid, COLOR_RED, "Wrong Password. 2/3");

                }

                if(gPlayer[playerid] == 3)
                {
                SCM(playerid, COLOR_RED, "Wrong Password. 3/3. You have been kicked.");
                    Kick(playerid);
                }
               

            }
        }
       
    }

     return 1;
}
It's most likely a simple mixup error..
Reply
#2

Post where you are saving the stats.
Reply
#3

hmm to figure out the problem
Why don't you try running the GM without password hash ? To see if it is saving password correctly or not
Reply
#4

Quote:
Originally Posted by RoleplayEditor
Посмотреть сообщение
hmm to figure out the problem
Why don't you try running the GM without password hash ? To see if it is saving password correctly or not
I've had this problem before, and there is a quick fix. Without disabling the hashing stock.
Reply
#5

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Post where you are saving the stats.
....
pawn Код:
if(dialogid == 666)
    {
         if(response)
        {
            new INI:File = INI_Open(UserPath(playerid));

            INI_SetTag(File,"data");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel] = 1);
            INI_WriteInt(File, "Respect",PlayerInfo[playerid][pLevel] = 0);
            INI_WriteInt(File, "RP Points",PlayerInfo[playerid][pLevel] = 0);
            INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash] = 0);
            INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin] = 0);
            INI_WriteInt(File, "Vip", PlayerInfo[playerid][pVip] = 0);
            INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined] = 0);
            INI_WriteInt(File, "Exp", PlayerInfo[playerid][pExp] = 0);
            INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns] = 0);
            INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted] = 0);
            INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime] = 0);
            INI_Close(File);
            SCM(playerid, COLOR_RED, "You have registered. You may now spawn.");
            gPlayerLogged[playerid] = 1;
This?
Reply
#6

No, like where you save stats for players that are already registered. OnPlayerDisconnect I would imagine.
Reply
#7

pawn Код:
new INIFile = INI_Open(UserPath(playerid));
    INI_SetTag(File,data);
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Pass",PlayerInfo[playerid][pPass]);
    INI_WriteInt(File, "Respect",PlayerInfo[playerid][pRespect]);
    INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
    INI_WriteInt(File, "Exp", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
    INI_Close(File);
Reply
#8

Haha, okay. You made the same mistake I did.
Remove the line
pawn Код:
INI_WriteInt(File, "Pass",PlayerInfo[playerid][pPass]);
From the OnPlayerDisconnect.

What's happening is that the password is not being hashed when you are saving. So, when you log off your password is zero, and the udb_hash is not reading it as so. Tell me what happens. Goodluck

P.S

pawn Код:
new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,data);
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Pass",PlayerInfo[playerid][pPass]);
    INI_WriteInt(File, "Respect",PlayerInfo[playerid][pRespect]);
    INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
    INI_WriteInt(File, "Exp", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
    INI_Close(File);
You forgot the colon between INI and File
Reply
#9

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Haha, okay. You made the same mistake I did.
Remove the line
pawn Код:
INI_WriteInt(File, "Pass",PlayerInfo[playerid][pPass]);
From the OnPlayerDisconnect.

What's happening is that the password is not being hashed when you are saving. So, when you log off your password is zero, and the udb_hash is not reading it as so. Tell me what happens. Goodluck

P.S

pawn Код:
new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,data);
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Pass",PlayerInfo[playerid][pPass]);
    INI_WriteInt(File, "Respect",PlayerInfo[playerid][pRespect]);
    INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
    INI_WriteInt(File, "Exp", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
    INI_Close(File);
You forgot the colon between INI and File
(Sorry for the late reply, I managed to destroy my entire script and fill it with hundreds of errors while disabling the hash, It's sorted now)
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)