Login system not saving password (+REP)
#1

I made a login system using dialogs and YINI. All of the sudden, when I try to log in, it always shows "Incorrect Password", no matter what I do. I tried entering the UDB hash into the password, but nothing seems to work.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    //Login System
    if(dialogid == DIALOG_REGISTER)
        {
        if (!response) return Kick(playerid);
        if(response)
            {
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"Player Info");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File, "Paycheck", PlayerInfo[playerid][pPaycheck]);
            INI_WriteInt(File, "Level", PlayerInfo[playerid][pLevel]);
            INI_WriteInt(File, "Hours", PlayerInfo[playerid][pHours]);
            INI_WriteInt(File, "Job", PlayerInfo[playerid][pJob]);
            INI_WriteFloat(File, "Spawn X",PlayerInfo[playerid][pSpawnX]);
            INI_WriteFloat(File, "Spawn Y",PlayerInfo[playerid][pSpawnY]);
            INI_WriteFloat(File, "Spawn Z",PlayerInfo[playerid][pSpawnZ]);
            INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
            INI_WriteInt(File, "Banned",PlayerInfo[playerid][pBanned]);
            INI_WriteInt(File, "Spawn", PlayerInfo[playerid][pSpawn]);
            INI_WriteInt(File, "Bank", PlayerInfo[playerid][pBank]);
            INI_WriteInt(File, "Food", PlayerInfo[playerid][pFood]);
            INI_WriteInt(File, "Water", PlayerInfo[playerid][pWater]);
            INI_WriteInt(File, "Skin", PlayerInfo[playerid][pSkin]);
            INI_WriteInt(File, "Faction", PlayerInfo[playerid][pFaction]);
            INI_WriteString(File, "Faction Rank", PlayerInfo[playerid][pFrank]);
            INI_WriteInt(File, "Faction Level", PlayerInfo[playerid][pFlevel]);
            INI_Close(File);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Enter your password below:", "Login", "Cancel");
            return 1;
            }
        }
pawn Код:
if(dialogid == DIALOG_LOGIN)
        {
        if(!response) return Kick(playerid);
        if(response)
            {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetSpawnInfo(playerid, 0, 1, 1242.0341,327.7363,19.7555, 0, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer(playerid);
                return 1;
                }
            else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","{FF0000}Error:{FFFFFF} You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
            }
        }
And this is the code to the UDB hash

pawn Код:
stock udb_hash(buf[]) { // Credits to DracoBlue
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
As mentioned in the code, credits to DracoBlue for the udb_hash.

Also, this is made by me, not an edit, just incase it matters for whatever reason.
Reply


Messages In This Thread
Login system always showing INCORRECT PASS (+REP) - by Mattakil - 26.09.2013, 20:17
Re: Login system not saving password (+REP) - by BoU3A - 26.09.2013, 20:25
Re: Login system not saving password (+REP) - by Mattakil - 26.09.2013, 20:34
Re: Login system not saving password (+REP) - by |MadDog| - 26.09.2013, 21:02
Re: Login system not saving password (+REP) - by Mattakil - 26.09.2013, 21:15
Re: Login system not saving password (+REP) - by Mattakil - 26.09.2013, 21:24
Re: Login system not saving password (+REP) - by Mattakil - 27.09.2013, 01:37
Re: Login system not saving password (+REP) - by Accord - 27.09.2013, 01:46
Re: Login system not saving password (+REP) - by Mattakil - 27.09.2013, 01:48
Respuesta: Login system not saving password (+REP) - by RafaelZam - 27.09.2013, 02:22

Forum Jump:


Users browsing this thread: 1 Guest(s)