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
#2

Show register dialog will may help. + show the enum of player data
Reply
#3

OnPlayerConnect:
pawn Код:
if(fexist(UserPath(playerid)))
        {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            format(dstring, sizeof(dstring), "{FFFFFF}Welcome back to {00FF26}SERVER!{FFFFFF}\n\nThat name is registered. Please enter your password below.");
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", dstring, "Login", "Quit");
        }
        else
        {
            format(dstring, sizeof(dstring),  "{FFFFFF}Welcome %s {FFFFFF}to {00FF00}SERVER!\n\n{FFFFFF}It seems to be your first time on the server?\nThe registration progress will be as the following:\n\n1. Rules Agreement\n2. An RP quiz that consists out of 5 questions\n3. Password Selection\n4. Age Selection\n5. Skin Selection", GetName(playerid));
            ShowPlayerDialog(playerid, DIALOG_START, DIALOG_STYLE_MSGBOX, "West Coast Life Roleplay",dstring, "Continue", "Quit");
        }
Enum pInfo
pawn Код:
enum pInfo
{
    pCash,
    pPass,
    pAdmin,
    pLevel,
    pAge,
    pKills,
    pDeaths,
    pSkin,
    pInt,
    pVW,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    Float:pLastX,
    Float:pLastY,
    Float:pLastZ,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#4

pPass should be a number like pPass[20] instead of pPass only.
so:
pawn Код:
enum pInfo
{
    pCash,
    pPass[20],
    pAdmin,
    pLevel,
    pAge,
    pKills,
    pDeaths,
    pSkin,
    pInt,
    pVW,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    Float:pLastX,
    Float:pLastY,
    Float:pLastZ,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#5

Quote:
Originally Posted by Eth
Посмотреть сообщение
pPass should be a number like pPass[20] instead of pPass only.
so:
pawn Код:
enum pInfo
{
    pCash,
    pPass[20],
    pAdmin,
    pLevel,
    pAge,
    pKills,
    pDeaths,
    pSkin,
    pInt,
    pVW,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    Float:pLastX,
    Float:pLastY,
    Float:pLastZ,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
It works fine without the array.

It's fixed, I didn't load the account info before the dialog showed up.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)