Advertisement
ViniBorn

VBan2

Apr 11th, 2017
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.02 KB | None | 0 0
  1. /*
  2.     Nome: VBan2
  3.     Descrição: Sistema de bans
  4.     Autor: ViniBorn
  5.     Contato : www.facebook.com/vinibornpawn
  6.  
  7.  
  8. ***        ***   ***   *****     ***   ***   *** ***       *****      ********    ******    ***
  9.  ***      ***    ***   *** ***   ***   ***   ***   **    ***   ***    ***  ***    *** ***   ***
  10.   ***    ***     ***   ***  ***  ***   ***   *** **      ***   ***    *** ***     ***  ***  ***
  11.    ***  ***      ***   ***   *** ***   ***   ***   **    ***   ***    ***  ***    ***   *** ***
  12.     ******       ***   ***    ******   ***   *** ****      *****      ***   ***   ***    ******
  13.  
  14.  
  15.  
  16.  
  17.  
  18.         Não retire os créditos.
  19.         Seu nome é valioso, não suje-o.
  20.  
  21.  
  22.         Observações :
  23.  
  24.         - O diretório padrão para salvar os bans é : scriptfiles/Bans.  Crie a pasta Bans.
  25.         - Adicione ao seu GM o código abaixo, adaptando à sua variável de admin
  26.  
  27.         forward GetAdmin(playerid); public GetAdmin(playerid) return Admin[playerid];
  28.  
  29.  
  30. */
  31.  
  32. #include <a_samp>
  33. #include <zcmd>
  34. #include <DOF2>
  35. #include <sscanf2>
  36.  
  37. #define DIALOG_VBAN             10000
  38.  
  39. #define CorErro        0xFF0000AA
  40. #define CorBan        0xE11D36AA
  41.  
  42. #define Bissexto(%0) !(%0 % 400)
  43.  
  44. new VBString[128], LastArq[35];
  45.  
  46. CMD:ban(playerid, params[])
  47. {
  48.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 1)
  49.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  50.  
  51.     new ID, Motivo[32];
  52.     if(sscanf(params, "ds[32]", ID, Motivo))
  53.         return SendClientMessage(playerid, CorErro, "USO: /ban [ID] [Motivo]");
  54.  
  55.     VBan(ID, playerid, Motivo);
  56.     return true;
  57. }
  58.  
  59. CMD:banip(playerid, params[])
  60. {
  61.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 1)
  62.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  63.  
  64.     new vIP[16], Motivo[32];
  65.     if(sscanf(params, "s[16]s[32]", vIP, Motivo))
  66.         return SendClientMessage(playerid, CorErro, "USO: /banip [IP] [Motivo]");
  67.  
  68.     VBanIP(vIP, playerid, Motivo);
  69.     return true;
  70. }
  71.  
  72. CMD:bannick(playerid, params[])
  73. {
  74.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 1)
  75.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  76.  
  77.     new Nick[25], Motivo[32];
  78.     if(sscanf(params, "s[25]s[32]", Nick, Motivo))
  79.         return SendClientMessage(playerid, CorErro, "USO: /bannick [Nick] [Motivo]");
  80.  
  81.     VBanNick(Nick, playerid, Motivo);
  82.     return true;
  83. }
  84.  
  85. CMD:tempban(playerid, params[])
  86. {
  87.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 1)
  88.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  89.  
  90.     new ID, Dias, Motivo[32];
  91.     if(sscanf(params, "uds[32]", ID, Dias, Motivo))
  92.         return SendClientMessage(playerid, CorErro, "USO: /tempban [ID] [Dias] [Motivo]");
  93.  
  94.     if(Dias < 1 || Dias > 30)
  95.         return SendClientMessage(playerid, CorErro, "ERRO: Mínimo de 1 e máximo de 30 dias.");
  96.  
  97.     VBanTemp(ID, playerid, Motivo, Dias);
  98.     return true;
  99. }
  100.  
  101. CMD:desbanir(playerid, params[])
  102. {
  103.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 2)
  104.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  105.  
  106.     new Arq[45];
  107.     if(sscanf(params, "s[45]", Arq))
  108.         return SendClientMessage(playerid, CorErro, "USO: /desbanir [Nick/IP]");
  109.  
  110.     VBUnBan(playerid,Arq);
  111.     return true;
  112. }
  113.  
  114. CMD:baninfo(playerid, params[])
  115. {
  116.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 1)
  117.         return SendClientMessage(playerid, CorErro, "ERRO: Você não tem permissão para usar este comando!");
  118.  
  119.     new Arq[24];
  120.     if(sscanf(params, "s[24]", Arq))
  121.         return SendClientMessage(playerid, CorErro, "USO: /baninfo [IP/Nick]");
  122.  
  123.     format(VBString, 35, "/Bans/%s.ini", Arq);
  124.     format(LastArq, 24, Arq);
  125.     VBanLoadInfo(playerid,VBString);
  126.     return true;
  127. }
  128.  
  129. VBan(playerid, admin, Motivo[])
  130. {
  131.     if(IsPlayerConnected(playerid))
  132.     {
  133.         new AdminNick[MAX_PLAYER_NAME];
  134.         if(admin == -1) format(AdminNick, MAX_PLAYER_NAME, "VBot");
  135.         else format(AdminNick, MAX_PLAYER_NAME, Player(admin));
  136.  
  137.         format(VBString,128,"'- VBan -' O jogador %s foi banido por %s. Motivo: %s",Player(playerid),AdminNick,Motivo);
  138.         SendClientMessageToAll(CorBan,VBString);
  139.         format(VBString, 35, "/Bans/%s.ini", Player(playerid));
  140.         VBanSaveInfo(VBString, Player(playerid), AdminNick, PlayerIP(playerid), getdate()-1, Motivo);
  141.         format(VBString, 35, "/Bans/%s.ini", PlayerIP(playerid));
  142.         VBanSaveInfo(VBString, Player(playerid), AdminNick, PlayerIP(playerid), getdate()-1, Motivo);
  143.         VBanLoadInfo(playerid,VBString);
  144.         SetTimerEx("VBKick",300, false, "i", playerid);
  145.     }
  146.     else SendClientMessage(admin, CorErro, "Jogador não conectado.");
  147.  
  148.     return true;
  149. }
  150.  
  151. VBanIP(pIP[], admin, Motivo[])
  152. {
  153.     new playerid = GetIDIP(pIP);
  154.     if(playerid != INVALID_PLAYER_ID)
  155.     {
  156.         format(VBString, 35, "/Bans/%s.ini", Player(playerid));
  157.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), getdate()-1, Motivo);
  158.         format(VBString, 35, "/Bans/%s.ini", PlayerIP(playerid));
  159.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), getdate()-1, Motivo);
  160.         VBanLoadInfo(playerid,VBString);
  161.         SetTimerEx("VBKick",300, false, "i", playerid);
  162.     }
  163.     else
  164.     {
  165.         format(VBString, 35, "/Bans/%s.ini", pIP);
  166.         VBanSaveInfo(VBString, "Nenhum", Player(admin), pIP, getdate()-1, Motivo);
  167.     }
  168.     format(VBString,128,"'- VBan -' O IP %s foi banido por %s. Motivo: %s",pIP,Player(admin),Motivo);
  169.     SendClientMessageToAll(CorBan,VBString);
  170.     return true;
  171. }
  172.  
  173. VBanNick(Nick[], admin, Motivo[])
  174. {
  175.     new playerid = GetIDName(Nick);
  176.     if(playerid != INVALID_PLAYER_ID)
  177.     {
  178.         format(VBString, 35, "/Bans/%s.ini", Player(playerid));
  179.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), getdate()-1, Motivo);
  180.         format(VBString, 35, "/Bans/%s.ini", PlayerIP(playerid));
  181.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), getdate()-1, Motivo);
  182.         VBanLoadInfo(playerid,VBString);
  183.         SetTimerEx("VBKick",300, false, "i", playerid);
  184.     }
  185.     else
  186.     {
  187.         format(VBString, 35, "/Bans/%s.ini", Nick);
  188.         VBanSaveInfo(VBString, Nick, Player(admin), "Nenhum", getdate()-1, Motivo);
  189.     }
  190.     format(VBString,128,"'- VBan -' O nick %s foi banido por %s. Motivo: %s",Nick,Player(admin),Motivo);
  191.     SendClientMessageToAll(CorBan,VBString);
  192.     return true;
  193. }
  194.  
  195. VBanTemp(playerid, admin, Motivo[], dias)
  196. {
  197.     if(IsPlayerConnected(playerid))
  198.     {
  199.         format(VBString,128,"'- VBan -' O jogador %s foi banido temporariamente por %s (%d dias). Motivo: %s",Player(playerid),Player(admin),dias,Motivo);
  200.         SendClientMessageToAll(CorBan,VBString);
  201.         new Data[3], MaxDias, Final;
  202.         getdate(Data[0], Data[1], Data[2]);
  203.         if(Bissexto(Data[0])) MaxDias = 366;
  204.         else MaxDias = 365;
  205.  
  206.         if(getdate()+dias > MaxDias) Final = (getdate()+dias)-MaxDias;
  207.         else Final = getdate()+dias;
  208.  
  209.         format(VBString, 35, "/Bans/%s.ini", Player(playerid));
  210.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), Final, Motivo);
  211.         format(VBString, 35, "/Bans/%s.ini", PlayerIP(playerid));
  212.         VBanSaveInfo(VBString, Player(playerid), Player(admin), PlayerIP(playerid), Final, Motivo);
  213.         VBanLoadInfo(playerid,VBString);
  214.         SetTimerEx("VBKick",300, false, "i", playerid);
  215.     }
  216.     else SendClientMessage(admin, CorErro, "Jogador não conectado.");
  217.  
  218.     return true;
  219. }
  220.  
  221. VBanSaveInfo(File[], nick[], admin[], ip[], tempban, motivo[])
  222. {
  223.     new Data[6], Aux[32];
  224.     getdate(Data[0], Data[1], Data[2]);
  225.     gettime(Data[3], Data[4], Data[5]);
  226.     DOF2_CreateFile(File);
  227.     DOF2_SetString(File,"Nick",nick);
  228.     DOF2_SetString(File,"Admin",admin);
  229.     DOF2_SetString(File,"IP",ip);
  230.     DOF2_SetInt(File,"TempBan",tempban);
  231.     if(getdate() > tempban) DOF2_SetInt(File,"AnoTempBan",Data[0]+1);
  232.     else DOF2_SetInt(File,"AnoTempBan",Data[0]);
  233.     DOF2_SetString(File,"Motivo",motivo);
  234.     format(Aux, sizeof Aux, "%02d/%02d/%d", Data[2], Data[1], Data[0]);
  235.     DOF2_SetString(File,"Data",Aux);
  236.     format(Aux, sizeof Aux, "%02d:%02d:%02d", Data[3], Data[4], Data[5]);
  237.     DOF2_SetString(File,"Hora",Aux);
  238.     DOF2_SaveFile();
  239. }
  240.  
  241. VBanLoadInfo(playerid,Varq[])
  242. {
  243.     if(!DOF2_FileExists(Varq))
  244.         return SendClientMessage(playerid, CorErro,"'- VBan -' Ban inexistente.");
  245.  
  246.     new InfoString[300], Data[3], TempoDesban;
  247.     getdate(Data[0], Data[1], Data[2]);
  248.     if(DOF2_GetInt(Varq,"AnoTempBan") == Data[0])
  249.         TempoDesban = DOF2_GetInt(Varq,"TempBan") - getdate();
  250.     else
  251.     {
  252.         new MaxDias;
  253.         if(Bissexto(Data[0])) MaxDias = 366;
  254.         else MaxDias = 365;
  255.  
  256.         TempoDesban = (DOF2_GetInt(Varq,"TempBan")+MaxDias) - getdate();
  257.     }
  258.  
  259.     format(InfoString,300,"\n\t{FFFFFF}Nick : {E11D36}%s\n\t{FFFFFF}IP : {E11D36}%s\n\t{FFFFFF}Admin : {E11D36}%s\n\t{FFFFFF}Motivo : {E11D36}%s\n\t{FFFFFF}Data : {E11D36}%s\n\t{FFFFFF}Horário : {E11D36}%s\n\n\t%d dia(s) para ser desbanido(a).",DOF2_GetString(Varq,"Nick"),DOF2_GetString(Varq,"IP"),DOF2_GetString(Varq,"Admin"),DOF2_GetString(Varq,"Motivo"),DOF2_GetString(Varq,"Data"),DOF2_GetString(Varq,"Hora"),TempoDesban);
  260.     if(CallRemoteFunction("GetAdmin", "d", playerid) < 2)
  261.         ShowPlayerDialog(playerid, DIALOG_VBAN, DIALOG_STYLE_MSGBOX, "{FFFFFF}VBan - BanInfo - By: ViniBorn",InfoString,"Fechar", "");
  262.     else
  263.         ShowPlayerDialog(playerid, DIALOG_VBAN, DIALOG_STYLE_MSGBOX, "{FFFFFF}VBan - BanInfo - By: ViniBorn",InfoString,"Fechar", "Desbanir");
  264.     return true;
  265. }
  266.  
  267. VBUnBan(playerid,Varq[], Automatico = 0)
  268. {
  269.     format(VBString, 35, "/Bans/%s.ini",Varq);
  270.     if(!DOF2_FileExists(VBString))
  271.         return SendClientMessage(playerid, CorErro,"'- VBan -' Ban inexistente.");
  272.  
  273.     new tNick[25], tIP[16];
  274.     format(tNick, 25, DOF2_GetString(VBString, "Nick"));
  275.     format(tIP, 16, DOF2_GetString(VBString, "IP"));
  276.     format(VBString, 35, "/Bans/%s.ini",tNick);
  277.     if(DOF2_FileExists(VBString))
  278.         DOF2_RemoveFile(VBString);
  279.     format(VBString, 35, "/Bans/%s.ini",tIP);
  280.     if(DOF2_FileExists(VBString))
  281.         DOF2_RemoveFile(VBString);
  282.  
  283.     DOF2_Exit();
  284.     if(Automatico == 0)
  285.         format(VBString,128,"'- VBan -' O nick/IP %s foi desbanido por %s.",Varq,Player(playerid));
  286.     else
  287.         format(VBString,128,"'- VBan -' O nick/IP %s cumpriu sua punição e foi desbanido.",Varq);
  288.  
  289.     SendClientMessageToAll(0x0080FFFF, VBString);
  290.     return true;
  291. }
  292.  
  293. VBCheck(playerid)
  294. {
  295.     new File[35];
  296.     format(File, 35, "/Bans/%s.ini", Player(playerid));
  297.     if(DOF2_FileExists(File))
  298.     {
  299.         new Data[3];
  300.         getdate(Data[0], Data[1], Data[2]);
  301.         if(DOF2_GetInt(File,"TempBan") <= getdate() && DOF2_GetInt(File,"AnoTempBan") == Data[0])
  302.             VBUnBan(playerid,Player(playerid), 1);
  303.         else
  304.         {
  305.             VBanLoadInfo(playerid,File);
  306.             SetTimerEx("VBKick",300, false, "i", playerid);
  307.             return true;
  308.         }
  309.     }
  310.  
  311.     format(File, 35, "/Bans/%s.ini", PlayerIP(playerid));
  312.     if(DOF2_FileExists(File))
  313.     {
  314.         new Data[3];
  315.         getdate(Data[0], Data[1], Data[2]);
  316.  
  317.         if(DOF2_GetInt(File,"TempBan") <= getdate() && DOF2_GetInt(File,"AnoTempBan") == Data[0])
  318.             VBUnBan(playerid,PlayerIP(playerid), 1);
  319.         else
  320.         {
  321.             VBanLoadInfo(playerid,File);
  322.             SetTimerEx("VBKick",300, false, "i", playerid);
  323.             return true;
  324.         }
  325.     }
  326.     return false;
  327. }
  328.  
  329. GetIDIP(vIP[])
  330. {
  331.     new vvIP[16];
  332.     for(new v, b = GetMaxPlayers(); v != b; v++)
  333.         if(IsPlayerConnected(v))
  334.         {
  335.             GetPlayerIp(v, vvIP, sizeof vvIP);
  336.             if(strfind(vIP, vvIP) != -1)
  337.                 return v;
  338.         }
  339.  
  340.     return INVALID_PLAYER_ID;
  341. }
  342.  
  343. GetIDName(vName[])
  344. {
  345.     new VBNome[MAX_PLAYER_NAME];
  346.     for(new v, b = GetMaxPlayers(); v != b; v++)
  347.         if(IsPlayerConnected(v))
  348.         {
  349.             GetPlayerName(v, VBNome, MAX_PLAYER_NAME);
  350.             if(!strcmp(vName, VBNome))
  351.                 return v;
  352.         }
  353.  
  354.     return INVALID_PLAYER_ID;
  355. }
  356.  
  357. Player(playerid)
  358. {
  359.     new Nome[24];
  360.     GetPlayerName(playerid, Nome, 24);
  361.     return Nome;
  362. }
  363.  
  364. PlayerIP(playerid)
  365. {
  366.     new vbIP[16];
  367.     GetPlayerIp(playerid, vbIP, 16);
  368.     return vbIP;
  369. }
  370.  
  371. forward VBKick(playerid);public VBKick(playerid) Kick(playerid);
  372.  
  373. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  374. {
  375.     new Arq[35];
  376.     format(Arq, 35, "/Bans/%s.ini", LastArq);
  377.     if(dialogid == DIALOG_VBAN)
  378.     {
  379.         if(!response)
  380.         {
  381.             if(strcmp(DOF2_GetString(Arq, "Nick"),"Nenhum")) format(VBString, 64, "Você realmente deseja desbanir o nick %s ?",DOF2_GetString(Arq, "Nick"));
  382.             else if(strcmp(DOF2_GetString(Arq, "IP"),"Nenhum")) format(VBString, 64, "Você realmente deseja desbanir o IP %s ?",DOF2_GetString(Arq, "IP"));
  383.  
  384.             if(CallRemoteFunction("GetAdmin", "d", playerid) > 1)
  385.                 ShowPlayerDialog(playerid, DIALOG_VBAN+1, DIALOG_STYLE_MSGBOX, "{FFFFFF}Desbanir",VBString,"Sim", "Não");
  386.         }
  387.     }
  388.     else if(dialogid == DIALOG_VBAN+1)
  389.         if(response)
  390.             VBUnBan(playerid,LastArq);
  391.  
  392.     return false;
  393. }
  394.  
  395. public OnPlayerRequestClass(playerid,classid)
  396. {
  397.     VBCheck(playerid);
  398.     return true;
  399. }
  400.  
  401. public OnFilterScriptInit()
  402. {
  403.     print("\n\nVBan2 iniciado.\t\t\tAutor: ViniBorn\n\n");
  404.     return true;
  405. }
  406.  
  407. public OnFilterScriptExit()
  408. {
  409.     print("\n\nVBan2 finalizado.\t\t\tAutor: ViniBorn\n\n");
  410.     DOF2_Exit();
  411.     return true;
  412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement