SHARE
TWEET

ban fs

a guest Oct 7th, 2014 333 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*===============================================================
  2.   =============TEMP BAN SYSTEM V 3.0=============================
  3.   ===============MADE BY BROZEUS=================================
  4.   CREDITS------>
  5.     Zeus [ thats me] -- For scripting
  6.     YSI -- For sscanf2 and YSI/ini
  7.     Zeex -- For Zcmd
  8.     Jochemd -- For TimeStampToDate.inc
  9.     Shacky  -- for fcreate and fdelete stocks
  10.  
  11.     Do not remove creits or redistribute*/
  12.     #include <a_samp>
  13.     #include <YSI\y_ini>
  14.     #include <zcmd>
  15.     #include <sscanf2>
  16.     #include <TimeStampToDate>
  17.    
  18.  
  19.     #define BANPATH "/Bans/%s.ini"
  20.     #define IPPATH "/IP/%s.ini"
  21.    
  22.     #define GMT_H 0  // Enter the value of the gmt hour u want otherwise keep it zero
  23.     #define GMT_M 0  // Enter the value of the gmt mintues u want otherwise keep it zero
  24.  
  25. new ln[MAX_PLAYERS]=0,revseen[][MAX_PLAYERS];
  26.  
  27. #if defined FILTERSCRIPT
  28. public OnFilterScriptInit()
  29. {
  30. if(!fexist("unban_log.txt"))
  31. {
  32. fcreate("unban_log.txt");
  33. print("unban_log.txt didnt existed so it was created.");
  34. }
  35. if(!fexist("BannedPlayers.txt"))
  36. {
  37. fcreate("BannedPlayers.txt");
  38. print("BannedPlayers.txt didnt existed so it was created.");
  39. }
  40. return 1;
  41. }
  42. #else
  43. public OnGameModeInit()
  44. {
  45. if(!fexist("unban_log.txt"))
  46. {
  47. fcreate("unban_log.txt");
  48. print("unban_log.txt didnt existed so it was created.");
  49. }
  50. if(!fexist("BannedPlayers.txt"))
  51. {
  52. fcreate("BannedPlayers.txt");
  53. print("BannedPlayers.txt didnt existed so it was created.");
  54. }
  55.  
  56. return 1;
  57. }
  58. #endif
  59.  
  60.     enum pInfo
  61.     {
  62.     pBanexp,
  63.     pBanres[100],
  64.     pBanPerm,
  65.     pBanAdmin[20],
  66.     pBanIPP[20]
  67.     }
  68.     new PlayerInfo[MAX_PLAYERS][pInfo];
  69.     new pp[50];
  70.  
  71.         forward fcreate(filename[]);
  72.     public fcreate(filename[])
  73.     {
  74.     if (fexist(filename)){return false;}
  75.     new File:fhandle = fopen(filename,io_write);
  76.     fclose(fhandle);
  77.     return true;
  78.     }
  79.    
  80.     forward LoadBanUser_data(playerid,name[],value[]);
  81.     public LoadBanUser_data(playerid,name[],value[])
  82.     {INI_Int("Banexp",PlayerInfo[playerid][pBanexp]);
  83.      INI_Int("BanPerm",PlayerInfo[playerid][pBanPerm]);
  84.      INI_String("BanAdmin", PlayerInfo[playerid][pBanAdmin], 20);
  85.      INI_String("Reason",PlayerInfo[playerid][pBanres],100);
  86.      return 1;
  87.     }
  88.    
  89.     forward LoadIPUser_data(playerid,name[],value[]);
  90.     public LoadIPUser_data(playerid,name[],value[])
  91.     {INI_Int("Banexp",PlayerInfo[playerid][pBanexp]);
  92.      INI_Int("BanPerm",PlayerInfo[playerid][pBanPerm]);
  93.      INI_String("BanPlayer", PlayerInfo[playerid][pBanIPP], 20);
  94.      INI_String("BanAdmin", PlayerInfo[playerid][pBanAdmin], 20);
  95.      INI_String("Reason",PlayerInfo[playerid][pBanres],100);
  96.      return 1;
  97.     }
  98.    
  99.     forward LoadIP_data(playerid,name[],value[]);
  100.     public LoadIP_data(playerid,name[],value[])
  101.     {INI_String("IP",pp,50);
  102.      return 1;
  103.     }
  104.  
  105.     stock UserBanPath(playerid)
  106.     {
  107.         new string[128],playername[MAX_PLAYER_NAME];
  108.         GetPlayerName(playerid,playername,sizeof(playername));
  109.         format(string,sizeof(string),BANPATH,playername);
  110.         return string;
  111.     }
  112.     stock UserIPPath(playerid)
  113.     {
  114.         new string[128],ip[50];
  115.         GetPlayerIp(playerid,ip,sizeof(ip));
  116.         format(string,sizeof(string),IPPATH,ip);
  117.         return string;
  118.     }
  119.    
  120.     stock Showinfo(playerid,targetname[])
  121.     {
  122.     new path[150],ss[500];
  123.         format(path,sizeof(path),"Bans/%s.ini",targetname);
  124.     INI_ParseFile(path, "LoadBanUser_%s", .bExtra = true, .extra = playerid);
  125.         if(PlayerInfo[playerid][pBanPerm]==1)
  126.         format(ss,sizeof(ss),"{00FFFF}Banning Admin:\t\t{ff0000}%s\n{00FFFF}Ban Reason:\t\t{ff0000}%s\n{00FFFF}Ban Type:\t\t{ff0000}Permanent.\n\n{FFFF00}Click on Remove Ban button to un-ban the player.",PlayerInfo[playerid][pBanAdmin],PlayerInfo[playerid][pBanres]);
  127.         else
  128.         {
  129.     new d,m,y,h,mi,s;
  130.     TimestampToDate(PlayerInfo[playerid][pBanexp],y,m,d,h,mi,s,GMT_H,GMT_M);
  131.         format(ss,sizeof(ss),"{00FFFF}Banning Admin:\t\t{ff0000}%s\n{00FFFF}Ban Reason:\t\t{ff0000}%s\n{00FFFF}Expire Time:\t\t{ff0000}%i-%i\n{00FFFF}Expire Date:\t\t{ff0000}%i-%i-%i\n\n{FFFF00}Time is according to %i GMT\nDate Format: dd-mm-yyyy\nClick on Remove Ban button to un-ban the player.",PlayerInfo[playerid][pBanAdmin],PlayerInfo[playerid][pBanres],h,mi,d,m,y,GMT_H);
  132.         }
  133.         format(revseen[playerid],MAX_PLAYER_NAME,"%s",targetname);
  134.         ShowPlayerDialog(playerid, 113,  DIALOG_STYLE_MSGBOX,targetname,ss, "Remove Ban", "Cancel");
  135.         return 1;
  136.         }
  137.        
  138.         stock fdeleteline(filename[], line[])
  139.         {
  140.         if(fexist(filename)){
  141.                 new temp[256];
  142.                 new File:fhandle = fopen(filename,io_read);
  143.                 fread(fhandle,temp,sizeof(temp),false);
  144.                 if(strfind(temp,line,true)==-1){return 0;}
  145.                 else{
  146.                         fclose(fhandle);
  147.                         fremove(filename);
  148.                         for(new i=0;i<strlen(temp);i++){
  149.                                 new templine[256];
  150.                                 strmid(templine,temp,i,i+strlen(line));
  151.                                 if(strcmp(templine,line,true)){
  152.                                         strdel(temp,i,i+strlen(line));
  153.                                         fcreate(filename);
  154.                                         fhandle = fopen(filename,io_write);
  155.                                         fwrite(fhandle,temp);
  156.                                         fclose(fhandle);
  157.                                         return 1;
  158.                                 }
  159.                         }
  160.                 }
  161.         }
  162.         return 0;
  163. }
  164.    
  165.  
  166.     public OnPlayerConnect(playerid)
  167.     {
  168.  
  169.      if(fexist(UserBanPath(playerid)))
  170.         {
  171.             INI_ParseFile(UserBanPath(playerid), "LoadBanUser_%s", .bExtra = true, .extra = playerid);
  172.  
  173.             if(PlayerInfo[playerid][pBanPerm]==1)
  174.             {new reso[256];
  175.              SendClientMessage(playerid,-1,"{85BB65}You are permanently Banned from this server by Administration");
  176.              format(reso,sizeof(reso),"{85BB65}Reason: {f0f000}%s",PlayerInfo[playerid][pBanres]);
  177.              SendClientMessage(playerid,-1,reso);
  178.              format(reso,sizeof(reso),"{85BB65}Banning Admin: {f0f000}%s",PlayerInfo[playerid][pBanAdmin]);
  179.              SendClientMessage(playerid,-1,reso);
  180.              SetTimerEx("KickPlayer",100,false,"i",playerid);
  181.             }
  182.              else
  183.              {
  184.           if(gettime() > PlayerInfo[playerid][pBanexp])
  185.           {   fremove(UserBanPath(playerid));
  186.               fremove(UserIPPath(playerid));
  187.               SendClientMessage(playerid,-1,"{00cc00}You have been unbanned!!!!");
  188.           }
  189.           else
  190.           {
  191.           new d,m,y,h,mi,s;
  192.           TimestampToDate(PlayerInfo[playerid][pBanexp],y,m,d,h,mi,s,GMT_H,GMT_M);
  193.           new str[540];
  194.           format(str,sizeof(str),"{85BB65}This Account Has Been Banned By The Adminstration Until {f0f000}%i-%i-%i[Date format : dd/mm/yyyy]",d,m,y);
  195.           SendClientMessage(playerid,-1,str);
  196.           format(str,sizeof(str),"{85BB65}Expires on[TIME] -- {f0f000}%i-%i[Time Format: 24 Hour Clock]",h,mi);
  197.           SendClientMessage(playerid, -1, str);
  198.           format(str,sizeof(str),"{85BB65}Reason -- {f0f000}%s",PlayerInfo[playerid][pBanres]);
  199.           SendClientMessage(playerid, -1, str);
  200.           format(str,sizeof(str),"{85BB65}Banning Admin -- {f0f000}%s",PlayerInfo[playerid][pBanAdmin]);
  201.           SendClientMessage(playerid, -1, str);
  202.           SetTimerEx("KickPlayer",100,false,"i",playerid);
  203.               }}}
  204.              
  205.                   else if(fexist(UserIPPath(playerid)))
  206.                   {
  207.                   INI_ParseFile(UserIPPath(playerid), "LoadIPUser_%s", .bExtra = true, .extra = playerid);
  208.                   if(PlayerInfo[playerid][pBanPerm]==1)
  209.           {  new reso[256];
  210.              SendClientMessage(playerid,-1,"{85BB65}This IP is permanently Banned from this server by Administration");
  211.              format(reso,sizeof(reso),"{85BB65}Originally Banned Player: {f0f000}%s",PlayerInfo[playerid][pBanIPP]);
  212.              SendClientMessage(playerid,-1,reso);
  213.                          format(reso,sizeof(reso),"{85BB65}Reason: {f0f000}%s",PlayerInfo[playerid][pBanres]);
  214.              SendClientMessage(playerid,-1,reso);
  215.              format(reso,sizeof(reso),"{85BB65}Banning Admin: {f0f000}%s",PlayerInfo[playerid][pBanAdmin]);
  216.              SendClientMessage(playerid,-1,reso);
  217.              SetTimerEx("KickPlayer",100,false,"i",playerid);
  218.                   }
  219.                   else {
  220.                   if(gettime() > PlayerInfo[playerid][pBanexp])
  221.           {   new pat[100];
  222.                       fremove(UserIPPath(playerid));
  223.               format(pat,sizeof(pat),"Bans/%s.ini",PlayerInfo[playerid][pBanIPP]);
  224.               fremove(pat);
  225.               SendClientMessage(playerid,-1,"{00cc00}This IP was banned but as now the expire time has passed this IP has been unbanned.");
  226.           }
  227.           else
  228.           {
  229.           new d,m,y,h,mi,s;
  230.           TimestampToDate(PlayerInfo[playerid][pBanexp],y,m,d,h,mi,s,GMT_H,GMT_M);
  231.           new str[540];
  232.           format(str,sizeof(str),"{85BB65}This IP Has Been Banned By The Adminstration Until {f0f000}%i-%i-%i[Date format : dd/mm/yyyy]",d,m,y);
  233.           SendClientMessage(playerid,-1,str);
  234.           format(str,sizeof(str),"{85BB65}Expires on[TIME] -- {f0f000}%i-%i[Time Format: 24 Hour Clock]",h,mi);
  235.           SendClientMessage(playerid, -1, str);
  236.           format(str,sizeof(str),"{85BB65}Originally Banned Player -- {f0f000}%s",PlayerInfo[playerid][pBanIPP]);
  237.                   SendClientMessage(playerid, -1, str);
  238.           format(str,sizeof(str),"{85BB65}Reason -- {f0f000}%s",PlayerInfo[playerid][pBanres]);
  239.           SendClientMessage(playerid, -1, str);
  240.           format(str,sizeof(str),"{85BB65}Banning Admin -- {f0f000}%s",PlayerInfo[playerid][pBanAdmin]);
  241.           SendClientMessage(playerid, -1, str);
  242.           SetTimerEx("KickPlayer",100,false,"i",playerid);
  243.               }}}
  244.          
  245.           return 1;}
  246.          
  247.           public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  248.           {
  249.           if(dialogid==110 && response)
  250.                   {
  251.                  
  252.                   Showinfo(playerid,inputtext);
  253.                   ln[playerid]=0;
  254.                   }
  255.                   if(dialogid==111)
  256.                   {
  257.                   if(response)Showinfo(playerid,inputtext);
  258.                   else
  259.                   {
  260.                   new read[200],ss[1008],op[1000];
  261.           format(op,sizeof(op),"");
  262.           new File:log=fopen("BannedPlayers.txt",io_read);
  263.           fseek(log,ln[playerid],seek_start);
  264.           while(fread(log,read))
  265.           {
  266.           strcat(read,"\n",200);
  267.           strcat(op,read,1000);
  268.           }
  269.           fclose(log);
  270.           format(ss,sizeof(ss),"{9ACD32}%s",op);
  271.           ShowPlayerDialog(playerid, 112,  DIALOG_STYLE_LIST, "{00FFFF}Showing Currently Banned Players[Page 2]",ss, "Select", "Cancel");
  272.           ln[playerid]=0;
  273.           }}
  274.                   if(dialogid==112 && response)Showinfo(playerid,inputtext);
  275.                   if(dialogid==113 && response)
  276.                   {
  277.                   new pat[MAX_PLAYER_NAME+10],pati[MAX_PLAYER_NAME+10],ppf[100],adname[MAX_PLAYER_NAME];
  278.          
  279.           format(pat,sizeof(pat),"Bans/%s.ini",revseen[playerid]);
  280.          
  281.               INI_ParseFile(pat, "LoadIP_%s", .bExtra = true, .extra = playerid);
  282.               format(pati,sizeof(pat),"IP/%s.ini",pp);
  283.               fremove(pati);
  284.               format(pat,sizeof(pat),"Bans/%s.ini",revseen[playerid]);
  285.               fremove(pat);
  286.           format(ppf,sizeof(ppf),"The player %s has been un-banned.",revseen[playerid]);
  287.           SendClientMessage(playerid,0x00FF00FF,ppf);
  288.           GetPlayerName(playerid,adname,sizeof(adname));
  289.           format(pat,sizeof(pat),"%s has been unbanned by %s",revseen[playerid],adname);
  290.               new File:log=fopen("unban_log.txt",io_append);
  291.               fwrite(log, pat);
  292.               fwrite(log,"\r\n");
  293.               fclose(log);
  294.               fdeleteline("BannedPlayers.txt", revseen[playerid]);
  295.               }
  296.  
  297.                  
  298.                   return 0;
  299.           }
  300.          
  301.  
  302.  
  303.  
  304.  
  305.     forward KickPlayer(playerid);
  306.     public KickPlayer(playerid)
  307.     {
  308.         Kick(playerid);
  309.         return 1;
  310.     }
  311.  
  312.     /*=====================================COMMANDS======================================*/
  313.     CMD:ban(playerid,parmas[])
  314.     {
  315.     if(IsPlayerAdmin(playerid)){
  316.     new tid,du,res[150],ppp[50];
  317.     if(sscanf(parmas,"uis",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
  318.     if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
  319.     new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
  320.      GetPlayerName(playerid,adminname,sizeof(adminname));
  321.      new exp=gettime()+(60*60*24*du);
  322.      GetPlayerIp(tid,ppp,sizeof(ppp));
  323.      new INI:File = INI_Open(UserBanPath(tid));
  324.      INI_SetTag(File,"data");
  325.      INI_WriteInt(File,"Banexp",exp);
  326.      INI_WriteInt(File,"BanPerm",0);
  327.      INI_WriteString(File,"BanAdmin",adminname);
  328.      INI_WriteString(File,"Reason",res);
  329.      INI_WriteString(File,"IP",ppp);
  330.      INI_Close(File);
  331.      GetPlayerName(tid,targetn,sizeof(targetn));
  332.      new INI:iFile = INI_Open(UserIPPath(tid));
  333.      INI_SetTag(iFile,"data");
  334.      INI_WriteInt(iFile,"Banexp",exp);
  335.      INI_WriteInt(iFile,"BanPerm",0);
  336.      INI_WriteString(iFile,"BanPlayer",targetn);
  337.      INI_WriteString(iFile,"BanAdmin",adminname);
  338.      INI_WriteString(iFile,"Reason",res);
  339.      INI_Close(iFile);
  340.      new File:logg=fopen("BannedPlayers.txt",io_append);
  341.          fwrite(logg, targetn);
  342.          fwrite(logg,"\n");
  343.          fclose(logg);
  344.      format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
  345.      format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
  346.      SendClientMessage(tid,-1,banmt);
  347.      SendClientMessageToAll(-1,banma);
  348.      SetTimerEx("KickPlayer",100,false,"i",tid);
  349.     }else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  350.     return 1;}
  351. /*===================================================================================================*/
  352.     CMD:removeban(playerid,parmas[]){
  353.     if(IsPlayerAdmin(playerid)){
  354.     new rename[MAX_PLAYER_NAME],pat[MAX_PLAYER_NAME+10],pati[MAX_PLAYER_NAME+10],ppf[100],adname[MAX_PLAYER_NAME];
  355.     if(sscanf(parmas,"s",rename) || isnull(parmas))return SendClientMessage(playerid, -1, "{FF0000}Wrong Usage || Usage : /removeban PlayerName");
  356.     format(pat,sizeof(pat),"Bans/%s.ini",rename);
  357.     if(!fexist(pat))
  358.     {
  359.         format(ppf,sizeof(ppf),"The user cannot be unbanned because there is user named as %s banned.",rename);
  360.         SendClientMessage(playerid,-1,ppf);
  361.         return 1;
  362.         }
  363.         INI_ParseFile(pat, "LoadIP_%s", .bExtra = true, .extra = playerid);
  364.         format(pati,sizeof(pat),"IP/%s.ini",pp);
  365.         fremove(pati);
  366.         format(pat,sizeof(pat),"Bans/%s.ini",rename);
  367.         fremove(pat);
  368.     format(ppf,sizeof(ppf),"The player %s has been un-banned.",rename);
  369.     SendClientMessage(playerid,0x00FF00FF,ppf);
  370.     GetPlayerName(playerid,adname,sizeof(adname));
  371.     format(pat,sizeof(pat),"%s has been unbanned by %s",rename,adname);
  372.         new File:log=fopen("unban_log.txt",io_append);
  373.         fwrite(log, pat);
  374.         fwrite(log,"\r\n");
  375.         fclose(log);
  376.         fdeleteline("BannedPlayers.txt", rename);
  377.         }
  378.     else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command");
  379.     return 1;}
  380. /*====================================================================================================*/
  381.     CMD:banperm(playerid,parmas[])
  382.     {
  383.     if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  384.     new tid,res[90],ppp[50];
  385.     if(sscanf(parmas,"us",tid,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /banperm PlayerID Reason");
  386.     if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
  387.     new adminname[MAX_PLAYER_NAME];
  388.     GetPlayerName(playerid,adminname,sizeof(adminname));
  389.     GetPlayerIp(tid,ppp,sizeof(ppp));
  390.     new INI:File = INI_Open(UserBanPath(tid));
  391.     INI_SetTag(File,"data");
  392.     INI_WriteInt(File,"Banexp",0);
  393.     INI_WriteInt(File,"BanPerm",1);
  394.     INI_WriteString(File,"BanAdmin",adminname);
  395.     INI_WriteString(File,"Reason",res);
  396.     INI_WriteString(File,"IP",ppp);
  397.     INI_Close(File);
  398.     new banmt[300],banma[300],targetn[MAX_PLAYER_NAME];
  399.     GetPlayerName(tid,targetn,sizeof(targetn));
  400.     new INI:iFile = INI_Open(UserIPPath(tid));
  401.      INI_SetTag(iFile,"data");
  402.      INI_WriteInt(iFile,"Banexp",0);
  403.      INI_WriteInt(iFile,"BanPerm",1);
  404.      INI_WriteString(iFile,"BanPlayer",targetn);
  405.      INI_WriteString(iFile,"BanAdmin",adminname);
  406.      INI_WriteString(iFile,"Reason",res);
  407.      INI_Close(iFile);
  408.      new File:logg=fopen("BannedPlayers.txt",io_append);
  409.          fwrite(logg, targetn);
  410.          fwrite(logg,"\n");
  411.          fclose(logg);
  412.     format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for permanently due to %s",adminname,res);
  413.     format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s permanenetly due to %s",adminname,targetn,res);
  414.     SendClientMessage(tid,-1,banmt);
  415.     SendClientMessageToAll(-1,banma);
  416.     SetTimerEx("KickPlayer",100,false,"i",tid);
  417.     return 1;}
  418. /*=======================================================================================================*/
  419.    CMD:banm(playerid,parmas[])
  420.     {
  421.     if(IsPlayerAdmin(playerid)){
  422.     new tid,h,m,res[150],ppp[50];
  423.     if(sscanf(parmas,"uiis",tid,h,m,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /banm ID Hours Minutes Reason");
  424.     if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
  425.     new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
  426.      GetPlayerName(playerid,adminname,sizeof(adminname));
  427.      new exp=gettime()+(60*m)+(60*60*h);
  428.      GetPlayerIp(tid,ppp,sizeof(ppp));
  429.      new INI:File = INI_Open(UserBanPath(tid));
  430.      INI_SetTag(File,"data");
  431.      INI_WriteInt(File,"Banexp",exp);
  432.      INI_WriteInt(File,"BanPerm",0);
  433.      INI_WriteString(File,"BanAdmin",adminname);
  434.      INI_WriteString(File,"Reason",res);
  435.      INI_WriteString(File,"IP",ppp);
  436.      INI_Close(File);
  437.      GetPlayerName(tid,targetn,sizeof(targetn));
  438.      new INI:iFile = INI_Open(UserIPPath(tid));
  439.      INI_SetTag(iFile,"data");
  440.      INI_WriteInt(iFile,"Banexp",exp);
  441.      INI_WriteInt(iFile,"BanPerm",0);
  442.      INI_WriteString(iFile,"BanPlayer",targetn);
  443.      INI_WriteString(iFile,"BanAdmin",adminname);
  444.      INI_WriteString(iFile,"Reason",res);
  445.      INI_Close(iFile);
  446.      new File:logg=fopen("BannedPlayers.txt",io_append);
  447.          fwrite(logg, targetn);
  448.          fwrite(logg,"\n");
  449.          fclose(logg);
  450.      format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i hours %i minutes due to %s",adminname,h,m,res);
  451.      format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i hours %i minutes due to %s",adminname,targetn,h,m,res);
  452.      SendClientMessage(tid,-1,banmt);
  453.      SendClientMessageToAll(-1,banma);
  454.      SetTimerEx("KickPlayer",100,false,"i",tid);
  455.     }else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  456.     return 1;}
  457. /*=======================================================================================================*/
  458. CMD:log(playerid,parmas[])
  459. {
  460. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  461. new read[500],ss[1008],op[1000];
  462. format(op,sizeof(op),"");
  463. new File:log=fopen("unban_log.txt",io_read);
  464. while(fread(log,read))
  465. {
  466. strcat(read,"\n",500);
  467. strcat(op,read,1000);
  468. }
  469. fclose(log);
  470. format(ss,sizeof(ss),"{9ACD32}%s",op);
  471. ShowPlayerDialog(playerid, 110, DIALOG_STYLE_MSGBOX, "{00BFFF}Showing Un-Ban Log",ss, "Cool", "");
  472. return 1;
  473. }
  474. /*=========================================================================================================*/
  475. CMD:showbans(playerid,parmas[])
  476. {
  477. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  478. new read[200],ss[1008],op[1000],bool:NextDialog=false;
  479. format(op,sizeof(op),"");
  480. new File:log=fopen("BannedPlayers.txt",io_read);
  481. while(fread(log,read))
  482. {
  483. strcat(read,"\n",200);
  484. strcat(op,read,1000);
  485. ln[playerid]++;
  486. if(ln[playerid]==110)//this specifies the maximum no. of bans that are to be shown in 1 dialog box
  487. {
  488. NextDialog=true;
  489. break;
  490. }
  491. }
  492. fclose(log);
  493. if(strlen(op)<=3)return SendClientMessage(playerid,-1,"{ff0000}No players currently banned.");
  494. format(ss,sizeof(ss),"{9ACD32}%s",op);
  495. if(NextDialog==false)ShowPlayerDialog(playerid, 110,  DIALOG_STYLE_LIST, "{00FFFF}Showing Currently Banned Players",ss, "Select", "Cancel");
  496. else ShowPlayerDialog(playerid, 111,  DIALOG_STYLE_LIST, "{00FFFF}Showing Currently Banned Players",ss, "Select", "Next Page");
  497. return 1;
  498. }
  499. /*================================================================================================================*/
  500. CMD:showbaninfo(playerid,parmas[])
  501. {
  502. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  503. new tid[MAX_PLAYER_NAME];
  504. if(sscanf(parmas,"s",tid))return SendClientMessage(playerid,-1,"{ff0000}Correct Usage: /showbaninfo PLAYERNAME\nNOTE:The PLAYERNAME should be exact name of player.");
  505. new path[150];
  506. format(path,sizeof(path),"Bans/%s.ini",tid);
  507. if(!fexist(path))return SendClientMessage(playerid,-1,"{ff0000}The player you requested is not in ban databse please use /showbans to view currently banned players.");
  508. Showinfo(playerid,tid);
  509. return 1;
  510. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top