31.03.2012, 15:16
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 );
}
}
}