Advertisement
DelKxD

Sisteme de Ban feito por: DelK

Sep 7th, 2017
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 10.93 KB | None | 0 0
  1. //=============[ Defines ]=======================//
  2. #define FILTERSCRIPT
  3. #if defined FILTERSCRIPT
  4. #define ConvertDays(%0) (gettime() + (86400 * (%0)))
  5. #define CorBan  0x058AFFFF
  6.  
  7. //=============[ Includes ]======================//
  8. #include <a_samp>
  9. #include <zcmd>
  10. #include <sscanf2>
  11. #include <DOF2>
  12.  
  13. //=============[ Variaveis ]=====================//
  14. enum Info
  15. {
  16.     Banido
  17. }
  18.  
  19. new Player[MAX_PLAYERS][Info];
  20. new D, Mes, A, H, M, S, Tempo[24], Data[24], DString[250];
  21.  
  22. public OnFilterScriptInit()
  23. {
  24.     print("¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨");
  25.     print("¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨");
  26.     print("¨¨Sistema de Ban feito por: DelK Carregado com Exîto.¨¨\n");
  27.     print("¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨[ Sistema DBan/v1.0 ]¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨");
  28.     print("¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨");
  29.     print("¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨");
  30.     return 1;
  31. }
  32.  
  33. #endif
  34.  
  35. public OnPlayerConnect(playerid)
  36. {
  37.     new Arquivo[64];
  38.     format(Arquivo, sizeof(Arquivo), "TempBan/%s.ini", PegarNome(playerid));
  39.     if(DOF2_FileExists(Arquivo))
  40.     {
  41.         Player[playerid][Banido] = DOF2_GetInt(Arquivo,"Dias");
  42.         if(VerifyExpiredDays(Player[playerid][Banido]))
  43.         {
  44.             DOF2_RemoveFile(Arquivo);
  45.             Player[playerid][Banido] = 0;
  46.             SendClientMessage(playerid, CorBan, "Seu ban temporário chegou ao fim.!");
  47.         }
  48.         else
  49.         {
  50.             SetTimerEx("KickBan",300, false, "i", playerid);
  51.             format(DString, sizeof(DString), "{FFFFF0}Seu IP: {FF4040}%s{FFFFF0}\n\nSeu Nick: {FF4040}%s{FFFFF0}\n\nBanido por: {FF4040}%s{FFFFF0}\n\nMotivo do Ban: {FF4040}%s{FFFFF0}\n\nTempo Restante: {FF4040}%s.", Pegarip(playerid), PegarNome(playerid), DOF2_GetString(Arquivo, "Admin"), DOF2_GetString(Arquivo, "Motivo"), ConvertToDays(Player[playerid][Banido]));
  52.             ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Sistema de Ban", DString, "Ok", "");
  53.         }
  54.     }
  55.     new Arquivo2[64];
  56.     format(Arquivo2, sizeof(Arquivo2), "Banidos/%s.ini", Pegarip(playerid));
  57.     if(DOF2_FileExists(Arquivo2))
  58.     {
  59.         format(DString, sizeof(DString), "{FFFFF0}Seu IP: {FF4040}%s{FFFFF0}\n\nSeu Nick: {FF4040}%s{FFFFF0}\n\nBanido por: {FF4040}%s{FFFFF0}\n\nMotivo do Ban: {FF4040}%s{FFFFF0}", Pegarip(playerid), PegarNome(playerid), DOF2_GetString(Arquivo2, "Admin"), DOF2_GetString(Arquivo2, "Motivo"));
  60.         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_MSGBOX, "Sistema de Ban", DString, "Ok", "");
  61.         SetTimerEx("KickBan",300, false, "i", playerid);
  62.         return 1;
  63.     }
  64.     new Arquivo3[64];
  65.     format(Arquivo3, sizeof(Arquivo3), "BansAgendados/%s.ini", PegarNome(playerid));
  66.     if(DOF2_FileExists(Arquivo3))
  67.     {
  68.         Player[playerid][Banido] = DOF2_GetInt(Arquivo3,"Dias");
  69.         if(VerifyExpiredDays(Player[playerid][Banido]))
  70.         {
  71.             DOF2_RemoveFile(Arquivo3);
  72.             Player[playerid][Banido] = 0;
  73.             SendClientMessage(playerid, CorBan, "Seu ban temporário chegou ao fim.!");
  74.         }
  75.         else
  76.         {
  77.             SetTimerEx("KickBan",300, false, "i", playerid);
  78.             format(DString, sizeof(DString), "{FFFFF0}Seu Nick: {FF4040}%s{FFFFF0}\n\nBanido por: {FF4040}%s{FFFFF0}\n\nMotivo do Ban: {FF4040}%s{FFFFF0}\n\nTempo Restante: {FF4040}%s{FFFFF0}.", PegarNome(playerid), DOF2_GetString(Arquivo3, "Admin"), DOF2_GetString(Arquivo3, "Motivo"), ConvertToDays(DOF2_GetInt(Arquivo3, "Dias")));
  79.             ShowPlayerDialog(playerid, 4, DIALOG_STYLE_MSGBOX, "Ban Agendado", DString, "Ok", "");
  80.         }
  81.     }
  82.     return 1;
  83. }
  84.  
  85. CMD:desban(playerid, params[])
  86. {
  87.     new nick[24], Arquivo[64];
  88.     if(sscanf(params, "s[24]", nick)) return SendClientMessage(playerid, CorBan, "Uso: /desban [nick]");
  89.     format(Arquivo, 64, "Banidos/%s.ini", nick);//Desbanindo Ip
  90.     format(Arquivo, 64, "Banidos/%s.ini", Pegarip(playerid));//Desbanindo Nick
  91.     if(!DOF2_FileExists(Arquivo)) return SendClientMessage(playerid, CorBan,"Está conta não se encontra banida.");
  92.     if(DOF2_FileExists(Arquivo))
  93.     {
  94.         DOF2_RemoveFile(Arquivo);
  95.         SendClientMessage(playerid, CorBan, "Conta retirada da lista de bans com sucesso.");
  96.     }
  97.     return 1;
  98. }
  99.  
  100. CMD:cancelarban(playerid, params[])
  101. {
  102.     new nick[16], Motivo[50], Arquivo[64];
  103.     if(sscanf(params,"s[16]s[50]", nick, Motivo)) return SendClientMessage(playerid, -1, "Use: /agendarban [nick] [motivo]");
  104.     format(DString, sizeof(DString), "{FFFFF0}%s Cancelou o ban de {FF4040}%s{FFFFF0} | Motivo: {FF4040}%s", PegarNome(playerid), nick, Motivo);
  105.     SendClientMessageToAll(CorBan, DString);
  106.     format(Arquivo, sizeof(Arquivo), "BansAgendados/%s.ini", nick);
  107.     if(!DOF2_FileExists(Arquivo)) return SendClientMessage(playerid, CorBan," Está conta não se encontra na agenda.");
  108.     DOF2_RemoveFile(Arquivo);
  109.     return 1;
  110. }
  111.  
  112. CMD:agendarban(playerid, params[])//Faz uma agenda de ban para o player que sair do servidor, vc agenda e quando ele logar de novo será banido automaticamente.
  113. {
  114.     new nick[16], Dias, Motivo[50];
  115.     if(sscanf(params,"s[16]ds[50]", nick, Dias, Motivo)) return SendClientMessage(playerid, -1, "Use: /agendarban [nick] [dias] [motivo]");
  116.     format(DString, sizeof(DString), "{FFFFF0}%s Agendou o ban de {FF4040}%s{FFFFF0} por: {FF4040}%d {FFFFF0}dias | Motivo: {FF4040}%s", PegarNome(playerid), nick, Dias, Motivo);
  117.     SendClientMessageToAll(CorBan, DString);
  118.     new Arquivo[64];
  119.     format(Arquivo, sizeof(Arquivo), "BansAgendados/%s.ini", nick);
  120.     DOF2_CreateFile(Arquivo);
  121.     Dias = ConvertDays(Dias);
  122.     DOF2_SetString(Arquivo, "Nick", nick);
  123.     DOF2_SetString(Arquivo, "Admin", PegarNome(playerid));
  124.     DOF2_SetString(Arquivo, "Motivo", Motivo);
  125.     DOF2_SetInt(Arquivo, "Dias", Dias);
  126.     DOF2_SaveFile();
  127.     return 1;
  128. }
  129.  
  130. CMD:tempban(playerid, params[])
  131. {
  132.     new nick, Dias, Motivo[50];
  133.     if(sscanf(params, "uds[50]", nick, Dias, Motivo)) return SendClientMessage(playerid, -1, "Uso: /tempban [nick ou id] [dias] [motivo]");
  134.     if(!IsPlayerConnected(nick)) return SendClientMessage(playerid, -1, "Este id não está conectado");
  135.     format(DString, sizeof(DString), "{FFFFF0}%s Baniu {FF4040}%s{FFFFF0} por: {FF4040}%d{FFFFF0} dias | Motivo: {FF4040}%s", PegarNome(playerid), PegarNome(nick), Dias, Motivo);
  136.     SendClientMessageToAll(CorBan, DString);
  137.     DTempBan(nick, playerid, Dias, Motivo);
  138.     return 1;
  139. }
  140.  
  141. CMD:banirip(playerid, params[])
  142. {
  143.     new ip[16], motivo[50], Arquivo[64];
  144.     if(sscanf(params, "s[16]s[50]", ip, motivo)) return SendClientMessage(playerid, -1, "Uso: /banirip [IP] [motivo]");
  145.     format(DString, sizeof(DString), "{FFFFF0}%s Bloqueou a entrada do ip: {FF4040}%s{FFFFF0} | Motivo: {FF4040}%s.", PegarNome(playerid), ip, motivo);
  146.     SendClientMessageToAll(CorBan, DString);
  147.     format(Arquivo, 64, "Banidos/%s.ini", ip);//Banindo Ip
  148.     DOF2_CreateFile(Arquivo);
  149.     DOF2_SetString(Arquivo, "Admin", PegarNome(playerid));
  150.     DOF2_SetString(Arquivo, "Motivo", motivo);
  151.     DOF2_SaveFile();
  152.     return 1;
  153. }
  154.  
  155. CMD:ban(playerid, params[])
  156. {
  157.     new id, Motivo[50];
  158.     if(sscanf(params, "us[50]", id, Motivo)) return SendClientMessage(playerid, -1, "Uso: /ban [nick ou id] [motivo]");
  159.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Este id não está conectado");
  160.     format(DString, sizeof(DString), "{FF4040}%s{FFFFF0} Teve sua conta banida permantentemente pelo administrador: {FF4040}%s{FFFFF0} | Motivo: {FF4040}%s.", PegarNome(id), PegarNome(playerid), Motivo);
  161.     SendClientMessageToAll(CorBan, DString);
  162.     DBan(id, playerid, Motivo);
  163.     return 1;
  164. }
  165.  
  166. CMD:pegarip(playerid, params[])
  167. {
  168.     new id;
  169.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "Uso: /pegarip [nick ou id]");
  170.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Este id não está conectado");
  171.     format(DString, sizeof(DString), "%s IP do player: %s", Pegarip(id), PegarNome(id));
  172.     SendClientMessage(playerid, CorBan, DString);
  173.     return 1;
  174. }
  175.  
  176. forward DBan(playerid, admin, Motivo[]);
  177. public DBan(playerid, admin, Motivo[])
  178. {
  179.     new Arquivo[64], Arquivo2[64];
  180.     SetTimerEx("KickBan",300, false, "i", playerid);
  181.     format(Arquivo2, 64, "Banidos/%s.ini", Pegarip(playerid));//Banindo Ip
  182.     DOF2_CreateFile(Arquivo2);
  183.     DOF2_SetString(Arquivo2, "Nick", PegarNome(playerid));
  184.     DOF2_SetString(Arquivo2, "Admin", PegarNome(admin));
  185.     DOF2_SetString(Arquivo2, "Motivo", Motivo);
  186.     format(Arquivo, 64, "Banidos/%s.ini", PegarNome(playerid));//Banindo Nome
  187.     DOF2_CreateFile(Arquivo);
  188.     DOF2_SetString(Arquivo, "Admin", PegarNome(admin));
  189.     DOF2_SetString(Arquivo, "Motivo", Motivo);
  190.     DOF2_SaveFile();
  191.     return 1;
  192. }
  193.  
  194. forward DTempBan(playerid, admin, Dias, Motivo[]);
  195. public DTempBan(playerid, admin, Dias, Motivo[])
  196. {
  197.     new Arquivo[64], DString2[250], Arquivo2[64];
  198.     getdate(A, Mes, D);
  199.     format(Data, 20, "%02d/%02d/%d", D, Mes, A);
  200.     gettime(H, M, S);
  201.     format(Tempo, 20, "%02d:%02d:%02d", H, M, S);
  202.     Player[playerid][Banido] = ConvertDays(Dias);
  203.     format(Arquivo, sizeof(Arquivo), "TempBan/%s.ini", Pegarip(playerid));//Banindo Ip
  204.     DOF2_CreateFile(Arquivo);
  205.     DOF2_SetString(Arquivo, "Nick", PegarNome(playerid));
  206.     format(Arquivo2, 64, "TempBan/%s.ini", PegarNome(playerid));//Banindo nick
  207.     DOF2_CreateFile(Arquivo2);
  208.     DOF2_SetString(Arquivo2, "IP", Pegarip(playerid));
  209.     DOF2_SetString(Arquivo2, "Admin", PegarNome(admin));
  210.     DOF2_SetInt(Arquivo2, "Dias", Player[playerid][Banido]);
  211.     DOF2_SetString(Arquivo2, "Motivo", Motivo);
  212.     DOF2_SetString(Arquivo2, "Data", Data);
  213.     DOF2_SetString(Arquivo2, "Horario", Tempo);
  214.     DOF2_SaveFile();
  215.     SetTimerEx("KickBan",300, false, "i", playerid);
  216.     format(DString2, sizeof(DString2), "{FFFFF0}Seu Nick: {FF4040}%s{FFFFF0}\n\nBanido por: {FF4040}%s{FFFFF0}\n\nMotivo: {FF4040}%s{FFFFF0}\n\nHorário: {FF4040}%s{FFFFF0}\n\nData: {FF4040}%s{FFFFF0}\n\nTempo Restante: {FF4040}%s.", PegarNome(playerid), PegarNome(admin), Motivo, Tempo, Data, ConvertToDays(Player[playerid][Banido]));
  217.     ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "Sistema de Ban", DString2, "Ok", "");
  218.     return 1;
  219. }
  220.  
  221. forward KickBan(playerid);
  222. public KickBan(playerid)
  223. {
  224.     Kick(playerid);
  225. }
  226.  
  227. stock VerifyExpiredDays(days)
  228.     return (days) < gettime();
  229.  
  230. stock ConvertToDays(n)
  231. {
  232.     #pragma tabsize 0
  233.     new t[5];
  234.         t[4] = n-gettime();
  235.         t[0] = t[4] / 3600;
  236.         t[1] = ((t[4] / 60) - (t[0] * 60));
  237.         t[2] = (t[4] - ((t[0] * 3600) + (t[1] * 60)));
  238.         t[3] = (t[0]/24);
  239.  
  240.     if(t[3] > 0)
  241.         t[0] = t[0] % 24,
  242.         format(DString, sizeof(DString), "%ddias, %02dh %02dm e %02ds", t[3], t[0], t[1], t[2]);
  243.     else if(t[0] > 0)
  244.         format(DString, sizeof(DString), "%02dh %02dm e %02ds", t[0], t[1], t[2]);
  245.     else
  246.         format(DString, sizeof(DString), "%02dm e %02ds", t[1], t[2]);
  247.     return DString;
  248. }
  249.  
  250. stock PegarNome(playerid)
  251. {
  252.     new name[MAX_PLAYER_NAME];
  253.     GetPlayerName(playerid, name, sizeof(name));
  254.     return name;
  255. }
  256.  
  257. stock Pegarip(playerid)
  258. {
  259.     new ip[16];
  260.     GetPlayerIp(playerid, ip, sizeof(ip));
  261.     return ip;
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement