Help with password checking.
#9

I don't like to user Filterscripts.

Okay so anyone who's willing to help me instead of telling me to do it the quick and easy way, here's what I've now got:

My dialogs:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(response)
            {
                new
                    strText[179];

                if(strlen(inputtext) >= 4 && strlen(inputtext) <= 35)
                {
                    new
                    uFile[35];
                    format(uFile, 35, "%s.ini", PlayerName(playerid));
                    new
                    INI:playerFile = INI_Open(uFile);
                    INI_WriteInt(playerFile, "Password",udb_hash(inputtext));
                    INI_WriteInt(playerFile, "Admin", 0);
                    INI_WriteInt(playerFile, "VIP", 0);
                    INI_WriteInt(playerFile, "Money", 500);
                    INI_WriteInt(playerFile, "Score", 0);
                    INI_WriteInt(playerFile, "Kills", 0);
                    INI_WriteInt(playerFile, "Deaths", 0);
                    INI_WriteInt(playerFile, "Online", 0);
                    INI_WriteInt(playerFile, "Banned", 0);
                    INI_WriteString(playerFile, "BanReason", PlayerInfo[playerid][pBanReason]);
                    INI_Close(playerFile);
                    SetPVarInt(playerid, "Registered", 1);
                    SetPVarInt(playerid, "Logged", 1);
                    format(strText, 125, "You have registered with name {FFFFFF}'%s' {FFFF00}and password {FFFFFF}'%s'{FFFF00}, you are automatic logged in!", GetName(playerid), inputtext);
                    SendClientMessage(playerid, COLOR_VAGOS, strText);
                }
                else
                {
                    new registermsg[128];
                    format(registermsg, sizeof(registermsg), "Welcome to Los Santos Gang Wars.\n\nAccount Name: %s\nThat account is not registered, type your password below to register!", PlayerName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register for - Los Santos Gang Wars, string", registermsg, "Register", "Exit");
                }
            }
            else Kick(playerid);
        }

        case DIALOG_LOGIN:
        {
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
                {
                    OnPlayerLogin(playerid);
                }
                else
                {
                    new loginmsg[128];
                    format(loginmsg, sizeof(loginmsg), "Welcome back to Los Santos Gang Wars!\n\nAccount Name: %s\nThat account is registered, type your password in to return to war.", PlayerName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login to - Los Santos Gang Wars", loginmsg, "Login", "Exit");
                }
            }
            else Kick(playerid);
        }
    }
    return 1;
}
All OnPlayerLogin does is:
pawn Код:
OnPlayerLogin(playerid)
{
    if(PlayerInfo[playerid][pBanned] == 1)
    {
        new banreason = PlayerInfo[playerid][pBanReason];
        new string[128];
        format(string, sizeof(string), "%s", banreason);
        SendClientMessage(playerid, COLOR_LIGHTRED, "This account has been banned:");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        Kick(playerid);
        return 0;
    }
    SendClientMessage(playerid, COLOR_ORANGE, "Welcome back to Los Santos Gang Wars!");
    return 1;
}
my problem is now it keeps showing me the dialog showing my passwords wrong (when it's not).

I do have the udb_hash stock:
pawn Код:
stock udb_hash(buf[]) {
    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;
}
Oh and this is the bit in my OnPlayerConnect:
pawn Код:
if(!INI_Exists(strText))
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Los Santos Gang Wars", registermsg, "Register", "Exit");
    }
    else
    {
        new
        uFile[35];
        format(uFile, 35, "%s.ini", PlayerName(playerid));
        INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Los Santos Gang Wars", loginmsg, "Login", "Exit");
    }
Reply


Messages In This Thread
Help with password checking. - by Jack_Leslie - 30.08.2011, 00:53
Re: Help with password checking. - by IceCube! - 30.08.2011, 01:04
Re: Help with password checking. - by Jack_Leslie - 30.08.2011, 01:08
Re: Help with password checking. - by IceCube! - 30.08.2011, 01:11
Re: Help with password checking. - by Jack_Leslie - 30.08.2011, 01:14
Re: Help with password checking. - by IceCube! - 30.08.2011, 01:27
Re: Help with password checking. - by Jack_Leslie - 30.08.2011, 01:36
Re: Help with password checking. - by IceCube! - 30.08.2011, 01:43
Re: Help with password checking. - by Jack_Leslie - 30.08.2011, 01:45
Re: Help with password checking. - by IceCube! - 30.08.2011, 01:48

Forum Jump:


Users browsing this thread: 1 Guest(s)