Advertisement
Papadopolis

registro onebip

Aug 13th, 2013
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.05 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <a_mysql>
  4. #include <a_http>
  5.  
  6. #define DIALOG_ONEBIP 10100
  7. #define DIALOG_ONEBIP_INFO 10101
  8.  
  9. #define ONEBIP_API_FILE "OneBip/OneBipOutput"
  10.  
  11. new
  12.     _OBFilePath[41][50],
  13.     _OBOutput[200],
  14.     _OBEtapa[41],
  15.     _OBOperadora[41][10],
  16.     _OBOjr_email[41][50],
  17.     _OBOtravado[41],
  18.     Query[640]
  19. ;
  20.  
  21. //----------------------------------------------------------------------------------------------------------------------------------------
  22. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  23. {
  24.     new nick[MAX_PLAYER_NAME], email[50], passwd[50], celular[50], temp[50], out[500], registrado;
  25.    
  26.     GetPlayerName(playerid, nick, sizeof(nick));
  27.    
  28.     if(dialogid == DIALOG_ONEBIP) {
  29.         switch(_OBEtapa[playerid]) {
  30.             case -1: {
  31.                 if(response == 0) return 1;
  32.  
  33.                 _OBEtapa[playerid] = 0;
  34.                 ShowPlayerDialog(playerid,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Início", "{FFFFFF}Você já possui uma conta no OneBip?", "Sim", "Não");
  35.             }
  36.             case 0: {
  37.                 if(response == 1) {
  38.                     _OBEtapa[playerid] = 11;
  39.                     ShowPlayerDialog(playerid,  DIALOG_ONEBIP, DIALOG_STYLE_INPUT, "Registro - Onebip", "{FFFFFF}Insira abaixo o seu e-mail do OneBip:", "Continuar", "Cancelar");
  40.                 } else {
  41.                     _OBEtapa[playerid] = 1;
  42.                     OnDialogResponse(playerid, DIALOG_ONEBIP, 1, 0, "");
  43.                 }
  44.             }
  45.             case 11: {
  46.                 if(response == 0) return 1;
  47.                
  48.                 format(_OBOjr_email[playerid], 50, "%s", inputtext);
  49.                 _OBEtapa[playerid] = 12;
  50.                 ShowPlayerDialog(playerid,  DIALOG_ONEBIP, DIALOG_STYLE_INPUT, "Registro - Onebip", "{FFFFFF}Insira abaixo o sua senha do OneBip:", "Continuar", "Cancelar");
  51.             }
  52.             case 12: {
  53.                 if(response == 0) return 1;
  54.                
  55.                 if(_OBOtravado[playerid] != 1) {
  56.                     format(_OBOutput, sizeof(_OBOutput), "brazucas-server.com/OneBipCore.php?nick=%s&etapa=verificarlogin&email=%s&senha=%s", nick, _OBOjr_email[playerid], inputtext);
  57.                     HTTP(playerid, HTTP_GET, _OBOutput, "", "OnebipResponse");
  58.                 }
  59.  
  60.                 _OBOtravado[playerid] = 1;
  61.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{FFFFFF}Aguarde enquanto os dados inseridos são verificados...\n\n{999999}Pressione ESC caso o processo leve mais de um minuto.", "OK", "");
  62.             }
  63.             case 13: {
  64.                 if(response == 0) return 1;
  65.                
  66.                 _OBEtapa[playerid] = 1;
  67.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{00FF00}Login efetuado com sucesso!\n\n{999999}Clique em OK para continuar com o processo de registro.", "OK", "");
  68.             }
  69.             case 1: {
  70.                 if(response == 0) return 1;
  71.                
  72.                 new _opr = strval(inputtext);
  73.                
  74.                 format(Query, sizeof(Query), "SELECT * FROM onebip_info WHERE NICK = '%s' LIMIT 0,1", nick);
  75.                 mysql_query(Query);
  76.                 mysql_store_result();
  77.  
  78.                 if(mysql_retrieve_row()) {
  79.                     mysql_fetch_field_row(email, "ONEBIP_USER");
  80.                     mysql_fetch_field_row(passwd, "ONEBIP_PASS");
  81.                     mysql_fetch_field_row(celular, "ONEBIP_CEL");
  82.                     mysql_fetch_field_row(temp, "REGISTRADO"); registrado = strval(temp);
  83.                    
  84.                     if(registrado == 1) {
  85.                         ShowPlayerDialog(playerid,  DIALOG_ONEBIP_INFO, DIALOG_STYLE_MSGBOX, "Registro - Conta já registrada", "{FFFFFF}Você já está registrado.", "OK", "");
  86.                         return 1;
  87.                     }
  88.                    
  89.                     format(out, sizeof(out), "{FF0000}Informações já salvas sobre seus dados:\n\n{FFFFFF}Username: {00FF00}%s\n{FFFFFF}Senha: {00FF00}%s\n{FFFFFF}Celular: {00FF00}%s\n\n{FF0000}Caso os dados do seu celular estejam errados, logue em http://my.onebip.com/login\ncom os dados de login acima e faça as alterações necessárias.", email, passwd, celular);
  90.                     _OBEtapa[playerid] = 5;
  91.                     ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Cadastro encontrado!", out, "Continuar", "Cancelar");
  92.                    
  93.                     mysql_free_result();
  94.                    
  95.                     return 1;
  96.                  }
  97.                
  98.                 switch(_opr) {
  99.                     case 1: format(_OBOperadora[playerid], 10, "%s", "claro");
  100.                     case 2: format(_OBOperadora[playerid], 10, "%s", "vivo");
  101.                     case 3: format(_OBOperadora[playerid], 10, "%s", "tim");
  102.                     case 4: format(_OBOperadora[playerid], 10, "%s", "oi");
  103.                     default: {
  104.                         ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_INPUT, "Registro - Etapa 1", "{FFFFFF}Insira abaixo sua operadora:\n\n1 - Claro\n2 - Vivo\n3 - Tim\n4 - Oi", "Continuar", "Cancelar");
  105.  
  106.                         return 1;
  107.                     }
  108.                 }
  109.                
  110.                 _OBEtapa[playerid] = 2;
  111.                 OnDialogResponse(playerid, DIALOG_ONEBIP, 1, 0, "");
  112.  
  113.                 return 1;
  114.             }
  115.             case 2: {
  116.                 if(response == 0) return 1;
  117.                
  118.                 _OBEtapa[playerid] = 3;
  119.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_INPUT, "Registro - Etapa 2", "{FFFFFF}Insira abaixo o número de seu celular com DDD: (exemplo: 6192775466)", "Continuar", "Cancelar");
  120.  
  121.                 return 1;
  122.             }
  123.             case 3: {
  124.                 if(response == 0) return 1;
  125.                
  126.                 if(_OBOtravado[playerid] != 1) {
  127.                     format(_OBOutput, sizeof(_OBOutput), "brazucas-server.com/OneBipCore.php?nick=%s&etapa=1&celular=%s&operadora=%s", nick, inputtext, _OBOperadora[playerid]);
  128.                     HTTP(playerid, HTTP_GET, _OBOutput, "", "OnebipResponse");
  129.                 }
  130.                
  131.                 _OBOtravado[playerid] = 1;
  132.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{FFFFFF}Aguarde enquanto suas contas de e-mail e do onebip são criadas...\n\n{999999}Pressione ESC caso o processo leve mais de um minuto.", "OK", "");
  133.             }
  134.             case 4: {
  135.                 if(response == 0) return 1;
  136.                
  137.                 format(Query, sizeof(Query), "SELECT * FROM onebip_info WHERE NICK = '%s' LIMIT 0,1", nick);
  138.                 mysql_query(Query);
  139.                 mysql_store_result();
  140.                
  141.                 if(mysql_retrieve_row()) {
  142.                     mysql_fetch_field_row(email, "ONEBIP_USER");
  143.                     mysql_fetch_field_row(passwd, "ONEBIP_PASS");
  144.                     mysql_fetch_field_row(celular, "ONEBIP_CEL");
  145.                 }
  146.                
  147.                 mysql_free_result();
  148.                
  149.                 _OBEtapa[playerid] = 5;
  150.                
  151.                 format(out, sizeof(out), "{FF0000}Informações de sua conta do onebip:\n\n{FFFFFF}Username: {00FF00}%s\n{FFFFFF}Senha: {00FF00}%s\n{FFFFFF}Celular: {00FF00}%s\n{FFFFFF}URL para login: {00FF00}http://my.onebip.com/login\n\n{FF0000}Salve essas informações caso queira comprar créditos no futuro.", email, passwd, celular);
  152.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", out, "Continuar", "Cancelar");
  153.             }
  154.             case 5: {
  155.                 if(response == 0) return 1;
  156.                
  157.                 if(_OBOtravado[playerid] != 1) {
  158.                     format(_OBOutput, sizeof(_OBOutput), "brazucas-server.com/OneBipCore.php?nick=%s&etapa=2", nick);
  159.                     HTTP(playerid, HTTP_GET, _OBOutput, "", "OnebipResponse");
  160.                 }
  161.                
  162.                 _OBOtravado[playerid] = 1;
  163.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{FFFFFF}Aguarde enquanto o código é enviado para o seu celular...\n\n{999999}Pressione ESC caso o processo leve mais de um minuto.", "OK", "");
  164.             }
  165.             case 6: {
  166.                 if(response == 0) return 1;
  167.                
  168.                 _OBEtapa[playerid] = 7;
  169.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_INPUT, "Registro - Etapa 3", "{FFFFFF}Insira abaixo o código enviado para o seu celular:\n\n{999999}O código pode levar alguns minutos para chegar em seu celular.", "Continuar", "Cancelar");
  170.  
  171.                 return 1;
  172.             }
  173.             case 7: {
  174.                 if(response == 0) return 1;
  175.                
  176.                 new pincode = strval(inputtext);
  177.                
  178.                 if(_OBOtravado[playerid] != 1) {
  179.                     format(_OBOutput, sizeof(_OBOutput), "brazucas-server.com/OneBipCore.php?nick=%s&etapa=3&pincode=%d", nick, pincode);
  180.                     HTTP(playerid, HTTP_GET, _OBOutput, "", "OnebipResponse");
  181.                 }
  182.                
  183.                 _OBOtravado[playerid] = 1;
  184.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{FFFFFF}Aguarde, verificando o código...\n\n{999999}Pressione ESC caso o processo leve mais de um minuto.", "OK", "");
  185.             }
  186.             case 8: {
  187.                 if(response == 0) return 1;
  188.                
  189.                 _OBEtapa[playerid] = 1;
  190.                 ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Mensagem", "{00FF00}Pagamento efetuado com sucesso!", "OK", "");
  191.             }
  192.         }
  193.     }
  194.     return 0;
  195. }
  196. //----------------------------------------------------------------------------------------------------------------------------------------
  197. public OnPlayerCommandText(playerid, cmdtext[])
  198. {
  199.     new cmd[128];
  200.     new idx;
  201.     cmd = strtok(cmdtext,idx);
  202.  
  203.     if(strcmp("/novoregistro", cmd, true) == 0) {
  204.         _OBEtapa[playerid] = -1;
  205.         ShowPlayerDialog(playerid, DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Iniciar", "{FFFFFF}Para se registrar no Brazucas é necessário fazer o pagamento de uma taxa de R$4 que\npode ser feito via celular in-game, o sistema de registro foi feito desta maneira para\neliminar as chances de ter jogadores usando cheat no servidor, os R$4 gastos no pagamento\nsão convertidos em 4.000 créditos logo após o seu registro, para ler mais sobre créditos\nacesse nossa FAQ.", "Continuar", "Fechar");
  206.  
  207.         return 1;
  208.     }
  209.  
  210.     return 0;
  211. }
  212. //----------------------------------------------------------------------------------------------------------------------------------------
  213. forward OnebipResponse(index, response_code, data[]);
  214. public OnebipResponse(index, response_code, data[]) {
  215.     format(_OBFilePath[index], sizeof(_OBFilePath), "%s%d.ini", ONEBIP_API_FILE, index);
  216.  
  217.     new File:temp = fopen(_OBFilePath[index], io_write);
  218.     if(temp) {
  219.         fwrite(temp, data);
  220.         fclose(temp);
  221.     }
  222.    
  223.     switch(strval(dini_Get(_OBFilePath[index], "Etapa"))) {
  224.         case 2: {
  225.             _OBEtapa[index] = 4;
  226.             _OBOtravado[index] = 0;
  227.  
  228.             OnDialogResponse(index, DIALOG_ONEBIP, 1, 0, "");
  229.             return 1;
  230.         }
  231.         case 3: {
  232.             _OBEtapa[index] = 6;
  233.             _OBOtravado[index] = 0;
  234.  
  235.             OnDialogResponse(index, DIALOG_ONEBIP, 1, 0, "");
  236.             return 1;
  237.         }
  238.         case 5: {
  239.             _OBEtapa[index] = 8;
  240.             _OBOtravado[index] = 0;
  241.  
  242.             OnDialogResponse(index, DIALOG_ONEBIP, 1, 0, "");
  243.             return 1;
  244.         }
  245.         case 13: {
  246.             _OBEtapa[index] = 13;
  247.             _OBOtravado[index] = 0;
  248.            
  249.             OnDialogResponse(index, DIALOG_ONEBIP, 1, 0, "");
  250.         }
  251.     }
  252.    
  253.     switch(strval(dini_Get(_OBFilePath[index], "Erro"))) {
  254.         case 1: {
  255.             _OBEtapa[index] = 1;
  256.             _OBOtravado[index] = 0;
  257.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}Não foi possível criar sua conta do OneBip.\n\n{FFFFFF}Possíveis motivos para este erro acontecer:\n- O número de celular inserido é inválido.\n- O número de celular inserido já está sendo usado em outra conta.", "OK", "");
  258.             return 1;
  259.         }
  260.         case 2: {
  261.             _OBEtapa[index] = 1;
  262.             _OBOtravado[index] = 0;
  263.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}Não foi possível confirmar sua conta do OneBip, tente iniciar o processo novamente.", "OK", "");
  264.             return 1;
  265.         }
  266.         case 3: {
  267.             _OBEtapa[index] = 1;
  268.             _OBOtravado[index] = 0;
  269.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}A operadora de celular inserida não existe.", "OK", "");
  270.             return 1;
  271.         }
  272.         case 4: {
  273.             _OBEtapa[index] = 1;
  274.             _OBOtravado[index] = 0;
  275.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}Não foi possível enviar o código para o seu celular, tente iniciar o processo novamente.", "OK", "");
  276.             return 1;
  277.         }
  278.         case 5: {
  279.             _OBEtapa[index] = 1;
  280.             _OBOtravado[index] = 0;
  281.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}O código inserido está incorreto.", "OK", "");
  282.             return 1;
  283.         }
  284.         case 6: {
  285.             _OBEtapa[index] = 1;
  286.             _OBOtravado[index] = 0;
  287.             ShowPlayerDialog(index,  DIALOG_ONEBIP, DIALOG_STYLE_MSGBOX, "Registro - Erro", "{FF0000}E-mail e/ou senha incorreto(s).", "OK", "");
  288.             return 1;
  289.         }
  290.     }
  291.  
  292.     return 1;
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement