Advertisement
Guest User

PM-BR Script By SuB_ZeRo0

a guest
May 23rd, 2010
1,644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.04 KB | None | 0 0
  1. //============================================================
  2. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  3. //        Versao: 0.1.8 || PREMIUM: SIM || SA-MP.com
  4. //              Comandos PREMIUM: /bpm & /kpm
  5. //                  Não apague os créditos!
  6. // Contato: Vá ao forum SA-MP.com Area: Portuguese/Portugues
  7. //============================================================
  8. #include <a_samp>
  9.  
  10. /*cores*/
  11. #define amarelo 0xFFFF00AA
  12. #define verde 0x33FF33AA
  13. #define vermelho 0xFF0000AA
  14. #define vermelhoescuro 0xAA3333AA
  15. #define branco 0xFFFFFFAA
  16. #define rosa 0xCCFF00FFAA
  17. #define azul 0x057ABDAA
  18. #define cinza 0xC0C0C0AA
  19. #define yellow 0xFFFF00AA
  20. #define laranja 0xFFA500AA
  21.  
  22. //Dcmd
  23. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  24. //PlayerData
  25. enum PlayerData {
  26.     Bpm,
  27.     Bmpm
  28. };
  29.  
  30. //Extras
  31. new PlayerInfo[MAX_PLAYERS][PlayerData];
  32. new stringpm[128];
  33. new kpm;
  34. new Verpms[MAX_PLAYERS];
  35. new Logpms;
  36. new ide[MAX_PLAYERS],idee[MAX_PLAYERS];
  37. #define idn ShowPlayerDialog(playerid,1604,DIALOG_STYLE_INPUT,"Mensagem Privada","Digite o ID do jogador abaixo e depois clique continuar","Continuar","Cancelar");
  38. #define pm ShowPlayerDialog(playerid,1601,DIALOG_STYLE_INPUT,"Mensagem Privada","Digite o texto abaixo e depois clique enviar","Enviar","Cancelar");
  39. #define receb1 ShowPlayerDialog(ide[playerid],1602,DIALOG_STYLE_MSGBOX,"Mensagem Privada",stringpm,"Responder","Ok");
  40. #define receb2 ShowPlayerDialog(idee[playerid],1602,DIALOG_STYLE_MSGBOX,"Mensagem Privada",stringpm,"Responder","Ok");
  41. #define resp ShowPlayerDialog(playerid,1603,DIALOG_STYLE_INPUT,"Mensagem Privada","Digite o texto abaixo e depois clique enviar","Enviar","Cancelar");
  42. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  43. // começo do sscanf -------------------------------------------------
  44. stock sscanf(string[], format[], {Float,_}:...)
  45. {
  46.     #if defined isnull
  47.         if (isnull(string))
  48.     #else
  49.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  50.     #endif
  51.         {
  52.             return format[0];
  53.         }
  54.     #pragma tabsize 4
  55.     new
  56.         formatPos = 0,
  57.         stringPos = 0,
  58.         paramPos = 2,
  59.         paramCount = numargs(),
  60.         delim = ' ';
  61.     while (string[stringPos] && string[stringPos] <= ' ')
  62.     {
  63.         stringPos++;
  64.     }
  65.     while (paramPos < paramCount && string[stringPos])
  66.     {
  67.         switch (format[formatPos++])
  68.         {
  69.             case '\0':
  70.             {
  71.                 return 0;
  72.             }
  73.             case 'i', 'd':
  74.             {
  75.                 new
  76.                     neg = 1,
  77.                     num = 0,
  78.                     ch = string[stringPos];
  79.                 if (ch == '-')
  80.                 {
  81.                     neg = -1;
  82.                     ch = string[++stringPos];
  83.                 }
  84.                 do
  85.                 {
  86.                     stringPos++;
  87.                     if ('0' <= ch <= '9')
  88.                     {
  89.                         num = (num * 10) + (ch - '0');
  90.                     }
  91.                     else
  92.                     {
  93.                         return -1;
  94.                     }
  95.                 }
  96.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  97.                 setarg(paramPos, 0, num * neg);
  98.             }
  99.             case 'h', 'x':
  100.             {
  101.                 new
  102.                     num = 0,
  103.                     ch = string[stringPos];
  104.                 do
  105.                 {
  106.                     stringPos++;
  107.                     switch (ch)
  108.                     {
  109.                         case 'x', 'X':
  110.                         {
  111.                             num = 0;
  112.                             continue;
  113.                         }
  114.                         case '0' .. '9':
  115.                         {
  116.                             num = (num << 4) | (ch - '0');
  117.                         }
  118.                         case 'a' .. 'f':
  119.                         {
  120.                             num = (num << 4) | (ch - ('a' - 10));
  121.                         }
  122.                         case 'A' .. 'F':
  123.                         {
  124.                             num = (num << 4) | (ch - ('A' - 10));
  125.                         }
  126.                         default:
  127.                         {
  128.                             return -1;
  129.                         }
  130.                     }
  131.                 }
  132.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  133.                 setarg(paramPos, 0, num);
  134.             }
  135.             case 'c':
  136.             {
  137.                 setarg(paramPos, 0, string[stringPos++]);
  138.             }
  139.             case 'f':
  140.             {
  141.                 setarg(paramPos, 0, _:floatstr(string[stringPos]));
  142.             }
  143.             case 'p':
  144.             {
  145.                 delim = format[formatPos++];
  146.                 continue;
  147.             }
  148.             case '\'':
  149.             {
  150.                 new
  151.                     end = formatPos - 1,
  152.                     ch;
  153.                 while ((ch = format[++end]) && ch != '\'') {}
  154.                 if (!ch)
  155.                 {
  156.                     return -1;
  157.                 }
  158.                 format[end] = '\0';
  159.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  160.                 {
  161.                     if (format[end + 1])
  162.                     {
  163.                         return -1;
  164.                     }
  165.                     return 0;
  166.                 }
  167.                 format[end] = '\'';
  168.                 stringPos = ch + (end - formatPos);
  169.                 formatPos = end + 1;
  170.             }
  171.             case 'u':
  172.             {
  173.                 new
  174.                     end = stringPos - 1,
  175.                     id = 0,
  176.                     bool:num = true,
  177.                     ch;
  178.                 while ((ch = string[++end]) && ch != delim)
  179.                 {
  180.                     if (num)
  181.                     {
  182.                         if ('0' <= ch <= '9')
  183.                         {
  184.                             id = (id * 10) + (ch - '0');
  185.                         }
  186.                         else
  187.                         {
  188.                             num = false;
  189.                         }
  190.                     }
  191.                 }
  192.                 if (num && IsPlayerConnected(id))
  193.                 {
  194.                     setarg(paramPos, 0, id);
  195.                 }
  196.                 else
  197.                 {
  198.                     #if !defined foreach
  199.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  200.                         #define __SSCANF_FOREACH__
  201.                     #endif
  202.                     string[end] = '\0';
  203.                     num = false;
  204.                     new
  205.                         name[MAX_PLAYER_NAME];
  206.                     id = end - stringPos;
  207.                     foreach (Player, playerid)
  208.                     {
  209.                         GetPlayerName(playerid, name, sizeof (name));
  210.                         if (!strcmp(name, string[stringPos], true, id))
  211.                         {
  212.                             setarg(paramPos, 0, playerid);
  213.                             num = true;
  214.                             break;
  215.                         }
  216.                     }
  217.                     if (!num)
  218.                     {
  219.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  220.                     }
  221.                     string[end] = ch;
  222.                     #if defined __SSCANF_FOREACH__
  223.                         #undef foreach
  224.                         #undef __SSCANF_FOREACH__
  225.                     #endif
  226.                 }
  227.                 stringPos = end;
  228.             }
  229.             case 's', 'z':
  230.             {
  231.                 new
  232.                     i = 0,
  233.                     ch;
  234.                 if (format[formatPos])
  235.                 {
  236.                     while ((ch = string[stringPos++]) && ch != delim)
  237.                     {
  238.                         setarg(paramPos, i++, ch);
  239.                     }
  240.                     if (!i)
  241.                     {
  242.                         return -1;
  243.                     }
  244.                 }
  245.                 else
  246.                 {
  247.                     while ((ch = string[stringPos++]))
  248.                     {
  249.                         setarg(paramPos, i++, ch);
  250.                     }
  251.                 }
  252.                 stringPos--;
  253.                 setarg(paramPos, i, '\0');
  254.             }
  255.             default:
  256.             {
  257.                 continue;
  258.             }
  259.         }
  260.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  261.         {
  262.             stringPos++;
  263.         }
  264.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  265.         {
  266.             stringPos++;
  267.         }
  268.         paramPos++;
  269.     }
  270.     do
  271.     {
  272.         if ((delim = format[formatPos++]) > ' ')
  273.         {
  274.             if (delim == '\'')
  275.             {
  276.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  277.             }
  278.             else if (delim != 'z')
  279.             {
  280.                 return delim;
  281.             }
  282.         }
  283.     }
  284.     while (delim > ' ');
  285.     return 0;
  286. } // termino do sscanf ----------------------------------------------------------
  287. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  288.  
  289. #if defined FILTERSCRIPT
  290. #define FILTERSCRIPT
  291.  
  292. public OnFilterScriptInit()
  293. {
  294.     print("\n==============================================");
  295.     print("  PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]");
  296.     print(" Versao: 0.1.8 || PREMIUM: SIM || SA-MP.com");
  297.     print("     Comandos PREMIUM: /bpm & /kpm");
  298.     print("==============================================\n");
  299.     SetTimer("SVP",600000,true);
  300.     if(!fexist("logpm.txt")) {new File:file=fopen("logpm.txt",io_write);fclose(file);}
  301.     return 1;
  302. }
  303. forward SVP();
  304. public SVP() {
  305.     SendClientMessageToAll(verde,"Este servidor possui Sistema de Mensagens Privadas por SuB_ZeRo0 ([SA]Smith[FG])!");
  306.     // Global Evolution Playboy 0.3a - Ip: 200.155.33.86:7777
  307.     //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  308.     return 1;
  309. }
  310.  
  311. public OnFilterScriptExit()
  312. {
  313.     return 1;
  314. }
  315.  
  316. #else
  317.  
  318. main()
  319. {
  320. }
  321.  
  322. #endif
  323. public OnPlayerDisconnect(playerid, reason)
  324. {
  325.     PlayerInfo[playerid][Bpm]=0;
  326.     PlayerInfo[playerid][Bmpm]=0;
  327.     if(Verpms[playerid]==1) {Verpms[playerid]=0;}
  328.     return 1;
  329. }
  330. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  331. public OnPlayerCommandText(playerid, cmdtext[])
  332. {
  333.     if(strcmp("/pm", cmdtext, true, 10) == 0)
  334.     {
  335.         if(PlayerInfo[playerid][Bpm]==1) return SendClientMessage(playerid,vermelhoescuro, "[PM] Você está bloqueado do uso do /pm!");
  336.         else {
  337.         idn
  338.         }
  339.         return 1;
  340.     }
  341.     if(strcmp("/blockpm", cmdtext, true, 10) == 0)
  342.     {
  343.         if(PlayerInfo[playerid][Bmpm]==0) {PlayerInfo[playerid][Bmpm]=1;SendClientMessage(playerid,amarelo,"[PM] Você habilitou seu sistema de PMs!");return 1;}
  344.         if(PlayerInfo[playerid][Bmpm]==1) {PlayerInfo[playerid][Bmpm]=0;SendClientMessage(playerid,amarelo,"[PM] Você desabilitou seu sistema de PMs!");return 1;}
  345.         return 1;
  346.     }
  347.     if(strcmp("/verpms", cmdtext, true, 10) == 0)
  348.     {
  349.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,vermelhoescuro, "[PM] Você não é Admin RCON!");
  350.         if(Verpms[playerid]==0) {Verpms[playerid]=1;SendClientMessage(playerid,amarelo,"[PM] Você habilitou o sistema para ler PMs.");return 1;}
  351.         if(Verpms[playerid]==1) {Verpms[playerid]=0;SendClientMessage(playerid,amarelo,"[PM] Você desabilitou o sistema para ler PMs.");return 1;}
  352.         return 1;
  353.     }
  354.     if(strcmp("/logpm", cmdtext, true, 10) == 0)
  355.     {
  356.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,vermelhoescuro, "[PM] Você não é Admin RCON!");
  357.         if(!fexist("logpm.txt")) return SendClientMessage(playerid,vermelhoescuro, "[PM] Arquivo 'logpm.txt' não encontrado!");
  358.         if(Logpms==0) {Logpms=1;SendClientMessage(playerid,amarelo,"[PM] Você habilitou o sistema para guardar o log das PMs.");return 1;}
  359.         if(Logpms==1) {Logpms=0;SendClientMessage(playerid,amarelo,"[PM] Você desabilitou o sistema para guardar o log das PMs.");return 1;}
  360.         return 1;
  361.     }
  362.     dcmd(bpm,3,cmdtext);
  363.     dcmd(kpm,3,cmdtext);
  364.     return 0;
  365. }
  366. dcmd_bpm(playerid,params[])
  367. {
  368.     new id,sn;
  369.     if(sscanf(params,"ii",id,sn)) SendClientMessage(playerid,vermelhoescuro, "USO: /bpm [ID] [1(SIM)/0(NAO)]");
  370.     else if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid,vermelhoescuro, "[PM] Você não é Admin RCON!");
  371.     else if(id==playerid) SendClientMessage(playerid,vermelhoescuro, "[PM] Este é o seu ID!");
  372.     else if(!IsPlayerConnected(id)) SendClientMessage(playerid,vermelhoescuro, "[PM] Este player não se encontra online!");
  373.     else {
  374.     if(sn==1) {
  375.     if(PlayerInfo[id][Bpm]==1) return SendClientMessage(id,vermelhoescuro, "[PM] Este ID já está bloqueado do uso da /pm.");
  376.     PlayerInfo[id][Bpm]=1;
  377.     SendClientMessage(id,vermelhoescuro, "[PM] Você foi bloqueado do uso da /pm.");
  378.     return 1;
  379. }
  380.     if(sn==0) {
  381.     if(PlayerInfo[id][Bpm]==0) return SendClientMessage(id,vermelhoescuro, "[PM] Este ID já está desbloqueado do uso da /pm.");
  382.     PlayerInfo[id][Bpm]=0;
  383.     SendClientMessage(id,vermelhoescuro, "[PM] Você foi desbloqueado do uso da /pm.");
  384.     return 1;
  385. }
  386.     }
  387.     return 1;
  388. }
  389. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  390. dcmd_kpm(playerid,params[])
  391. {
  392.     new sn[128];
  393.     if(sscanf(params,"s",sn)) SendClientMessage(playerid,vermelhoescuro, "USO: /kpm [SIM/NAO]");
  394.     else if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid,vermelhoescuro, "[PM] Você não é Admin RCON!");
  395.     else {
  396.     if(!strcmp(params,"sim",true)) {
  397.     if(kpm==1) {SendClientMessage(playerid,vermelhoescuro,"[PM] O /pm já está desabilitado!");return 1;}
  398.     kpm=1;
  399.     SendClientMessageToAll(vermelhoescuro, "[PM] O /pm foi desabilitado.");
  400.     return 1;
  401. }
  402.     if(!strcmp(params,"nao",true)) {
  403.     if(kpm==0) {SendClientMessage(playerid,vermelhoescuro,"[PM] O /pm já está habilitado!");return 1;}
  404.     kpm=0;
  405.     SendClientMessageToAll(vermelhoescuro, "[PM] O /pm foi habilitado.");
  406.     return 1;
  407. }
  408.     }
  409.     return 1;
  410. }
  411. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  412. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  413. {
  414.     if(dialogid == 1601)
  415.     {
  416.         if(response) { if(!inputtext[0]) {SendClientMessage(playerid,vermelhoescuro, "Coloque uma mensagem no campo indicado!"); pm return 1;}}
  417.         if(response) {
  418.         new nome2[25],nome3[25],strt[128],strtt[128];
  419.         GetPlayerName(playerid,nome2,25);
  420.         GetPlayerName(ide[playerid],nome3,25);
  421.         format(stringpm,sizeof(stringpm),"Mensagem de: %s \nTexto: %s",nome2,inputtext);
  422.         format(strtt,sizeof(strtt),"[PM] %s (ID:%i) para %s (ID:%i): %s\r\n",nome2,playerid,nome3,ide[playerid],inputtext);
  423.         format(strt,sizeof(strt),"[PM] %s (ID:%i) para %s (ID:%i): %s\r\n",nome2,playerid,nome3,ide[playerid],inputtext);
  424.         if(Logpms==1) {new File:log=fopen("logpm.txt",io_append);fwrite(log,strt);fclose(log);}
  425.         for(new i=0;i<MAX_PLAYERS;i++)
  426.             if(Verpms[i]==1) {SendClientMessage(i,amarelo,strtt);}
  427.         receb1 }
  428.         return 1;
  429.     }
  430.     if(dialogid == 1602)
  431.     {
  432.         if(response) { resp }
  433.         return 1;
  434.     }
  435.     if(dialogid == 1603)
  436.     {
  437.         if(response) { if(!inputtext[0]) {SendClientMessage(playerid,vermelhoescuro, "Coloque uma mensagem no campo indicado!"); pm return 1;}}
  438.         if(response) {
  439.         new nome[25],nome2[25],strt[128],strtt[128];
  440.         GetPlayerName(playerid,nome,25);
  441.         GetPlayerName(idee[playerid],nome2,sizeof(nome2));
  442.         format(stringpm,sizeof(stringpm),"Resposta de: %s \nTexto: %s",nome,inputtext);
  443.         format(strtt,sizeof(strtt),"[PM] %s (ID:%i) para %s (ID:%i): %s\r\n",nome,playerid,nome2,idee[playerid],inputtext);
  444.         format(strt,sizeof(strt),"[PM] %s (ID:%i) para %s (ID:%i): %s\r\n",nome,playerid,nome2,idee[playerid],inputtext);
  445.         if(Logpms==1) {new File:log=fopen("logpm.txt",io_append);fwrite(log,strt);fclose(log);}
  446.         for(new i=0;i<MAX_PLAYERS;i++)
  447.             if(Verpms[i]==1) {SendClientMessage(i,amarelo,strtt);}
  448.         if(playerid==ide[playerid]) {receb2 return 1;}
  449.         if(playerid!=ide[playerid]) {receb1 return 1;}
  450.         }
  451.         return 1;
  452.     }
  453.     if(dialogid == 1604)
  454.     {
  455.         if(response) { if(!inputtext[0]) {SendClientMessage(playerid,vermelhoescuro, "Coloque o ID do player no campo indicado!"); pm return 1;}}
  456.         if(response) {
  457.         ide[playerid] = strval(inputtext);
  458.         idee[ide[playerid]]=playerid;
  459.         if(PlayerInfo[playerid][Bmpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Seu sistema de PM está desligado. Use '/blockpm' para desbloquear!");return 1;}
  460.         if(PlayerInfo[ide[playerid]][Bmpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este ID está com o sistema de PM desligado!");return 1;}
  461.         if(PlayerInfo[idee[playerid]][Bmpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este ID está com o sistema de PM desligado!");return 1;}
  462.         if(ide[playerid]==playerid) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este é o seu ID!");return 1;}
  463.         if(!IsPlayerConnected(ide[playerid])) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este player não se encontra online!");return 1;}
  464.         if(!IsPlayerConnected(idee[playerid])) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este player não se encontra online!");return 1;}
  465.         if(PlayerInfo[ide[playerid]][Bpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este player está bloqueado do uso da /pm!");return 1;}
  466.         if(PlayerInfo[playerid][Bpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Você está bloqueado do uso da /pm!");return 1;}
  467.         if(PlayerInfo[idee[playerid]][Bpm]==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] Este player está bloqueado do uso da /pm!");return 1;}
  468.         if(kpm==1) {SendClientMessage(playerid,vermelhoescuro, "[PM] O comando /pm está desabilitado atualmente.");return 1;}
  469.         else { pm }
  470.         }
  471.         return 1;
  472.     }
  473.     return 0;
  474. }
  475. //============================================================
  476. //          PM-BR Script By SuB_ZeRo0_ [0.3] [S.A.S]
  477. //        Versao: 0.1.8 || PREMIUM: SIM || SA-MP.com
  478. //              Comandos PREMIUM: /bpm & /kpm
  479. //                  Não apague os créditos!
  480. // Contato: Vá ao forum SA-MP.com Area: Portuguese/Portugues
  481. //============================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement