Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- *
- *
- * Sistema de registro com codigo de ativacao via email
- * Creditos a mau.tito
- *
- *
- *******************************************************************************/
- #include a_samp
- #include DOF2
- #include a_http
- #define USERS "Contas/%s.ini"
- #define MAILER_URL \
- "geradoresjfs.site90.net/mailer.php"
- #define Destinatario \
- #define DIALOG_REGISTRO 1
- #define DIALOG_LOGIN 2
- #define DIALOG_EMAIL 3
- #define DIALOG_ATIVACAO 4
- #define Random_Maiuscula() (random(25) + 65)
- #define Random_Minuscula() (random(25) + 97)
- #define Random_Numero() (random(9) + 48)
- #define CallBack::%0(%1) forward %0(%1); \
- public %0(%1)
- new Nome[MAX_PLAYER_NAME];
- enum pInfo
- {
- pLevel,
- pGrana,
- TotalVezesLogado,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- public OnFilterScriptInit()
- {
- print("\n Sistema de registro by mau tito");
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2::Exit();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new str[30];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- format(str, sizeof(str), "Contas/%s.ini", Nome);
- if(!DOF2_GetBool(str, "ContaAtivado"))
- {
- ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Bote o codigo de ativao da conta !", "Continuar", "");
- }
- if(!DOF2_FileExists(str))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_PASSWORD, "Registro", "Bem vindo ao servidor voce nao possue registro \n bote uma senha para pode se registrar.", "Registrar", "Cancelar");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)return SalvarConta(playerid);
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_REGISTRO)
- {
- if(response)
- {
- new str[100];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- format(str, sizeof(str), USERS, Nome);
- DOF2_CreateFile(str);
- DOF2_SetString(str, "Senha", inputtext);
- SendClientMessage(playerid, -1, "Registrado corretamente preencha os dados pedidos adiante");
- DOF2_SetString(str, "Email", "SemEmail");
- DOF2_SetBool(str, "ContaAtivado", false);
- new var[90];
- format(var, sizeof var, "%c%c%c%c", Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero());
- DOF2_SetString(str, "CodeAtivacao", var);
- ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Bote um email valido para ser mandado codigo de ativaçao da conta!", "Continuar", "");
- DOF2_SaveFile();
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "Voce Foi Kickado pelo bot");
- Kick(playerid);
- }
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(response)
- {
- if(!strlen(inputtext))
- {
- GetPlayerName(playerid, Nome, sizeof(Nome));
- SendClientMessage(playerid,-1 ,"Senha Incorreta !");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
- return 0;
- }
- new str[100];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- format(str, sizeof(str), USERS, Nome);
- if(!strcmp(inputtext,DOF2_GetString(str,"Senha"),false))
- {
- PlayerInfo[playerid][TotalVezesLogado]++;
- CarregarConta(playerid);
- }
- else
- {
- SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "login", "Voce ja possue um registro em nosso servidor \n bote sua senha para poder logar corretamente.", "Logar", "Cancelar");
- }
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "Voce Foi Kickado .");
- Kick(playerid);
- }
- }
- if(dialogid == DIALOG_EMAIL)
- {
- if(response)
- {
- new str[60], tito[320];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome);
- DOF2_SetString(str,"Email", inputtext);
- format(tito, sizeof(tito), "Bem vindo ao servidor \n\n Acabamos de detectar que voce acaba de registrar em nosso servido\
- \n Seja bem vindo !\n Para voce poder logar voce tem que ativar sua conta para poder jogar coretamente!\n\n\n\
- Codigo de ativaçao: %0.4s", DOF2_GetString(str, "CodeAtivacao"));
- EnviarEmail(DOF2_GetString(str, "Email"),Destinatario, "Ativaçao da Conta Sa-mp", "TT Ativacao da conta", tito);
- ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Bote o codigo de ativao da conta !", "Continuar", "");
- DOF2_SaveFile();
- }
- }
- if(dialogid == DIALOG_ATIVACAO)
- {
- if(response)
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Este nao e seu codigo de ativao!\n Bote o codigo de ativacao correto .", "Continuar", "");
- return 0;
- }
- new str[60];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- if(!strcmp(inputtext, DOF2_GetString(str,"CodeAtivacao"),false))
- {
- SendClientMessage(playerid, -1, "Sua conta foi ativada(o) com o codigo de ativaçao mandado em seu e-mail .");
- DOF2_SetBool(str, "ContaAtivado", true);
- new tito[290];
- format(tito, sizeof(tito), "Bem Vindo ao Servidor \n \
- Personagem : %s \n Level: %i\n Grana: %i \n\n \
- As suas informaçoes forao citados acima , obrigado por registrar em nosso servidor de sa-mp !\n\n \n\
- Att mau.tito", Nome, GetPlayerScore(playerid), GetPlayerMoney(playerid));
- EnviarEmail(DOF2_GetString(str, "Email"),Destinatario, "Ativaçao da Conta Sa-mp", "TT Ativacao da conta", tito);
- DOF2_SaveFile();
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Este nao e seu codigo de ativao!\n Bote o codigo de ativacao correto .", "Continuar", "");
- }
- }
- }
- return 1;
- }
- CallBack::SalvarConta(playerid)
- {
- new file[40];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- format(file, sizeof(file), USERS, Nome);
- DOF2_SetInt(file, "Level", GetPlayerMoney(playerid));
- DOF2_SetInt(file, "Dinheiro", GetPlayerScore(playerid));
- DOF2_SetInt(file, "VezesLogou", PlayerInfo[playerid][TotalVezesLogado]);
- DOF2_SaveFile();
- return 1;
- }
- CallBack::CarregarConta(playerid)
- {
- new file[40];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- format(file, sizeof(file), USERS, Nome);
- GivePlayerMoney(playerid, DOF2_GetInt(file, "Level"));
- SetPlayerScore(playerid, DOF2_GetInt(file, "Dinheiro"));
- PlayerInfo[playerid][TotalVezesLogado] = DOF2_GetInt(file, "VezesLogou");
- DOF2_SaveFile();
- return 1;
- }
- /* Include mailer By Sliceo */
- #if ( !defined MAILER_MAX_MAIL_SIZE )
- #define MAILER_MAX_MAIL_SIZE (1024)
- #endif
- #if ( !defined MAILER_URL )
- #error Please define MAILER_URL before including the mailer include.
- #endif
- stock EnviarEmail( const szReceiver[ ], const szSenderMail[ ], const szSenderName[ ], const szSubject[ ], const szMessage[ ] )
- {
- new
- szBuffer[ MAILER_MAX_MAIL_SIZE ] = "t=",
- iPos = strlen( szBuffer ),
- iLength = strlen( szReceiver )
- ;
- memcpy( szBuffer, szReceiver, iPos * 4, ( iLength + 1 ) * 4 );
- StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
- strcat( szBuffer, "&f=" );
- iPos = strlen( szBuffer );
- iLength = strlen( szSenderName );
- memcpy( szBuffer, szSenderName, iPos * 4, ( iLength + 1 ) * 4 );
- StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
- strcat( szBuffer, "&n=" );
- iPos = strlen( szBuffer );
- iLength = strlen( szSenderMail );
- memcpy( szBuffer, szSenderMail, iPos * 4, ( iLength + 1 ) * 4 );
- StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
- strcat( szBuffer, "&s=" );
- iPos = strlen( szBuffer );
- iLength = strlen( szSubject );
- memcpy( szBuffer, szSubject, iPos * 4, ( iLength + 1 ) * 4 );
- StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
- strcat( szBuffer, "&m=" );
- iPos = strlen( szBuffer );
- iLength = strlen( szMessage );
- memcpy( szBuffer, szMessage, iPos * 4, ( iLength + 1 ) * 4 );
- StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
- HTTP( 0xD00D, HTTP_POST, MAILER_URL, szBuffer, "OnMailScriptResponse" );
- }
- forward OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] );
- public OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] )
- {
- if ( szData[ 0 ] )
- printf( "Mailer script says: %s", szData );
- }
- stock StringURLEncode( szString[ ], iSize = sizeof( szString ) )
- {
- for ( new i = 0, l = strlen( szString ); i < l; i++ )
- {
- switch ( szString[ i ] )
- {
- case '!', '(', ')', '\'', '*',
- '0' .. '9',
- 'A' .. 'Z',
- 'a' .. 'z':
- {
- continue;
- }
- case ' ':
- {
- szString[ i ] = '+';
- continue;
- }
- }
- new
- s_szHex[ 8 ]
- ;
- if ( i + 3 >= iSize )
- {
- szString[ i ] = EOS;
- break;
- }
- if ( l + 3 >= iSize )
- szString[ iSize - 3 ] = EOS;
- format( s_szHex, sizeof( s_szHex ), "%02h", szString[ i ] );
- szString[ i ] = '%';
- strins( szString, s_szHex, i + 1, iSize );
- l += 2;
- i += 2;
- if ( l > iSize - 1 )
- l = iSize - 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment