Guest User

SendMail by Mandrack_FreeZe

a guest
Oct 3rd, 2014
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.11 KB | None | 0 0
  1. /*
  2.     Send-Mail by Mandrack_FreeZe
  3.     Créditos ao 'Victor pela PSD Plugin
  4.     Créditos ao Slice pela include mailer
  5.     Créditos ao Y_Less pelo ycmd e sscanf2
  6.     Crédito a Double_O_Seven pela DOF2
  7.     www.forum.sa-mp.com/forumdisplay.php?f=56
  8.     ***NÃO RETIRE OS CRÉDITOS***
  9.     Server PHP já configurado. FS pronto para utilização.
  10. */
  11. #include <a_samp>
  12. #include <DOF2>
  13. #include <YSI\y_commands>
  14. #include <sscanf2>
  15. #define  MAILER_URL "sendmailsamp.url.ph/sendmail.php" //NÃO MODIFIQUE OU REMOVA ESTÁ LINHA!!
  16. #include <mailer>
  17.  
  18. #define loop(%0,%1) for(new %0; %0 < %1; ++%0)
  19. #define AZUL_CLARO 0x00BFFFFF
  20. #define VERMELHO 0xFF0000FF
  21. #define CINZA 0x696969FF
  22. #define VERDE 0x00FF00FF
  23.  
  24. new pAuto[MAX_PLAYERS];
  25. new pSpawn[MAX_PLAYERS];
  26. native CriarPasta(pasta[]);
  27. public OnFilterScriptInit()
  28. {
  29.     print("[Send-Mail] Configurando...");
  30.     if(!DOF2_FileExists("SendMail"))
  31.     {
  32.         CriarPasta("scriptfiles\\SendMail");
  33.     }
  34.  
  35.     if(!DOF2_FileExists("SendMail/Emails"))
  36.     {
  37.         CriarPasta("scriptfiles\\SendMail\\Emails");
  38.         print("[Send-Mail] Pastas criadas!");
  39.     }
  40.     print("\n--------------------------------------");
  41.     print(" Send-Mail by Mandrack_FreeZe Ativado");
  42.     print(" www.forum.sa-mp.com");
  43.     print("--------------------------------------\n");
  44.     return 1;
  45. }
  46.  
  47. public OnFilterScriptExit()
  48. {
  49.     DOF2_Exit();
  50.     print("\n--------------------------------------");
  51.     print(" Send-Mail by Mandrack_FreeZe Desativado");
  52.     print(" www.forum.sa-mp.com");
  53.     print("--------------------------------------\n");
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59.     pSpawn[playerid] = 0;
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerDisconnect(playerid, reason)
  64. {
  65.     pSpawn[playerid] = 0;
  66.     SendClientMessage(playerid, VERDE, "[Send-Mail] Este servidor utiliza o sistema de e-mail Send-Mail por Mandrack_FreeZe");
  67.     return 1;
  68. }
  69.  
  70. public OnPlayerSpawn(playerid)
  71. {
  72.     pSpawn[playerid] = 1;
  73.     return 1;
  74. }
  75. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  76. {
  77.     if(dialogid == 9647)
  78.     {
  79.         if(response)
  80.         {
  81.             new arquivo[60];
  82.             format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  83.             DOF2_CreateFile(arquivo);
  84.             DOF2_SetString(arquivo, "Email", inputtext);
  85.             DOF2_SetString(arquivo, "Para", "ND");
  86.             DOF2_SetString(arquivo, "Assunto", "ND");
  87.             DOF2_SaveFile();
  88.         }
  89.         return 1;
  90.     }
  91.    
  92.     if(dialogid == 8569)
  93.     {
  94.         if(response)
  95.         {
  96.             if(listitem == 0)
  97.             {
  98.                 ShowPlayerDialog(playerid,7545,DIALOG_STYLE_INPUT,"Para:","Digite o destinatario abaixo:","Proximo","Cancelar");
  99.             }
  100.             if(listitem == 1)
  101.             {
  102.                 SendClientMessage(playerid, VERDE, "Uma solicitação de troca de e-mail foi enviada aos admins online.");
  103.                 new string[100];
  104.                 format(string, sizeof(string), "O player [%d]%s está solicitando uma troca de email. Utilize /aemail.", playerid, PlayerName(playerid));
  105.                 loop(i, GetMaxPlayers())
  106.                 {
  107.                     if(IsPlayerConnected(i))
  108.                     {
  109.                         if(IsPlayerAdmin(i))
  110.                         {
  111.                             SendClientMessage(i, VERMELHO, string);
  112.                         }
  113.                     }
  114.                 }
  115.             }
  116.         }
  117.         return 1;
  118.     }
  119.    
  120.     if(dialogid == 7545)
  121.     {
  122.         if(response)
  123.         {
  124.             new arquivo[60];
  125.             format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  126.             DOF2_SetString(arquivo, "Para", inputtext);
  127.             DOF2_SaveFile();
  128.             ShowPlayerDialog(playerid,7548,DIALOG_STYLE_INPUT,"Assunto:","Digite um título abaixo:","Proximo","Cancelar");
  129.         }
  130.         return 1;
  131.     }
  132.    
  133.     if(dialogid == 7548)
  134.     {
  135.         if(response)
  136.         {
  137.             new arquivo[60];
  138.             format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  139.             DOF2_SetString(arquivo, "Assunto", inputtext);
  140.             DOF2_SaveFile();
  141.             ShowPlayerDialog(playerid,7549,DIALOG_STYLE_INPUT,"Menssagem:","Digite a menssagem abaixo:","Enviar","Cancelar");
  142.         }
  143.         return 1;
  144.     }
  145.    
  146.     if(dialogid == 7549)
  147.     {
  148.         if(response)
  149.         {
  150.             new arquivo[60], string[126];
  151.             format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  152.             SendMail(DOF2_GetString(arquivo, "Para"), DOF2_GetString(arquivo, "Email"),PlayerName(playerid),DOF2_GetString(arquivo, "Assunto"), inputtext);
  153.             format(string, sizeof(string), "E-mail enviado para: %s Assunto: %s. Verifique se o E-mail digitado é o correto.", DOF2_GetString(arquivo, "Para"), DOF2_GetString(arquivo, "Assunto"));
  154.             SendClientMessage(playerid, AZUL_CLARO, string);
  155.         }
  156.         return 1;
  157.     }
  158.     return 1;
  159. }
  160.  
  161. stock PlayerName(playerid)
  162. {
  163.     new pName[MAX_PLAYER_NAME];
  164.     GetPlayerName(playerid, pName, sizeof(pName));
  165.     return pName;
  166. }
  167.  
  168. YCMD:aemail(playerid, params[], help)
  169. {
  170.     if(pSpawn[playerid] != 1) return SendClientMessage(playerid, CINZA, "Logue antes de usar esse comando!");
  171.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, CINZA, "Você não é um Admin!");
  172.     new string[80], id;
  173.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, CINZA, "Utilize /aemail [ID]");
  174.     pAuto[id] = 1;
  175.     format(string, sizeof(string), "Você autorizou o player %s a mudar de e-mail.", PlayerName(id));
  176.     SendClientMessage(playerid, VERDE, string);
  177.     format(string, sizeof(string), "Você foi autorizado a mudar de e-mail pelo admin %s. Use /memail", PlayerName(playerid));
  178.     SendClientMessage(id, AZUL_CLARO, string);
  179.     return 1;
  180. }
  181.  
  182. YCMD:email(playerid, params[], help)
  183. {
  184.     if(pSpawn[playerid] != 1) return SendClientMessage(playerid, CINZA, "Logue antes de usar esse comando!");
  185.     new arquivo[60];
  186.     format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  187.     if(DOF2_FileExists(arquivo))
  188.     {
  189.         new email[60];
  190.         format(email, sizeof(email), "E-mail %s", DOF2_GetString(arquivo, "Email"));
  191.         ShowPlayerDialog(playerid,8569,DIALOG_STYLE_LIST,email,"Mandar E-mail\nSolicitar troca de E-mail","Selecionar","Cancelar");
  192.     } else {
  193.         ShowPlayerDialog(playerid, 9647, DIALOG_STYLE_INPUT, "Seu E-mail não está registrado!", "Digite seu e-mail abaixo corretamente por favor:\nOBS: Você só tem 1 e-mail por conta.", "Registrar","Cancelar");
  194.     }
  195.     return 1;
  196. }
  197.  
  198. YCMD:memail(playerid, params[], help)
  199. {
  200.     if(pSpawn[playerid] != 1) return SendClientMessage(playerid, CINZA, "Logue antes de usar esse comando!");
  201.     if(pAuto[playerid] != 1) return SendClientMessage(playerid, CINZA, "Você não foi autorizado! Peça autorização a um admin!");
  202.     new ss[80];
  203.     if(sscanf(params, "s[80]", ss)) return SendClientMessage(playerid, CINZA, "Utilize /memail [NOVO E-MAIL]");
  204.     new arquivo[60], string[100];
  205.     format(arquivo, sizeof(arquivo), "SendMail/Emails/%s", PlayerName(playerid));
  206.     pAuto[playerid] = 0;
  207.     if(DOF2_FileExists(arquivo))
  208.     {
  209.         DOF2_SetString(arquivo, "Email", ss);
  210.         format(string, sizeof(string), "Novo e-mail configurado: %s", ss);
  211.         SendClientMessage(playerid, VERDE, string);
  212.     } else {
  213.         ShowPlayerDialog(playerid, 9647, DIALOG_STYLE_INPUT, "Seu E-mail não está registrado!", "Digite seu email abaixo corretamente por favor:\nOBS: Você só tem 1 e-mail por conta.", "Registrar","Cancelar");
  214.     }
  215.     return 1;
  216. }
Add Comment
Please, Sign In to add comment