[HELP] Dialog registration system
#1

There is something wrong with this system. When I register an account and disconnect, re-connects and try to login, it just shows me 'Wrong password'.

pawn Код:
enum pInfo
{
    pPassword,
    pCash,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], file[128];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(file, sizeof(file), "users/%s.ini", name);
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Please provide your password below.", "Register", "Cancel"); // this is the dialog type
    }
    else
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Please provide your password below.", "Login", "Cancel");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new file[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(file, sizeof(file), "users/%s.ini", name);
    if(dini_Exists(file))
    {
        dini_IntSet(file, "Password", PlayerInfo[playerid][pPassword]);
        dini_IntSet(file, "Cash", PlayerInfo[playerid][pCash]);
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        new file[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "users/%s.ini", name);
        if(response)
        {
            if(strlen(inputtext))
            {
                dini_Create(file);
                dini_IntSet(file, "Password", num_hash(inputtext));
                dini_IntSet(file, "Cash", PlayerInfo[playerid][pCash]);
                PlayerInfo[playerid][pCash] = dini_Int(file, "Cash");
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    if(dialogid == 2)
    {
        new file[128], name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string, sizeof(string), "users/%s.ini", name);
        if(response)
        {
            if(strlen(inputtext))
            {
                if(num_hash(inputtext) != dini_Int(file, "Password"))
                {
                    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Wrong password!", "Please provide your password below.", "Login", "Cancel");
                }
                else
                {
                    PlayerInfo[playerid][pCash] = dini_Int(file, "Cash");
                }
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    return 1;
}
Thanks in advance.
Reply


Messages In This Thread
[HELP] Dialog registration system - by Fredden1993 - 08.04.2012, 20:52
Re: [HELP] Dialog registration system - by ReneG - 08.04.2012, 21:00
Re: [HELP] Dialog registration system - by Fredden1993 - 08.04.2012, 22:48
Re: [HELP] Dialog registration system - by Fredden1993 - 09.04.2012, 11:47
Re: [HELP] Dialog registration system - by Reklez - 09.04.2012, 11:50
Re: [HELP] Dialog registration system - by Bokyyy - 09.04.2012, 12:08
Re: [HELP] Dialog registration system - by Fredden1993 - 09.04.2012, 13:41

Forum Jump:


Users browsing this thread: 1 Guest(s)