Register And Login dialog problems
#1

Hello,

I use Kush's Tutorial for the login and register systems,

The problem is this :

When i select Quit in the register dialog, it kicks me and thats what should happen,

But, it creates my User file in scriptfiles when i'm kicked!

So, when i go to the server and i didn't register yet, it asks me to login cause the User file is in scriptfiles,

and in scriptfiles, all i have is :

The cash, admin, kills, and Deaths.

But there is no password.

So the problem is that it creates my user file when i click on Quit in the register dialog, and so the login dialog will ask me to login and i didn't register yet!

OnPlayerConnect :

pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Login",""COL_LIGHTBLUE"Type your password below to login.","Login","Quit");
    }
    else
    {
        new String[200];
        new pName[24];
        GetPlayerName(playerid, pName, 24);
        format(String, 200, ""COL_LIGHTBLUE"Hello %s, Type your password below to register a new account.", pName);
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registering", String, "Register", "Quit");
    }
    return 1;
}
UserPath stock :

pawn Код:
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
OnDialogResponse :

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if(!response)
            {
                Kick(playerid);
                return 1;
            }
            else
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_LIGHTBLUE"Type your password below to register a new account.","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,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thank you for registering!","Ok","");
            }
        }

        case 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);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_LIGHTBLUE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Register And Login dialog problems - by SilverKiller - 25.03.2013, 16:18
Re: Register And Login dialog problems - by SilverKiller - 25.03.2013, 16:39
Re: Register And Login dialog problems - by SilverKiller - 26.03.2013, 11:30
Re: Register And Login dialog problems - by newbienoob - 26.03.2013, 11:33
Re: Register And Login dialog problems - by SilverKiller - 26.03.2013, 11:45

Forum Jump:


Users browsing this thread: 1 Guest(s)