Advertisement
iCasTiel

cBan v0.2 - ZCMD + SSCANF

Jan 18th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 23.08 KB | None | 0 0
  1. #include a_samp
  2. #include zcmd
  3. #include sscanf2
  4.  
  5. #if defined MAX_PLAYERS
  6.     #undef MAX_PLAYERS
  7.     #define MAX_PLAYERS 20
  8. #else
  9.     #define MAX_PLAYERS 20
  10. #endif
  11.  
  12. #define Kick(%0) SetTimerEx("Kicka", 100, false, "i", %0)
  13. #define Ban(%0) SetTimerEx("Bana", 100, false, "i", %0)
  14.  
  15. #define BLACK_LIST_TIPO 8500
  16. #define DIALOG_BLACK_LIST_INSERIR_DATA_USUARIOS 8501
  17. #define DIALOG_BLACK_LIST_INSERIR_DATA_IPS 8502
  18.  
  19. #define SPLITTER /
  20.  
  21. new MonthTimes[12][4] =
  22. {
  23.         { 31, 31, 2678400, 2678400 },
  24.         { 28, 29, 2419200, 2505600 },
  25.         { 31, 31, 2678400, 2678400 },
  26.         { 30, 30, 2592000, 2592000 },
  27.         { 31, 31, 2678400, 2678400 },
  28.         { 30, 30, 2592000, 2592000 },
  29.         { 31, 31, 2678400, 2678400 },
  30.         { 31, 31, 2678400, 2678400 },
  31.         { 30, 30, 2592000, 2592000 },
  32.         { 31, 31, 2678400, 2678400 },
  33.         { 30, 30, 2592000, 2592000 },
  34.         { 31, 31, 2678400, 2678400 }
  35. };
  36.  
  37. new DB:cBan;
  38.  
  39. new Query[1024];
  40.  
  41. public OnFilterScriptInit() {
  42.  
  43.     print("\n--------------------------------------");
  44.     print("      cBan carregado com sucesso!");
  45.     print("--------------------------------------\n");
  46.    
  47.     cBan = db_open("cBan.db");
  48.  
  49.     db_free_result(db_query(cBan, "CREATE TABLE IF NOT EXISTS usuarios_banidos (id INTEGER PRIMARY KEY, nome TEXT, admin TEXT, motivo TEXT, tempo NUMERIC, data_ocorrido NUMERIC)"));
  50.     db_free_result(db_query(cBan, "CREATE TABLE IF NOT EXISTS ips_banidos (id INTEGER PRIMARY KEY, ip TEXT, admin TEXT, motivo TEXT, tempo NUMERIC, data_ocorrido NUMERIC)"));
  51.  
  52.     return 1;
  53. }
  54.  
  55. public OnFilterScriptExit() {
  56.  
  57.     db_close(cBan);
  58.     return 1;
  59. }
  60.  
  61. public OnPlayerConnect(playerid) {
  62.  
  63.     new meuNome[MAX_PLAYER_NAME], DBResult:Consulta, meuIP[16];
  64.  
  65.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  66.     GetPlayerIp(playerid, meuIP, 16);
  67.    
  68.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", meuNome);
  69.     Consulta = db_query(cBan, Query);
  70.    
  71.     if ( db_num_rows(Consulta) > 0 ) {
  72.    
  73.         new Admin[MAX_PLAYER_NAME], Motivo[64], Tempo;
  74.        
  75.         db_get_field_assoc(Consulta, "admin", Admin, MAX_PLAYER_NAME);
  76.         db_get_field_assoc(Consulta, "motivo", Motivo, 64);
  77.         db_get_field_assoc(Consulta, "tempo", Query, 1024);
  78.         Tempo = strval(Query);
  79.        
  80.         if ( Tempo != -1 ) {
  81.        
  82.             if ( gettime() >= Tempo ) {
  83.            
  84.                 format (Query, 1024, "DELETE FROM usuarios_banidos WHERE nome = '%s'", meuNome);
  85.                 db_free_result(db_query(cBan, Query));
  86.                 SendClientMessage(playerid, 0xD40000FF, "Sua conta foi desbanida! Não cometa os mesmos erros!");
  87.             }
  88.             else {
  89.            
  90.                 format (Query, 1024, "{FFFFFF}Sua conta esta banida!\n{FF0000}Informações de banimento:\n{FFFFFF}Nome da conta: {FF0000}%s\n{FFFFFF}Administrador responsável: {FF0000}%s\n{FFFFFF}Motivo do banimento:{FF0000}%s\n{FFFFFF}Data de desbanimento: {FF0000}%s", meuNome, Admin, Motivo, timestampToDate(Tempo) );
  91.                 ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FF0000}Você esta banido!", Query, "Fechar", #);
  92.                 Kick(playerid);
  93.             }
  94.         }
  95.         else {
  96.        
  97.             format (Query, 1024, "{FFFFFF}Sua conta esta banida!\n{FF0000}Informações de banimento:\n{FFFFFF}Nome da conta: {FF0000}%s\n{FFFFFF}Administrador responsável: {FF0000}%s\n{FFFFFF}Motivo do banimento:{FF0000}%s\n{FFFFFF}Data de desbanimento: {FF0000}Nunca", meuNome, Admin, Motivo );
  98.             ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FF0000}Você esta banido!", Query, "Fechar", #);
  99.             Kick(playerid);
  100.        
  101.         }
  102.     }
  103.     db_free_result(Consulta);
  104.    
  105.     format (Query, 1024, "SELECT * FROM ips_banidos WHERE ip = '%s'", meuIP);
  106.     Consulta = db_query(cBan, Query);
  107.  
  108.     if ( db_num_rows(Consulta) > 0 ) {
  109.  
  110.         new Admin[MAX_PLAYER_NAME], Motivo[64], Tempo;
  111.  
  112.         db_get_field_assoc(Consulta, "admin", Admin, MAX_PLAYER_NAME);
  113.         db_get_field_assoc(Consulta, "motivo", Motivo, 64);
  114.         db_get_field_assoc(Consulta, "tempo", Query, 1024);
  115.         Tempo = strval(Query);
  116.  
  117.         if ( Tempo != -1 ) {
  118.  
  119.             if ( gettime() >= Tempo ) {
  120.  
  121.                 format (Query, 1024, "DELETE FROM ips_banidos WHERE ip = '%s'", meuIP);
  122.                 db_free_result(db_query(cBan, Query));
  123.                 SendClientMessage(playerid, 0xD40000FF, "Seu IP foi desbanido! Não cometa os mesmos erros!");
  124.             }
  125.             else {
  126.  
  127.                 format (Query, 1024, "{FFFFFF}Seu IP esta banido!\n{FF0000}Informações de banimento:\n{FFFFFF}IP: {FF0000}%s\n{FFFFFF}Administrador responsável: {FF0000}%s\n{FFFFFF}Motivo do banimento:{FF0000}%s\n{FFFFFF}Data de desbanimento: {FF0000}%s", meuIP, Admin, Motivo, timestampToDate(Tempo) );
  128.                 ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FF0000}Você esta banido!", Query, "Fechar", #);
  129.                 Kick(playerid);
  130.             }
  131.         }
  132.         else {
  133.  
  134.             format (Query, 1024, "{FFFFFF}Seu IP esta banido!\n{FF0000}Informações de banimento:\n{FFFFFF}IP: {FF0000}%s\n{FFFFFF}Administrador responsável: {FF0000}%s\n{FFFFFF}Motivo do banimento:{FF0000}%s\n{FFFFFF}Data de desbanimento: {FF0000}Nunca", meuIP, Admin, Motivo );
  135.             ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FF0000}Você esta banido!", Query, "Fechar", #);
  136.             Kick(playerid);
  137.  
  138.         }
  139.     }
  140.     db_free_result(Consulta);
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerSpawn(playerid) {
  145.  
  146.     SendClientMessage(playerid, 0x00B655FF, "Este servidor utiliza o sistema cBan, desenvolvido por CasTiel!");
  147.     SendClientMessage(playerid, 0x00B655FF, "Você pode ver todos os comandos disponíveis do sistema utilizando /ajudaban!");
  148.     SendClientMessage(playerid, 0x00B655FF, "Consulte a lista de banidos usando /blacklist!");
  149.     return 1;
  150. }
  151.  
  152. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  153.  
  154.     switch (dialogid) {
  155.    
  156.         case BLACK_LIST_TIPO: {
  157.        
  158.             if ( response ) {
  159.            
  160.                 SendClientMessage(playerid, 0xFF0000FF, "Você optou por ver a lista de usuários banidos!");
  161.                 ShowPlayerDialog(playerid, DIALOG_BLACK_LIST_INSERIR_DATA_USUARIOS, DIALOG_STYLE_INPUT, "{FFFFFF}Black list", "{FFFFFF}Digite no campo abaixo a {FF0000}data referente aos bloqueios de usuários efetuados!\n{FF0000}OBS:{FFFFFF}Siga o padrão {FF0000}dd-mm-aaaa{FFFFFF}, exemplo (18/01/2013)!", "Ver lista", "Fechar");
  162.             }
  163.             else {
  164.            
  165.                 SendClientMessage(playerid, 0xFF0000FF, "Você optou por ver a lista de IPs banidos!");
  166.                 ShowPlayerDialog(playerid, DIALOG_BLACK_LIST_INSERIR_DATA_IPS, DIALOG_STYLE_INPUT, "{FFFFFF}Black list", "{FFFFFF}Digite no campo abaixo a {FF0000}data referente aos bloqueios de IPs efetuados!\n{FF0000}OBS:{FFFFFF}Siga o padrão {FF0000}dd-mm-aaaa{FFFFFF}, exemplo (18/01/2013)!", "Ver lista", "Fechar");
  167.             }
  168.         }
  169.         case DIALOG_BLACK_LIST_INSERIR_DATA_USUARIOS: {
  170.        
  171.             if ( response ) {
  172.            
  173.                 new timestamp;
  174.                 timestamp = DateToTimestamp(inputtext);
  175.            
  176.                 if ( strlen(inputtext) != 10 || strfind(inputtext, "/") == -1 || timestamp == -1 ) {
  177.                
  178.                     SendClientMessage(playerid, 0xFF0000FF, "Data informada não segue os padrões estabelecidos!!");
  179.                     ShowPlayerDialog(playerid, DIALOG_BLACK_LIST_INSERIR_DATA_USUARIOS, DIALOG_STYLE_INPUT, "{FFFFFF}Black list", "{FFFFFF}Digite no campo abaixo a {FF0000}data referente aos bloqueios de usuários efetuados!\n{FF0000}OBS:{FFFFFF}Siga o padrão {FF0000}dd-mm-aaaa{FFFFFF}, exemplo (18/01/2013)!", "Ver lista", "Fechar");
  180.                     return 1;
  181.                  }
  182.                
  183.                 new DBResult:Consulta;
  184.                
  185.                 format (Query, 1024, "SELECT nome, admin, motivo FROM usuarios_banidos WHERE data_ocorrido BETWEEN %d AND %d", timestamp, (timestamp + 86399) );
  186.                 Consulta = db_query(cBan, Query);
  187.                
  188.                 if (db_num_rows(Consulta) == 0 ) {
  189.                
  190.                     format (Query, 1024, "{FFFFFF}Nenhum usuário foi banido em %s", inputtext);
  191.                     ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FFFFFF}Black list", Query, "Fechar", "");
  192.                
  193.                 }
  194.                 else {
  195.  
  196.                     new Nome[MAX_PLAYER_NAME], Admin[MAX_PLAYER_NAME], Motivo[64], str[128];
  197.                    
  198.                     Query[0] = EOS;
  199.                    
  200.                     do {
  201.  
  202.                         db_get_field_assoc(Consulta, "nome", Nome, MAX_PLAYER_NAME);
  203.                         db_get_field_assoc(Consulta, "admin", Admin, MAX_PLAYER_NAME);
  204.                         db_get_field_assoc(Consulta, "motivo", Motivo, 64);
  205.                         format (str, 128, "{FF0000}Nome: {FFFFFF}%s - {FF0000}Admin responsável:{FFFFFF}%s - {FF0000}Motivo: {FFFFFF}%s\n", Nome, Admin, Motivo);
  206.                         strcat(Query, str);
  207.                     }
  208.                     while( db_next_row(Consulta) );
  209.                    
  210.                     format (str, 128, "{FFFFFF}Lista de usuários banidos em {FF0000}%s", inputtext);
  211.                     ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, str, Query, "Fechar", #);
  212.                
  213.                 }
  214.                 db_free_result(Consulta);
  215.             }
  216.         }
  217.         case DIALOG_BLACK_LIST_INSERIR_DATA_IPS: {
  218.  
  219.             if ( response ) {
  220.  
  221.                 new timestamp;
  222.                 timestamp = DateToTimestamp(inputtext);
  223.  
  224.                 if ( strlen(inputtext) != 10 || strfind(inputtext, "/") == -1 || timestamp == -1 ) {
  225.  
  226.                     SendClientMessage(playerid, 0xFF0000FF, "Data informada não segue os padrões estabelecidos!!");
  227.                     ShowPlayerDialog(playerid, DIALOG_BLACK_LIST_INSERIR_DATA_USUARIOS, DIALOG_STYLE_INPUT, "{FFFFFF}Black list", "{FFFFFF}Digite no campo abaixo a {FF0000}data referente aos bloqueios de usuários efetuados!\n{FF0000}OBS:{FFFFFF}Siga o padrão {FF0000}dd-mm-aaaa{FFFFFF}, exemplo (18/01/2013)!", "Ver lista", "Fechar");
  228.                     return 1;
  229.                  }
  230.  
  231.                 new DBResult:Consulta;
  232.  
  233.                 format (Query, 1024, "SELECT ip, admin, motivo FROM ips_banidos WHERE data_ocorrido BETWEEN %d AND %d", timestamp, (timestamp + 86399) );
  234.                 Consulta = db_query(cBan, Query);
  235.  
  236.                 if (db_num_rows(Consulta) == 0 ) {
  237.  
  238.                     format (Query, 1024, "{FFFFFF}Nenhum IP foi banido em %s", inputtext);
  239.                     ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "{FFFFFF}Black list", Query, "Fechar", "");
  240.  
  241.                 }
  242.                 else {
  243.  
  244.                     new IP[16], Admin[MAX_PLAYER_NAME], Motivo[64], str[128];
  245.  
  246.                     Query[0] = EOS;
  247.  
  248.                     do {
  249.  
  250.                         db_get_field_assoc(Consulta, "ip", IP, 16);
  251.                         db_get_field_assoc(Consulta, "admin", Admin, MAX_PLAYER_NAME);
  252.                         db_get_field_assoc(Consulta, "motivo", Motivo, 64);
  253.                         format (str, 128, "{FF0000}IP: {FFFFFF}%s - {FF0000}Admin responsável:{FFFFFF}%s - {FF0000}Motivo: {FFFFFF}%s\n", IP, Admin, Motivo);
  254.                         strcat(Query, str);
  255.                     }
  256.                     while( db_next_row(Consulta) );
  257.  
  258.                     format (str, 128, "{FFFFFF}Lista de IPs banidos em {FF0000}%s", inputtext);
  259.                     ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, str, Query, "Fechar", #);
  260.  
  261.                 }
  262.                 db_free_result(Consulta);
  263.             }
  264.         }
  265.     }
  266.     return 1;
  267. }
  268.  
  269.  
  270. /* Funções */
  271.  
  272.  
  273.  
  274. stock IsLeapYear(year)
  275. {
  276.         if(year % 4 == 0) return 1;
  277.         else return 0;
  278. }
  279.  
  280. stock DateToTimestamp(str[]) {
  281.  
  282.         new date[3]; // date[0] = day           date[1] = month                 date[2] = year
  283.         if(!sscanf(str,"p<"#SPLITTER">ddd",date[0],date[1],date[2]))
  284.         {
  285.                 new total = 0, tmp = 0;
  286.                 total += date[0] * 86400;
  287.                 if(date[1] == 2 && date[0] < 29) tmp = ((date[2] - 1968) / 4 - 2);
  288.                 else tmp = ((date[2] - 1968) / 4 - 1);
  289.                 total += tmp * 31622400;
  290.                 total += (date[2] - 1970 - tmp) * 31536000;
  291.                 for(new i = 1; i < date[1]; i ++) total += MonthTimes[i][0 + IsLeapYear(date[2])] * 86400;
  292.                 return total;
  293.         }
  294.         else return -1;
  295. }
  296.  
  297. stock banirConta(nome[], admin[], motivo[], tempo = -1 ) {
  298.  
  299.     format (Query, 1024, "INSERT INTO usuarios_banidos (nome, admin, motivo, tempo, data_ocorrido) VALUES ('%s', '%s', '%s', '%d', '%d')", nome, admin, motivo, tempo, gettime());
  300.     db_free_result(db_query(cBan, Query));
  301.  
  302.     return 1;
  303. }
  304.  
  305. stock banirIP(ip[], admin[], motivo[], tempo = -1) {
  306.  
  307.     format (Query, 1024, "INSERT INTO ips_banidos (ip, admin, motivo, tempo, data_ocorrido) VALUES ('%s', '%s', '%s', '%d', '%d')", ip, admin, motivo, tempo, gettime());
  308.     db_free_result(db_query(cBan, Query));
  309.  
  310.     return 1;
  311. }
  312.  
  313. stock desbanirConta(conta[]) {
  314.  
  315.     format (Query, 1024, "DELETE FROM usuarios_banidos WHERE nome = '%s'", conta);
  316.     db_free_result(db_query(cBan, Query));
  317.     return 1;
  318. }
  319.  
  320. stock desbanirIP(ip[]) {
  321.  
  322.     format (Query, 1024, "DELETE FROM ips_banidos WHERE ip = '%s'", ip);
  323.     db_free_result(db_query(cBan, Query));
  324.     return 1;
  325. }
  326.  
  327. stock timestampToDate(time) {
  328.  
  329.     new date[20], DBResult:Data, str[55];
  330.    
  331.     format (str, 55, "SELECT datetime(%d, 'unixepoch', 'localtime')" ,time);
  332.     Data = db_query(cBan, str);
  333.     db_get_field(Data, 0, date, 20);
  334.     db_free_result(Data);
  335.     return date;
  336. }
  337.  
  338. /* Fim funções */
  339.  
  340. /* Comandos */
  341. CMD:ban(playerid, params[]) {
  342.  
  343.     if (!IsPlayerAdmin(playerid))
  344.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  345.  
  346.     new id_, motivo_[64];
  347.  
  348.     if (sscanf(params, "us[64]", id_, motivo_))
  349.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /ban [ID/NOME] [MOTIVO]");
  350.  
  351.     if (!IsPlayerConnected(id_))
  352.         return SendClientMessage(playerid, 0xFF0000FF, "Jogador offline!");
  353.  
  354.     new nome_[MAX_PLAYER_NAME], meuNome[MAX_PLAYER_NAME];
  355.     GetPlayerName(id_, nome_, MAX_PLAYER_NAME);
  356.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  357.  
  358.     new DBResult:verificarConta;
  359.  
  360.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", nome_);
  361.     verificarConta = db_query(cBan, Query);
  362.  
  363.     if ( db_num_rows(verificarConta) > 0 )
  364.         return SendClientMessage(playerid, 0xFF0000FF, "Esta conta ja se encontra BANIDA!");
  365.  
  366.     db_free_result(verificarConta);
  367.  
  368.     banirConta(nome_, meuNome, motivo_);
  369.  
  370.     format (Query, 1024, "AdmCmd: %s[ID: %d] foi banido por %s[ID: %d] motivo: %s", nome_, id_, meuNome, playerid, motivo_);
  371.     SendClientMessageToAll(0xFF6347AA, Query);
  372.     Kick(id_);
  373.  
  374.     return 1;
  375. }
  376.  
  377. CMD:bantemp(playerid, params[]) {
  378.  
  379.     if (!IsPlayerAdmin(playerid))
  380.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  381.  
  382.     new id_, motivo_[64], dias_;
  383.  
  384.     if (sscanf(params, "uds[64]", id_, dias_, motivo_))
  385.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /bantemp [ID/NOME] [DIAS] [MOTIVO]");
  386.  
  387.     if (dias_ <= 0)
  388.         return SendClientMessage(playerid, 0xFF0000FF, "Número de dias inválido!");
  389.  
  390.     if (!IsPlayerConnected(id_))
  391.         return SendClientMessage(playerid, 0xFF0000FF, "Jogador offline!");
  392.  
  393.     new nome_[MAX_PLAYER_NAME], meuNome[MAX_PLAYER_NAME];
  394.     GetPlayerName(id_, nome_, MAX_PLAYER_NAME);
  395.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  396.  
  397.     new DBResult:verificarConta;
  398.  
  399.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", nome_);
  400.     verificarConta = db_query(cBan, Query);
  401.  
  402.     if ( db_num_rows(verificarConta) > 0 )
  403.         return SendClientMessage(playerid, 0xFF0000FF, "Esta conta ja se encontra BANIDA!");
  404.  
  405.     db_free_result(verificarConta);
  406.  
  407.     banirConta(nome_, meuNome, motivo_, (gettime() + (dias_ * 86400)));
  408.  
  409.     format (Query, 1024, "AdmCmd: %s[ID: %d] foi banido temporariamente (%d dia(s)) por %s[ID: %d] motivo: %s", nome_, id_, dias_, meuNome, playerid, motivo_);
  410.     SendClientMessageToAll(0xFF6347AA, Query);
  411.     Kick(id_);
  412.  
  413.     return 1;
  414. }
  415.  
  416. CMD:banconta(playerid, params[]) {
  417.  
  418.     if (!IsPlayerAdmin(playerid))
  419.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  420.  
  421.     new conta_[MAX_PLAYER_NAME], motivo_[64];
  422.  
  423.     if (sscanf(params, "s[24]s[64]", conta_, motivo_))
  424.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /banconta [NOME DA CONTA] [MOTIVO]");
  425.  
  426.     new DBResult:verificarConta;
  427.  
  428.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", conta_);
  429.     verificarConta = db_query(cBan, Query);
  430.  
  431.     if ( db_num_rows(verificarConta) > 0 )
  432.         return SendClientMessage(playerid, 0xFF0000FF, "Esta conta ja se encontra BANIDA!");
  433.  
  434.     db_free_result(verificarConta);
  435.  
  436.     new meuNome[MAX_PLAYER_NAME];
  437.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  438.  
  439.     banirConta(conta_, meuNome, motivo_);
  440.  
  441.     format (Query, 1024, "AdmCmd: %s foi banido por %s[ID: %d] motivo: %s", conta_, meuNome, playerid, motivo_);
  442.     SendClientMessageToAll(0xFF6347AA, Query);
  443.  
  444.     new i, NOME2_[MAX_PLAYER_NAME];
  445.  
  446.     for ( i = 0; i < MAX_PLAYERS; ++i) {
  447.  
  448.         if (IsPlayerConnected(i)) {
  449.  
  450.             GetPlayerName(i, NOME2_, MAX_PLAYER_NAME);
  451.             if (!strcmp(conta_, NOME2_)) {
  452.  
  453.                 Kick(i);
  454.                 break;
  455.             }
  456.         }
  457.     }
  458.  
  459.     return 1;
  460. }
  461.  
  462. CMD:bantempconta(playerid, params[]) {
  463.  
  464.     if (!IsPlayerAdmin(playerid))
  465.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  466.  
  467.     new conta_[MAX_PLAYER_NAME], motivo_[64], dias_;
  468.  
  469.     if (sscanf(params, "s[24]ds[64]", conta_, dias_, motivo_))
  470.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /bantempconta [NOME DA CONTA] [DIAS] [MOTIVO]");
  471.  
  472.     if (dias_ <= 0)
  473.         return SendClientMessage(playerid, 0xFF0000FF, "Número de dias inválido!");
  474.  
  475.     new DBResult:verificarConta;
  476.  
  477.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", conta_);
  478.     verificarConta = db_query(cBan, Query);
  479.  
  480.     if ( db_num_rows(verificarConta) > 0 )
  481.         return SendClientMessage(playerid, 0xFF0000FF, "Esta conta ja se encontra BANIDA!");
  482.  
  483.     db_free_result(verificarConta);
  484.  
  485.     new meuNome[MAX_PLAYER_NAME];
  486.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  487.  
  488.     banirConta(conta_, meuNome, motivo_, (gettime() + (dias_ * 86400)));
  489.  
  490.     format (Query, 1024, "AdmCmd: %s foi banido temporariamente (%d dia(s)) por %s[ID: %d] motivo: %s", conta_, dias_, meuNome, playerid, motivo_);
  491.     SendClientMessageToAll(0xFF6347AA, Query);
  492.  
  493.     new i, NOME2_[MAX_PLAYER_NAME];
  494.  
  495.     for ( i = 0; i < MAX_PLAYERS; ++i) {
  496.  
  497.         if (IsPlayerConnected(i)) {
  498.  
  499.             GetPlayerName(i, NOME2_, MAX_PLAYER_NAME);
  500.             if (!strcmp(conta_, NOME2_)) {
  501.            
  502.                 Kick(i);
  503.                 break;
  504.             }
  505.         }
  506.     }
  507.  
  508.     return 1;
  509. }
  510.  
  511. CMD:banip(playerid, params[]) {
  512.  
  513.     if (!IsPlayerAdmin(playerid))
  514.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  515.  
  516.     new ip_[16], motivo_[64];
  517.  
  518.     if (sscanf(params, "s[16]s[64]", ip_, motivo_))
  519.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /banip [IP] [MOTIVO]");
  520.  
  521.     new DBResult:verificarIP;
  522.  
  523.     format (Query, 1024, "SELECT * FROM ips_banidos WHERE ip = '%s'", ip_);
  524.     verificarIP = db_query(cBan, Query);
  525.  
  526.     if ( db_num_rows(verificarIP) > 0 )
  527.         return SendClientMessage(playerid, 0xFF0000FF, "Este IP ja se encontra BANIDO!");
  528.  
  529.     db_free_result(verificarIP);
  530.  
  531.     new meuNome[MAX_PLAYER_NAME];
  532.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  533.  
  534.     banirIP(ip_, meuNome, motivo_);
  535.  
  536.     format (Query, 1024, "AdmCmd: O IP %s foi banido por %s[ID: %d] motivo: %s", ip_, meuNome, playerid, motivo_);
  537.     SendClientMessageToAll(0xFF6347AA, Query);
  538.  
  539.     new i, IP2_[16];
  540.  
  541.     for ( i = 0; i < MAX_PLAYERS; ++i) {
  542.  
  543.         if (IsPlayerConnected(i)) {
  544.  
  545.             GetPlayerIp(i, IP2_, 16);
  546.             if (!strcmp(ip_, IP2_))
  547.                 Kick(i);
  548.         }
  549.     }
  550.  
  551.     return 1;
  552. }
  553.  
  554. CMD:baniptemp(playerid, params[]) {
  555.  
  556.     if (!IsPlayerAdmin(playerid))
  557.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  558.  
  559.     new ip_[16], motivo_[64], dias_;
  560.  
  561.     if (sscanf(params, "s[16]ds[64]", ip_, dias_, motivo_))
  562.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /banip [IP] [DIAS] [MOTIVO]");
  563.  
  564.     if (dias_ <= 0)
  565.         return SendClientMessage(playerid, 0xFF0000FF, "Número de dias inválido!");
  566.  
  567.     new DBResult:verificarIP;
  568.  
  569.     format (Query, 1024, "SELECT * FROM ips_banidos WHERE ip = '%s'", ip_);
  570.     verificarIP = db_query(cBan, Query);
  571.  
  572.     if ( db_num_rows(verificarIP) > 0 )
  573.         return SendClientMessage(playerid, 0xFF0000FF, "Este IP ja se encontra BANIDO!");
  574.  
  575.     db_free_result(verificarIP);
  576.  
  577.     new meuNome[MAX_PLAYER_NAME];
  578.     GetPlayerName(playerid, meuNome, MAX_PLAYER_NAME);
  579.  
  580.     banirIP(ip_, meuNome, motivo_, (gettime() + (dias_ * 86400)));
  581.  
  582.     format (Query, 1024, "AdmCmd: O IP %s foi banido temporariamente( %d dia(s) ) por %s[ID: %d] motivo: %s", ip_, dias_, meuNome, playerid, motivo_);
  583.     SendClientMessageToAll(0xFF6347AA, Query);
  584.  
  585.     new i, IP2_[16];
  586.  
  587.     for ( i = 0; i < MAX_PLAYERS; ++i) {
  588.  
  589.         if (IsPlayerConnected(i)) {
  590.  
  591.             GetPlayerIp(i, IP2_, 16);
  592.             if (!strcmp(ip_, IP2_))
  593.                 Kick(i);
  594.         }
  595.     }
  596.  
  597.     return 1;
  598. }
  599.  
  600. CMD:desbanconta(playerid, params[]) {
  601.  
  602.     if (!IsPlayerAdmin(playerid))
  603.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  604.  
  605.     if (isnull(params))
  606.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /desbanconta [CONTA]");
  607.  
  608.     new DBResult:verificarConta;
  609.  
  610.     format (Query, 1024, "SELECT * FROM usuarios_banidos WHERE nome = '%s'", params);
  611.     verificarConta = db_query(cBan, Query);
  612.  
  613.     if ( db_num_rows(verificarConta) > 0 ) {
  614.  
  615.         desbanirConta(params);
  616.         format (Query, 1024, "AdmCmd: A conta %s foi desbanida com sucesso!", params);
  617.         SendClientMessage(playerid, 0xFF6347AA, Query);
  618.     }
  619.     else
  620.         SendClientMessage(playerid, 0xFF0000FF, "Nenhum usuário com este nome esta banido!");
  621.  
  622.     db_free_result(verificarConta);
  623.  
  624.     return 1;
  625. }
  626.  
  627. CMD:desbanip(playerid, params[]) {
  628.  
  629.     if (!IsPlayerAdmin(playerid))
  630.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  631.  
  632.     if (isnull(params))
  633.         return SendClientMessage(playerid, 0xFF0000FF, "Uso correto: /desbanip [IP]");
  634.  
  635.     new DBResult:verificarIP;
  636.  
  637.     format (Query, 1024, "SELECT * FROM ips_banidos WHERE ip = '%s'", params);
  638.     verificarIP = db_query(cBan, Query);
  639.  
  640.     if ( db_num_rows(verificarIP) > 0 ) {
  641.  
  642.         desbanirIP(params);
  643.         format (Query, 1024, "AdmCmd: O IP %s foi desbanido com sucesso!", params);
  644.         SendClientMessage(playerid, 0xFF6347AA, Query);
  645.     }
  646.     else
  647.         SendClientMessage(playerid, 0xFF0000FF, "IP informado não esta banido!");
  648.  
  649.     db_free_result(verificarIP);
  650.  
  651.     return 1;
  652. }
  653.  
  654. CMD:blacklist(playerid) {
  655.  
  656.     ShowPlayerDialog(playerid, BLACK_LIST_TIPO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Black list", "{FFFFFF}Clique em {FF0000}Usuários {FFFFFF}se você deseja {FF0000}ver a lista de usuários banidos {FFFFFF}ou em {FF0000}IPs {FFFFFF}caso queira {FF0000}ver a lista de IPs bloqueados!", "Usuários", "IPs");
  657.     return 1;
  658. }
  659.  
  660. CMD:ajudaban(playerid) {
  661.  
  662.     if (!IsPlayerAdmin(playerid))
  663.         return SendClientMessage(playerid, 0xFF0000FF, "Comando restrito a administradores RCON!");
  664.  
  665.     ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Menu de ajuda do cBan!", "\t{FF0000}Comandos disponíveis!\n{FFFFFF}/ban\n{FFFFFF}/bantemp\n{FFFFFF}/banconta\n{FFFFFF}/bantempconta\n{FFFFFF}/banip\n{FFFFFF}/baniptemp\n{FFFFFF}/desbanconta\n{FFFFFF}/desbanip\n{FFFFFF}/blacklist", "Fechar", #);
  666.  
  667.     return 1;
  668. }
  669.  
  670. forward Kicka(p); public Kicka(p) {
  671.     #undef Kick
  672.     Kick(p);
  673.     #define Kick(%0) SetTimerEx("Kicka", 100, false, "i", %0)
  674.     return 1;
  675. }
  676.  
  677. forward Bana(p); public Bana(p) {
  678.     #undef Ban
  679.     Ban(p);
  680.     #define Ban(%0) SetTimerEx("Bana", 100, false, "i", %0)
  681.     return 1;
  682. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement