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
- #include zcmd
- #include sscanf2
- #define USERS "Contas/%s.ini"
- #define MAILER_URL \
- "geradoresjfs.site90.net/mailer.php"
- #define Destinatario \
- #define DIALOG_MENU 10
- #define DIALOG_REGISTRO 1
- #define DIALOG_LOGIN 2
- #define DIALOG_EMAIL 3
- #define DIALOG_ATIVACAO 4
- #define DIALOG_RECUPERACAO 5
- #define INICIOC 1
- #define INICIOM 10000
- #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],
- Mortes[MAX_PLAYERS],
- Matou[MAX_PLAYERS],
- Dia[MAX_PLAYERS],
- Mes[MAX_PLAYERS],
- Ano[MAX_PLAYERS],
- Horas[MAX_PLAYERS],
- Minutos[MAX_PLAYERS],
- TrocarN[MAX_PLAYERS];
- enum pInfo
- {
- pLevel,
- pGrana,
- TotalVezesLogado,
- pAdmin,
- Float:X,
- Float:Y,
- Float:Z
- }
- 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 ativar da conta !", "Continuar", "");
- }
- ShowPlayerDialog(playerid, DIALOG_MENU, DIALOG_STYLE_LIST, "Menu-Iniciar", "Registrar\nLogar\nEsqueci a Senha", "Selecionar", "");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new file[40];
- GetPlayerName(playerid, Nome, sizeof(Nome));
- GetPlayerPos(playerid, PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z]);
- format(file, sizeof(file), USERS, Nome);
- DOF2_SetFloat(file, "PosX", PlayerInfo[playerid][X]);
- DOF2_SetFloat(file, "PosY", PlayerInfo[playerid][Y]);
- DOF2_SetFloat(file, "PosZ", PlayerInfo[playerid][Z]);
- SalvarConta(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new file[60];
- GetPlayerName(playerid, Nome,sizeof(Nome));
- format(file, sizeof(file), USERS, Nome);
- PlayerInfo[playerid][X] = DOF2_GetFloat(file, "PosX");
- PlayerInfo[playerid][Y] = DOF2_GetFloat(file, "PosY");
- PlayerInfo[playerid][Z] = DOF2_GetFloat(file, "PosZ");
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Matou[killerid] ++;
- Mortes[playerid] ++;
- return 1;
- }
- 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);
- DOF2_SetInt(str, "Skin", 21);
- DOF2_SetInt(str, "Mortes", 0);
- DOF2_SetInt(str, "Matou", 0);
- DOF2_SetInt(str, "pAdmin", 0);
- DOF2_SetInt(str, "Dia", 0);
- DOF2_SetInt(str, "Mes", 0);
- DOF2_SetInt(str, "Ano", 0);
- DOF2_SetInt(str, "Horas", 0);
- DOF2_SetInt(str, "Minutos", 0);
- GivePlayerMoney(playerid, INICIOM);
- SetPlayerScore(playerid, INICIOC);
- new var[90];
- format(var, sizeof var, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\
- ", Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero());
- DOF2_SetString(str, "CodeAtivacao", var);
- new tito[90];
- format(tito, sizeof tito, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\
- ", Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero(),Random_Maiuscula(), Random_Minuscula(), Random_Numero(), Random_Numero());
- DOF2_SetString(str, "CodigoRecuperacao", tito);
- 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.16s", 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 ativar 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 ativar!\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);
- DOF2_SaveFile();
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_ATIVACAO, DIALOG_STYLE_INPUT, "Email", "Este nao e seu codigo de ativar!\n Bote o codigo de ativacao correto .", "Continuar", "");
- }
- }
- }
- if(dialogid == DIALOG_MENU)
- {
- if(response)
- {
- if(listitem == 0)
- {
- new str[60];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- 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 { SendClientMessage(playerid, -1,"Voce, ja possue conta aqui !"); }
- }
- else if(listitem == 1)
- {
- new str[60];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- if(DOF2_FileExists(str))
- {
- 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 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 if(listitem == 2)
- {
- new str[170], file[50];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(file, sizeof(file), USERS, Nome ) ;
- format(str, sizeof(str), "Ola Voce clicou em recuperaçao de conta \n Automaticamente foi enviado um email com um codigo para recuperar sua conta.\n\
- Enviado para e-mail %s .", DOF2_GetString(file, "Email"));
- ShowPlayerDialog(playerid, DIALOG_RECUPERACAO, DIALOG_STYLE_INPUT, "Recuperacao da conta", str, "Codigo", "");
- new tito[200];
- format(tito, sizeof(tito), " Bem Voce esqueceu sua senha e ativou o codigo auxiliar para recuperaçao da sua acc\n \
- Ficamos felizes que voce nao desistiu de nosso servido\n\n Codigo de recuperacao: %0.16s", DOF2_GetString(file, "CodigoRecuperacao"));
- EnviarEmail(DOF2_GetString(file, "Email"),Destinatario, "Recuperaçao da sua conta", "Recuperaçao da sua conta", tito);
- }
- }
- }
- if(dialogid == DIALOG_RECUPERACAO)
- {
- if(response)
- {
- if(!strlen(inputtext))
- {
- new str[170];
- format(str, sizeof(str), "Ola Voce clicou em recuperaçao de conta \n Automaticamente foi enviado um email com um codigo para recuperar sua conta.\n\
- Enviado para e-mail %s .", DOF2_GetString(str, "Email"));
- ShowPlayerDialog(playerid, DIALOG_RECUPERACAO, DIALOG_STYLE_INPUT, "Recuperacao da conta", str, "Codigo", "");
- return 0;
- }
- new str[170];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- if(!strcmp(inputtext, DOF2_GetString(str,"CodigoRecuperacao"),false))
- {
- SendClientMessage(playerid, -1, " Sua Conta foi recuperada com sucesso ! Use o cmd /trocarsenha");
- TrocarN[playerid] = 1;
- }
- else
- {
- format(str, sizeof(str), "Ola Voce clicou em recuperaçao de conta \n Automaticamente foi enviado um email com um codigo para recuperar sua conta.\n\
- Enviado para e-mail %s .", DOF2_GetString(str, "Email"));
- ShowPlayerDialog(playerid, DIALOG_RECUPERACAO, DIALOG_STYLE_INPUT, "Recuperacao da conta", str, "Codigo", "");
- }
- }
- }
- return 1;
- }
- CMD:trocarsenha(playerid, params[])
- {
- new novasenha[60], str[60];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- if(TrocarN[playerid] == 0) return SendClientMessage(playerid, -1, "Voce nao pode trocar a senha sem autorizacao");
- if(sscanf(params,"d[60]", novasenha))return SendClientMessage(playerid, -1, "CMD: /trocarsenha -> Nova Senha <-");
- SendClientMessage(playerid, -1, "Senha alterado com sucesso !");
- DOF2_SetString(str, "Senha", novasenha);
- TrocarN[playerid] = 0;
- DOF2_SaveFile();
- return 1;
- }
- CMD:trocaremail(playerid, params[])
- {
- new email[30], str[60];
- if(sscanf(params, "d[30]", email)) return SendClientMessage(playerid, -1,"CMD / : trocaremail [Novo Email]");
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- DOF2_SetString(str,"Email", email);
- SendClientMessage(playerid, -1," E-mail Alterado Com sucesso !");
- DOF2_SaveFile();
- return 1;
- }
- CMD:infocontaemail(playerid)
- {
- new tito[400], str[50];
- GetPlayerName( playerid , Nome, sizeof( Nome ) ) ;
- format(str, sizeof(str), USERS, Nome ) ;
- format(tito, sizeof(tito), "Ola Senhor Voce pediu informaçoes do seu char \n\nInformaçoes:\n \
- Personagem : %s \n Senha: %d \nLevel: %i\n Grana: %i \nSkin: %i \nMatou: %i\nMorreu: %i\nUtimo Login: %i:%i:%i %i:%i\n\nA Administracao do servidor agradeçe sua preferencia e deseja boas festas para voce.\n\n \n \
- Att administraçao & mau.tito\\"
- ,Nome, DOF2_GetString(str, "Senha"), GetPlayerScore(playerid), GetPlayerMoney(playerid), GetPlayerSkin(playerid), Matou[playerid],Mortes[playerid],Dia[playerid],Mes[playerid],Ano[playerid],Horas[playerid],Minutos[playerid]);
- EnviarEmail(DOF2_GetString(str, "Email"),Destinatario, "Informacoes da conta", "Informacao da Conta", tito);
- return 1;
- }
- CallBack::SalvarConta(playerid)
- {
- new file[40];
- gettime(Horas[playerid], Minutos[playerid]);
- getdate(Ano[playerid], Mes[playerid], Dia[playerid]);
- 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_SetInt(file, "Skin", GetPlayerSkin(playerid));
- DOF2_SetInt(file, "pAdmin", PlayerInfo[playerid][pAdmin]);
- DOF2_SetInt(file, "Matou", Matou[playerid]);
- DOF2_SetInt(file, "Mortes", Mortes[playerid]);
- DOF2_SetInt(file, "Dia", Dia[playerid]);
- DOF2_SetInt(file, "Mes", Mes[playerid]);
- DOF2_SetInt(file, "Ano", Ano[playerid]);
- DOF2_SetInt(file, "Horas", Horas[playerid]);
- DOF2_SetInt(file, "Minutos", Minutos[playerid]);
- DOF2_SetFloat(file, "PosX", PlayerInfo[playerid][X]);
- DOF2_SetFloat(file, "PosY", PlayerInfo[playerid][Y]);
- DOF2_SetFloat(file, "PosZ", PlayerInfo[playerid][Z]);
- 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");
- SetPlayerSkin(playerid, DOF2_GetInt(file, "Skin"));
- PlayerInfo[playerid][pAdmin] = DOF2_GetInt(file, "pAdmin");
- Matou[playerid] = DOF2_GetInt(file, "Matou");
- Mortes[playerid] = DOF2_GetInt(file, "Mortes");
- Dia[playerid] = DOF2_GetInt(file, "Dia");
- Mes[playerid] = DOF2_GetInt(file, "Mes");
- Ano[playerid] = DOF2_GetInt(file, "Ano");
- Horas[playerid] = DOF2_GetInt(file, "Horas");
- Minutos[playerid] = DOF2_GetInt(file, "Minutos");
- 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