Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <Dini>
- #define Dialogo_Registro 2
- #define Dialogo_Ingreso 1
- enum Datos
- {
- Registrado, Logueado, ContraFail, Muertes, Matados
- };
- new PlayerInfo[ MAX_PLAYERS ][ Datos ];
- new Nombre [ MAX_PLAYER_NAME ];
- new datos [ 356 ];
- public OnPlayerConnect(playerid)
- {
- SendDeathMessage(INVALID_PLAYER_ID,playerid, 200);
- GetPlayerName ( playerid, Nombre , sizeof( Nombre ) );
- format( datos, sizeof ( datos ), "files/users/%s.ini", Nombre);
- if ( !dini_Exists ( datos ) )
- {
- ShowPlayerDialog(playerid, Dialogo_Registro, DIALOG_STYLE_INPUT, "Register", "Welcome choose a password\nRegister to save your data" , "accept", "exit");
- }
- else
- {
- ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- GuardarDatos ( playerid );
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- SendDeathMessage(killerid, playerid, reason);
- if(killerid != INVALID_PLAYER_ID)
- {
- PlayerInfo[ killerid ][ Matados ] ++;
- }
- PlayerInfo[ playerid ][ Muertes ] ++;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if ( dialogid == Dialogo_Registro )
- {
- if (!response) return SendClientMessage(playerid, -1, "Register Cancelled." );
- GetPlayerName ( playerid, Nombre, sizeof ( Nombre ) );
- new string [ 256 ];
- format ( string , sizeof ( string ), "files/users/%s.ini", Nombre);
- dini_Create ( string );
- dini_Set ( string, "Name", Nombre );
- dini_Set ( string, "Password", inputtext );
- dini_Set ( string, "Registrado", PlayerInfo[ playerid ][ Registrado ] );
- dini_Set ( string, "Matados", PlayerInfo[ playerid ][ Matados ] );
- dini_Set ( string, "Muertes", PlayerInfo[ playerid ][ Muertes ] );
- dini_Set ( string, "Money", PlayerInfo[ playerid ][ Registrado ] );
- dini_IntSet ( string, "Matados", 0);
- dini_IntSet ( string, "Muertes", 0);
- ResetPlayerMoney( playerid );
- SendClientMessage(playerid, -1, "[Info]: Your account has been successfully created." );
- PlayerInfo[ playerid ][ Registrado ] = 1;
- PlayerInfo[ playerid ][ Logueado ] = 1;
- dini_IntSet ( string, "Registrado", PlayerInfo[ playerid ][ Registrado ] );
- }
- if ( dialogid == Dialogo_Ingreso )
- {
- new string[ 168 ], ipod[ 168 ], istring[ 128 ];
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
- if (!response) return ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
- GetPlayerName( playerid , Nombre , sizeof ( Nombre ) );
- format ( string, sizeof ( string ), "files/users/%s.ini", Nombre);
- format ( ipod , sizeof ( ipod ), "%s", dini_Get( string, "Password"));
- if ( !strcmp ( inputtext, ipod ) )
- {
- PlayerInfo[ playerid ][ Logueado ] = 1;
- CargarDatos ( playerid );
- }
- else
- {
- PlayerInfo[ playerid ][ ContraFail]++;
- if ( PlayerInfo[ playerid ][ ContraFail ] == 5)
- {
- format( istring, sizeof ( istring ), "%s It has been kickeado (Incorrect logins)", Nombre );
- SendClientMessageToAll( -1, istring );
- Kick ( playerid );
- }
- return ShowPlayerDialog ( playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Incorrect password", "Welcome back\n enter your password.", "accept", "exit" );
- }
- }
- return 1;
- }
- forward GuardarDatos ( playerid );
- public GuardarDatos ( playerid )
- {
- GetPlayerName ( playerid, Nombre, sizeof ( Nombre ) );
- format ( datos, sizeof ( datos), "files/users/%s.ini", Nombre );
- if ( !dini_Exists ( datos ) )
- {
- }
- else
- {
- dini_IntSet ( datos, "Matados", PlayerInfo[ playerid ][ Matados ] );
- dini_IntSet ( datos, "Muertes", PlayerInfo[ playerid ][ Muertes ] );
- dini_IntSet ( datos, "Money", GetPlayerMoney( playerid ) );
- SendClientMessage(playerid, -1, "registered correctly!.");
- PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 );
- }
- return 1;
- }
- forward CargarDatos ( playerid );
- public CargarDatos ( playerid )
- {
- format ( datos, sizeof ( datos ), "files/users/%s.ini", Nombre );
- if ( !dini_Exists ( datos ) )
- {
- }
- else
- {
- SetPlayerScore(playerid, dini_Int(datos, "Matados" ) );
- PlayerInfo[ playerid ][ Muertes ] = dini_Int ( datos, "Muertes" );
- GivePlayerMoney( playerid, dini_Int( datos, "Money" ) );
- SendClientMessage(playerid, -1, "Logged correctly!. Welcome back.");
- }
- PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 );
- return 1;
- }
- CMD:registro(playerid, params[])
- {
- if ( PlayerInfo[ playerid ][ Registrado ] == 0 )
- {
- ShowPlayerDialog(playerid, Dialogo_Registro, DIALOG_STYLE_INPUT, "Register", "Welcome choose a password\nRegister to save your data" , "accept", "exit");
- }
- else
- {
- SendClientMessage ( playerid, -1, "[ERROR]: You are already registered." );
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment