strcmp question
#3

pawn Code:
#define     USERPATH            "ZoneDM/Users/%s.ini"

enum accVars
{
    Password[ 64 ],
    Model,
    Access,
    ClassID
};
new accInfo [ MAX_PLAYERS ] [ accVars ], bool:player_Logged[ MAX_PLAYERS ] = false;
pawn Code:
public OnPlayerConnect(playerid)
{
    if( fexist( GetAccountPath( playerid ) ) ) //They exist!
    {
        INI_ParseFile( GetAccountPath( playerid ), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog( playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to SA:MP - Zone DM!", "\n\nPlease enter your password below to be logged in.", "Submit", "Quit" );
    }
    else //New user
    {
        ShowPlayerDialog( playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to SA:MP - Zone DM!", "\n\nPlease enter a password in order to register an account with us.", "Submit", "Quit" );
    }
    player_Spawned [ playerid ] = false, player_Logged [ playerid ] = false;
    return 1;
}
pawn Code:
switch( dialogid )
    {
        case    DIALOG_BLANK: { if( response ) { } }
        case    DIALOG_REGISTER: {
                    if( response )
                    {
                        if( !strlen( inputtext ) ) //They hit enter without entering a password.
                            return ShowPlayerDialog( playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome to SA:MP - Zone DM!", "\n\nYou have entered an invalid password, in order to assist you, a plain text password field has been enabled.\n\nPlease enter a password in order to register an account with us.", "Submit", "Quit" );
                       
                        new
                            INI: myAcc = INI_Open( GetAccountPath( playerid ) );
                           
                        INI_SetTag(         myAcc,          "data" );
                       
                        INI_WriteString(    myAcc,          "Password",         inputtext );
                       
                        INI_WriteInt(       myAcc,          "Model",            -1 );
                        INI_WriteInt(       myAcc,          "Access",           1 );
                        INI_WriteInt(       myAcc,          "ClassID",          -1 );
                           
                        INI_Close( myAcc );
                    }
                    else if( !response )
                    {
                        SendClientMessage( playerid, 0xFFFFFFFF, "You have chosen to quit the server. We hope you visit again soon!" );
                        Kick( playerid );
                    }
                }
        case    DIALOG_LOGIN: {
                    if( response )
                    {
                        if( !strlen( inputtext ) ) //They hit enter without entering a password.
                            return ShowPlayerDialog( playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome to SA:MP - Zone DM!", "\n\nYou have entered an invalid password, in order to assist you, a plain text password field has been enabled.\n\nPlease enter a password in order to register an account with us.", "Submit", "Quit" );
                           
                        if( strcmp( accInfo[ playerid ] [ Password ], inputtext, false ) == 0 )
                            return ShowPlayerDialog( playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome to SA:MP - Zone DM!", "\n\nYou have entered an invalid password, in order to assist you, a plain text password field has been enabled.\n\nPlease enter a password in order to register an account with us.", "Submit", "Quit" );

                        INI_ParseFile( GetAccountPath( playerid ), "LoadUser_%s", .bExtra = true, .extra = playerid );
                       
                        player_Logged [ playerid ] = true;
                       
                        GivePlayerMoney( playerid, 1000 );
                    }
                }
    }
Yeah, I'm sure.
Reply


Messages In This Thread
strcmp question - by 2KY - 31.03.2012, 15:13
Re: strcmp question - by jotan. - 31.03.2012, 15:15
Re: strcmp question - by 2KY - 31.03.2012, 15:16
Re: strcmp question - by Jochemd - 31.03.2012, 15:17
Re: strcmp question - by ReneG - 31.03.2012, 15:29
Re: strcmp question - by 2KY - 31.03.2012, 15:31
Re: strcmp question - by ReneG - 31.03.2012, 15:38
Re: strcmp question - by 2KY - 31.03.2012, 15:40
Re: strcmp question - by ReneG - 31.03.2012, 15:45
Re: strcmp question - by 2KY - 31.03.2012, 16:02
Re: strcmp question - by mprofitt - 07.05.2012, 20:13

Forum Jump:


Users browsing this thread: 2 Guest(s)