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

Ok, i found that the problem is in OnPlayerDisconnect!

But, i still need help!, now i have this :
pawn Код:
new REGKICK[MAX_PLAYERS];
And :

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if(!response)
            {
                Kick(playerid);
                REGKICK[playerid] = 1;
                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;
}
And :

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(REGKICK[playerid] == 1) return 1;
    else
    {
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
        INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
        INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
        INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Close(File);
        GetPlayerPos(playerid, pX[playerid], pY[playerid], pZ[playerid]);
        GetPlayerFacingAngle(playerid, A[playerid]);
        INI_SetTag(File, "Saved Position Data");
        INI_WriteFloat(File, "X", pX[playerid]);
        INI_WriteFloat(File, "Y", pY[playerid]);
        INI_WriteFloat(File, "Z", pZ[playerid]);
        INI_WriteFloat(File, "Angle", A[playerid]);
        INI_WriteInt(File, "Interior", GetPlayerInterior(playerid));
        INI_WriteInt(File, "VirtualWorld", GetPlayerVirtualWorld(playerid));
        INI_Close(File);
    }
    return 1;
}
The problem is,

it still creates my user file even with that REGKICK..

Please help!
Reply
#3

Bump.
Reply
#4

Just remove "Quit" button. That's what I do.
Reply
#5

My useless brain didn't think, anyway thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)