Login problems
#1

i have a login system but when a player registers its creates a user file, but the login system when a player comes back dose'nt work right the password dose'nt seem to be required how can i fix this?

pawn Код:
public OnPlayerConnect(playerid)
{
    if( fexist ( user_account_path ( playerid ) ) )
    {
        INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Log-in, #Quit);
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register.", #Register, #Quit);
    }
    userData[ playerid ][ Admin_Level ] = 0;
    userData[ playerid ][ Money ] = 0;
    userData[ playerid ][ Deaths ] = 0;
    userData[ playerid ][ Score ] = 0;
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick( playerid );
            if ( response )
            {
                if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have entered an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);

                new
                    hashed_password[ 129 ];
                WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );

                new INI:File = INI_Open( user_account_path( playerid ) );
                INI_SetTag(File, "statistics" );
                INI_WriteString(File, "Password", hashed_password );
                INI_WriteInt(File, "Money", 0 );
                INI_WriteInt(File, "AdminLevel", 0 );
                INI_WriteInt(File, "Deaths", 0 );
                INI_WriteInt(File, "Score", 0 );
                INI_Close(File);
                SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer( playerid );
            }
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new
                    hashed_password[ 129 ];
                WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );

                if( !strcmp ( hashed_password, userData[ playerid ][ Password ] ) )
                {
                    INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
                    SetPlayerScore( playerid, userData[ playerid ][ Score ] );
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#2

Show your load_user stock and your userData Enum.
Reply
#3

pawn Код:
enum USER_ENUM { Password[ 129 ], Score, Deaths, Money, Admin_Level }

new
    userData[ MAX_PLAYERS ][ USER_ENUM ];

stock user_account_path(playerid)
{
    new
        string_path[ 128 ],
        player_name[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
    format( string_path, sizeof ( string_path ), "Users/%s.ini", player_name);
    return
        string_path;
}
forward @load_user_statistics(playerid, name[], value[]);

@load_user_statistics(playerid, name[], value[])
{
    INI_String("Password", userData[ playerid ][ Password ], 129);
    INI_Int("Money", userData[ playerid ][ Money ]);
    INI_Int("AdminLevel", userData[ playerid ][ Admin_Level ]);
    INI_Int("Deaths", userData[ playerid ][ Deaths ]);
    INI_Int("Score", userData[ playerid ][ Score ]);
    return 1;
Reply
#4

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick( playerid );
            if ( response )
            {
                if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have entered an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);

                WP_Hash(userData[playerid][Password], 129, inputtext);

                new INI:File = INI_Open( user_account_path( playerid ) );
                INI_SetTag(File, "statistics" );
                INI_WriteString(File, "Password", userData[playerid][Password]);
                INI_WriteInt(File, "Money", 0 );
                INI_WriteInt(File, "AdminLevel", 0 );
                INI_WriteInt(File, "Deaths", 0 );
                INI_WriteInt(File, "Score", 0 );
                INI_Close(File);
                SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer( playerid );
            }
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                new
                    hashed_password[ 129 ];
                WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );

                if( !strcmp (hashed_password, userData[ playerid ][ Password ] ) )
                {
                    INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
                    SetPlayerScore( playerid, userData[ playerid ][ Score ] );
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#5

still nothing, still can login without a pass or a incorrect pass
Reply
#6

bump**
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)