My server does not recognize passwords.
#1

Hello folks
I have had a lot of problems with the register/login system that I've made.
Everything works perfectly now except for the password recognition.

Let's say for an instance that I'm new to my server and I want to register my account.
I go through the registration process and I'll get spawned eventually.
When I log off and back on, I get the login dialog which is good. I type in my password and then it says: "You have entered an invalid password"
My passwords are hashed, don't know if this might be the problem.

LOGIN DIALOG:
pawn Код:
if(dialogid == DIALOG_LOGIN)
        {
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    gPlayerLogged[playerid] = 1;
                    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pLastX], PlayerInfo[playerid][pLastY], PlayerInfo[playerid][pLastZ], PlayerInfo[playerid][pFacingAngle], 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                    GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                    SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
                    SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                    SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
                    format(tmp2, sizeof(tmp2), "~g~Welcome ~n~~w~   %s", GetName(playerid));
                    GameTextForPlayer(playerid, tmp2, 5000, 1);
                    TogglePlayerSpectating(playerid, 0);
                    TogglePlayerControllable(playerid, 1);
                    SetPlayerColor(playerid, TRANSPARENT_WHITE);
                    if(PlayerInfo[playerid][pAdmin] >= 1)
                    {
                        format(tmp2, sizeof(tmp2), "[SERVER] You are logged in as a Level %d Admin.",PlayerInfo[playerid][pAdmin]);
                        SendClientMessage(playerid, COLOR_WHITE,tmp2);
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back to {00FF26}SERVER NAME!{FFFFFF}\n\nThat name is registered. Please enter your password below.\n\n{FF0000} You have entered an incorrect password!","Login","Quit"); //login
                }
            }
            if(!response)
            {
                format(qstring, sizeof(qstring), "[AdmCMD] You have chosen to 'Quit', you're always welcome to come back!");
                SCM(playerid, COLOR_LIGHTRED, qstring);
                SetTimerEx("kickbugfix", 1000, false, "i", playerid);
            }
        }
Password Selection DIALOG
pawn Код:
if(dialogid == DIALOG_PASSWORD)
        {
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_PASSWORD ,DIALOG_STYLE_PASSWORD, "Password Selection", "{FFFFFF}Enter a desired password to proceed.\nNote: Never share your password! The Administration Team will never ask for your password!\n\n{FF0000}You have to enter a password in order to proceed!","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password", udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Level",0);
                INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
                INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
                INI_WriteInt(File,"Int",0);
                INI_WriteInt(File,"VW",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteFloat(File,"FacingAngle",0);
                INI_WriteFloat(File,"Health",0);
                INI_WriteFloat(File,"Armour",0);
                INI_WriteFloat(File,"LastX",0);
                INI_WriteFloat(File,"LastY",0);
                INI_WriteFloat(File,"LastZ",0);
                INI_Close(File);
                ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age Selection", "How old are you? (13-70)", "Select", "Quit");
            }
            if(!response)
            {
                format(qstring, sizeof(qstring), "[AdmCMD] You have chosen to 'Quit', you're always welcome to come back!");
                SCM(playerid, COLOR_LIGHTRED, qstring);
                SetTimerEx("kickbugfix", 1000, false, "i", playerid);
                if(fexist(UserPath(playerid)))
                {
                    fremove(UserPath(playerid));
                }
            }
        }
Hash Stock
pawn Код:
stock udb_hash(buf[]) { //converts the password to a bunch of random character which are only recognizable by the server.
    new length=strlen(buf); //credits:
    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;
}
If you require more information regarding my script, let me know.
Help is much appreciated.

Sincerely
Bible
Reply


Messages In This Thread
My server does not recognize passwords. - by AndySedeyn - 01.05.2014, 07:18
Re: My server does not recognize passwords. - by Eth - 01.05.2014, 07:20
Re: My server does not recognize passwords. - by AndySedeyn - 01.05.2014, 07:34
Re: My server does not recognize passwords. - by Eth - 01.05.2014, 07:50
Re: My server does not recognize passwords. - by AndySedeyn - 01.05.2014, 07:52

Forum Jump:


Users browsing this thread: 1 Guest(s)