Advertisement
Guest User

Temp Ban System V1.1 by Zeus

a guest
Feb 21st, 2014
1,262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This script is purely made by Zeus
  2. //All its Credits to Zeus for scripting
  3.  
  4. #include <a_samp>
  5. #include <zcmd>
  6. #include <sscanf2>
  7. #include <YSI\y_ini>
  8.  
  9. #define BANPATH "/Bans/%s.ini"
  10.  
  11. enum pInfo
  12. {
  13.     pBanexp,
  14.     pBanm,
  15.     pBany,
  16.     pBanh,
  17.     pBanmi,
  18.     pBanres
  19. }
  20. new PlayerInfo[MAX_PLAYERS][pInfo];
  21.  
  22. forward LoadBanUser_data(playerid,name[],value[]);
  23. public LoadBanUser_data(playerid,name[],value[])
  24. {INI_Int("Banexp",PlayerInfo[playerid][pBanexp]);
  25.  INI_Int("Banm",PlayerInfo[playerid][pBanm]);
  26.  INI_Int("Bany",PlayerInfo[playerid][pBany]);
  27.  INI_Int("Banhour",PlayerInfo[playerid][pBanh]);
  28.  INI_Int("Banmin",PlayerInfo[playerid][pBanmi]);
  29.  INI_Int("Reason",PlayerInfo[playerid][pBanres]);
  30.  return 1;
  31. }
  32.  
  33. stock UserBanPath(playerid)
  34. {
  35.     new string[128],playername[MAX_PLAYER_NAME];
  36.     GetPlayerName(playerid,playername,sizeof(playername));
  37.     format(string,sizeof(string),BANPATH,playername);
  38.     return string;
  39. }
  40. public OnPlayerConnect(playerid)
  41. {
  42. if(fexist(UserBanPath(playerid)))
  43.    {  INI_ParseFile(UserBanPath(playerid), "LoadBanUser_%s", .bExtra = true, .extra = playerid);
  44.       new d,m,y,h,mi,s;
  45.       getdate(y,m,d);
  46.       gettime(h,mi,s);
  47.       if((d>PlayerInfo[playerid][pBanexp] && m>=PlayerInfo[playerid][pBanm] && y>=PlayerInfo[playerid][pBany]) || (d>PlayerInfo[playerid][pBanexp] && m==PlayerInfo[playerid][pBanm]) || (m>PlayerInfo[playerid][pBanm] || y>PlayerInfo[playerid][pBany]) || (d==PlayerInfo[playerid][pBanexp] && m==PlayerInfo[playerid][pBanm] && y==PlayerInfo[playerid][pBany] && h>=PlayerInfo[playerid][pBanh] && mi>=PlayerInfo[playerid][pBanmi]))
  48.       {fremove(UserBanPath(playerid));}
  49.       else
  50.       {new clt[200],cltim[100];
  51.        SendClientMessage(playerid,-1,"{ff0000}You are currently Ban from the server");
  52.        format(clt,sizeof(clt),"{F0FFFF}Your Ban will expire on - {FFE5B4}%i/%i/%i {F0FFFF}[Date Format: dd/mm/yyyy]",PlayerInfo[playerid][pBanexp],PlayerInfo[playerid][pBanm],PlayerInfo[playerid][pBany]);
  53.        format(cltim,sizeof(cltim),"{F0FFFF}At Time : {FFE5B4}%i:%i {F0FFFF}[Time Format: 24 Hour Clock]",PlayerInfo[playerid][pBanh],PlayerInfo[playerid][pBanmi]);
  54.        SendClientMessage(playerid,-1,clt);
  55.        SendClientMessage(playerid,-1,cltim);
  56.        SetTimerEx("KickPlayer",70,false,"i",playerid);
  57.        }}}
  58. forward KickPlayer(playerid);
  59. public KickPlayer(playerid)
  60. {
  61.     Kick(playerid);
  62.     return 1;
  63. }
  64. /*=================================COMMANDS FROM HERE=========================================*/
  65. CMD:kick(nadmin,parmas[])
  66. {new  tok[300], toall[300], playerid, reason[128], adminname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
  67.  if(PlayerInfo[nadmin][pAdmin]>=1)// <---------PUT Your admin variables here and the levels who can use this cammand
  68. {if(sscanf(parmas, "us", playerid, reason) || isnull(parmas))return SendClientMessage(nadmin,-1,"{FF0000}Wrong Usage || Usage: /kick id reason");
  69.  if(!IsPlayerConnected(playerid))return SendClientMessage(nadmin,-1,"{FF0000}The player you want to kick is not connected");
  70.  GetPlayerName(nadmin, adminname, sizeof(adminname));
  71.  GetPlayerName(playerid, kname, sizeof(kname));
  72.  format(toall, sizeof(toall), "{FF0000}Admin %s(%i) has kicked %s(%i) due to %s" , adminname, nadmin, kname, playerid, reason);
  73.  format(tok, sizeof(tok), "{FF0000}Admin %s(%i) has kicked you due to %s" ,adminname, nadmin, reason);
  74.  SendClientMessageToAll(-1,toall);
  75.  SendClientMessage(playerid,-1,tok);
  76.  SetTimerEx("KickPlayer",100,false,"i",playerid);
  77. }
  78. else
  79. {SendClientMessage(nadmin, -1, "{FF0000}You need to be admin to use this commnad.");}
  80.  return 1;}
  81. /*======================================================================================================*/
  82.  
  83. CMD:ban(playerid,parmas[])
  84. {
  85. if(PlayerInfo[playerid][pAdmin]>=1)// <---------PUT Your admin variables here and the levels who can use this cammand
  86. {
  87. new tid,du,d,m,y,h,mi,s,bx,ca,res[150];
  88. if(sscanf(parmas,"uis",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
  89. if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
  90. if(du>20)return SendClientMessage(playerid,-1,"You cannot ban a person for more than 20 days.");
  91. new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
  92. getdate(y,m,d);
  93. gettime(h,mi,s);
  94. bx=d+du;
  95. if(m==12 && bx>31)
  96. {y++;}
  97. if(bx>30 && m==4 || m==6 || m==9 || m==11)
  98. {ca=bx-30;m++; }
  99. else if(bx>31 && m==1 || m==3 || m==5 || m==7 ||m==8 || m==10 || m==12)
  100. {ca=bx-31;m++;}
  101. else if(m==2 && bx>29 && y%4==0)
  102. {ca=bx-29;m++;}
  103. else if(m==2 && bx>28 && y%4!=0)
  104. {ca=bx-28;m++;}
  105. else ca=bx;
  106.  
  107.  new INI:File = INI_Open(UserBanPath(tid));
  108.  INI_WriteInt(File,"Banexp",ca);
  109.  INI_WriteInt(File,"Banm",m);
  110.  INI_WriteInt(File,"Bany",y);
  111.  INI_WriteInt(File,"Banhour",h);
  112.  INI_WriteInt(File,"Banmin",mi);
  113.  INI_WriteString(File,"Reason",res);
  114.  INI_Close(File);
  115.  GetPlayerName(playerid,adminname,sizeof(adminname));
  116.  GetPlayerName(tid,targetn,sizeof(targetn));
  117.  format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
  118.  format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
  119.  SendClientMessage(tid,-1,banmt);
  120.  SendClientMessageToAll(-1,banma);
  121.  SetTimerEx("KickPlayer",100,false,"i",tid);
  122. }else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
  123. return 1;}
  124.  
  125. /*======================================================================================================*/
  126.  
  127. CMD:removeban(playerid,parmas[]){
  128. if(PlayerInfo[playerid][pAdmin]>=3)// <---------PUT Your admin variables here and the levels who can use this cammand
  129. {
  130. new rename[MAX_PLAYER_NAME],pat[MAX_PLAYER_NAME+10],ppf[100],adname[MAX_PLAYER_NAME];
  131. if(sscanf(parmas,"s",rename) || isnull(parmas))return SendClientMessage(playerid, -1, "{FF0000}Wrong Usage || Usage : /removeban PlayerName");
  132. format(pat,sizeof(pat),"Bans/%s.ini",rename);
  133. fremove(pat);
  134. format(ppf,sizeof(ppf),"The player %s has been sucessfully un-banned",rename);
  135. SendClientMessage(playerid,0x00FF00FF,ppf);
  136. GetPlayerName(playerid,adname,sizeof(adname));
  137. printf("%s has been unbanned by %s",rename,adname);}
  138. else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command");
  139. return 1;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement