Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This script is purely made by Zeus
- //All its Credits to Zeus for scripting
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <YSI\y_ini>
- #define BANPATH "/Bans/%s.ini"
- enum pInfo
- {
- pBanexp,
- pBanm,
- pBany,
- pBanh,
- pBanmi,
- pBanres
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadBanUser_data(playerid,name[],value[]);
- public LoadBanUser_data(playerid,name[],value[])
- {INI_Int("Banexp",PlayerInfo[playerid][pBanexp]);
- INI_Int("Banm",PlayerInfo[playerid][pBanm]);
- INI_Int("Bany",PlayerInfo[playerid][pBany]);
- INI_Int("Banhour",PlayerInfo[playerid][pBanh]);
- INI_Int("Banmin",PlayerInfo[playerid][pBanmi]);
- INI_Int("Reason",PlayerInfo[playerid][pBanres]);
- return 1;
- }
- stock UserBanPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),BANPATH,playername);
- return string;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserBanPath(playerid)))
- { INI_ParseFile(UserBanPath(playerid), "LoadBanUser_%s", .bExtra = true, .extra = playerid);
- new d,m,y,h,mi,s;
- getdate(y,m,d);
- gettime(h,mi,s);
- 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]))
- {fremove(UserBanPath(playerid));}
- else
- {new clt[200],cltim[100];
- SendClientMessage(playerid,-1,"{ff0000}You are currently Ban from the server");
- 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]);
- format(cltim,sizeof(cltim),"{F0FFFF}At Time : {FFE5B4}%i:%i {F0FFFF}[Time Format: 24 Hour Clock]",PlayerInfo[playerid][pBanh],PlayerInfo[playerid][pBanmi]);
- SendClientMessage(playerid,-1,clt);
- SendClientMessage(playerid,-1,cltim);
- SetTimerEx("KickPlayer",70,false,"i",playerid);
- }}}
- forward KickPlayer(playerid);
- public KickPlayer(playerid)
- {
- Kick(playerid);
- return 1;
- }
- /*=================================COMMANDS FROM HERE=========================================*/
- CMD:kick(nadmin,parmas[])
- {new tok[300], toall[300], playerid, reason[128], adminname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
- if(PlayerInfo[nadmin][pAdmin]>=1)// <---------PUT Your admin variables here and the levels who can use this cammand
- {if(sscanf(parmas, "us", playerid, reason) || isnull(parmas))return SendClientMessage(nadmin,-1,"{FF0000}Wrong Usage || Usage: /kick id reason");
- if(!IsPlayerConnected(playerid))return SendClientMessage(nadmin,-1,"{FF0000}The player you want to kick is not connected");
- GetPlayerName(nadmin, adminname, sizeof(adminname));
- GetPlayerName(playerid, kname, sizeof(kname));
- format(toall, sizeof(toall), "{FF0000}Admin %s(%i) has kicked %s(%i) due to %s" , adminname, nadmin, kname, playerid, reason);
- format(tok, sizeof(tok), "{FF0000}Admin %s(%i) has kicked you due to %s" ,adminname, nadmin, reason);
- SendClientMessageToAll(-1,toall);
- SendClientMessage(playerid,-1,tok);
- SetTimerEx("KickPlayer",100,false,"i",playerid);
- }
- else
- {SendClientMessage(nadmin, -1, "{FF0000}You need to be admin to use this commnad.");}
- return 1;}
- /*======================================================================================================*/
- CMD:ban(playerid,parmas[])
- {
- if(PlayerInfo[playerid][pAdmin]>=1)// <---------PUT Your admin variables here and the levels who can use this cammand
- {
- new tid,du,d,m,y,h,mi,s,bx,ca,res[150];
- if(sscanf(parmas,"uis",tid,du,res) || isnull(parmas))return SendClientMessage(playerid,-1,"{ff0000}Wrong Usage || Correct Usage : /ban id duration(In Days) Reason");
- if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ff6666}The Player you requested is not connected.");
- if(du>20)return SendClientMessage(playerid,-1,"You cannot ban a person for more than 20 days.");
- new banmt[300],banma[300],adminname[MAX_PLAYER_NAME],targetn[MAX_PLAYER_NAME];
- getdate(y,m,d);
- gettime(h,mi,s);
- bx=d+du;
- if(m==12 && bx>31)
- {y++;}
- if(bx>30 && m==4 || m==6 || m==9 || m==11)
- {ca=bx-30;m++; }
- else if(bx>31 && m==1 || m==3 || m==5 || m==7 ||m==8 || m==10 || m==12)
- {ca=bx-31;m++;}
- else if(m==2 && bx>29 && y%4==0)
- {ca=bx-29;m++;}
- else if(m==2 && bx>28 && y%4!=0)
- {ca=bx-28;m++;}
- else ca=bx;
- new INI:File = INI_Open(UserBanPath(tid));
- INI_WriteInt(File,"Banexp",ca);
- INI_WriteInt(File,"Banm",m);
- INI_WriteInt(File,"Bany",y);
- INI_WriteInt(File,"Banhour",h);
- INI_WriteInt(File,"Banmin",mi);
- INI_WriteString(File,"Reason",res);
- INI_Close(File);
- GetPlayerName(playerid,adminname,sizeof(adminname));
- GetPlayerName(tid,targetn,sizeof(targetn));
- format(banmt,sizeof(banmt),"{ff0000}Admin %s has banned you for %i days due to %s",adminname,du,res);
- format(banma,sizeof(banma),"{ff0000}Admin %s has banned %s for %i days due to %s",adminname,targetn,du,res);
- SendClientMessage(tid,-1,banmt);
- SendClientMessageToAll(-1,banma);
- SetTimerEx("KickPlayer",100,false,"i",tid);
- }else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command.");
- return 1;}
- /*======================================================================================================*/
- CMD:removeban(playerid,parmas[]){
- if(PlayerInfo[playerid][pAdmin]>=3)// <---------PUT Your admin variables here and the levels who can use this cammand
- {
- new rename[MAX_PLAYER_NAME],pat[MAX_PLAYER_NAME+10],ppf[100],adname[MAX_PLAYER_NAME];
- if(sscanf(parmas,"s",rename) || isnull(parmas))return SendClientMessage(playerid, -1, "{FF0000}Wrong Usage || Usage : /removeban PlayerName");
- format(pat,sizeof(pat),"Bans/%s.ini",rename);
- fremove(pat);
- format(ppf,sizeof(ppf),"The player %s has been sucessfully un-banned",rename);
- SendClientMessage(playerid,0x00FF00FF,ppf);
- GetPlayerName(playerid,adname,sizeof(adname));
- printf("%s has been unbanned by %s",rename,adname);}
- else SendClientMessage(playerid,-1,"{ff0000}You are not authorized to use this command");
- return 1;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement