SA-MP Forums Archive
Ban system help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Ban system help (/showthread.php?tid=598590)



Ban system help - _GHT_MarK445 - 14.01.2016



Hey guys, i need help with my ban system.

I made this thanks to some tutorials, and it is ban command for days.

Код:
CMD:timeban(playerid,parmas[])
{
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "[ ! ] Nemбte dostateиnб admin prбva !");
else if(PlayerInfo[playerid][pAdmin] == 1)
{
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,"{ffffff}[ ! ] Pouћitн: /timeban [ ID ] [ POИET HODIN ] [ DЩVOD ]");
if(!IsPlayerConnected(tid))return SendClientMessage(playerid,-1,"{ffffff}[ ! ] Hrби nenн pшipojenэ");
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(banma,sizeof(banma),"{ff0000}Administrбtor %s zabanoval hrбиe %s na %d Hodin [ Dщvod: %s ]",adminname,targetn,du,res);
format(banmt,sizeof(banmt),"{ffffff}Myslнљ si, ћe ban, kterэ si dostal byl neoprбvnмnэ, nebo chceљ unban? Poћбdej si o nмj na {00FF00}game-force.eu/sub/forum/",adminname,du,res);
ShowPlayerDialog(playerid, 49789764, DIALOG_STYLE_MSGBOX, "Ban", banmt, "Ok", "");
SendClientMessageToAll(-1,banma);
SetTimerEx("KickPlayer",100,false,"i",tid);
}
return 1;}
I need to remake it, so it works for hours, every help will be appreciated with REP+.


Re: Ban system help - frog163 - 15.01.2016

It takes a lot of conditions. Better to do this:
Код:
CMD:timeban(playerid,parmas[]){
	if(PlayerInfo[playerid][pAdmin] != 1)
		return SendClientMessage(playerid, -1, "[ ! ] Nemбte dostateиnб admin prбva !");
	new tid,ho,res[150];
	if(sscanf(parmas,"uis",tid,ho,res) || isnull(parmas))
		return SendClientMessage(playerid,-1,"{ffffff}[ ! ] Pouћitн: /timeban [ ID ] [ POИET HODIN ] [ DЩVOD ]");
	if(!IsPlayerConnected(tid))
		return SendClientMessage(playerid,-1,"{ffffff}[ ! ] Hrби nenн pшipojenэ");
	new unix = gettime()+ho*3600;//unix_time + amount hours*(60sec*60min)
	new banmt[300], adminname[MAX_PLAYER_NAME], targetn[MAX_PLAYER_NAME];
	new INI:File = INI_Open(UserBanPath(tid));
	INI_WriteInt(File,"BaneUnix",unix);
	INI_WriteString(File,"Reason",res);
	INI_Close(File);
	GetPlayerName(playerid,adminname,sizeof(adminname));
	GetPlayerName(tid,targetn,sizeof(targetn));
	format(banmt, sizeof(banmt), "{ff0000}Administrбtor %s zabanoval hrбиe %s na %d Hodin [ Dщvod: %s ]",adminname,targetn,ho,res);
	SendClientMessageToAll(-1, banmt);
	format(banmt,sizeof(banmt),"{ffffff}Myslнљ si, ћe ban, kterэ si dostal byl neoprбvnмnэ, nebo chceљ unban? Poћбdej si o nмj na {00FF00}game-force.eu/sub/forum/",adminname,ho,res);
	ShowPlayerDialog(playerid, 49789764, DIALOG_STYLE_MSGBOX, "Ban", banmt, "Ok", "");
	SetTimerEx("KickPlayer",100,false,"i",tid);
	return true;
}
and on connect:
Код:
...
	new unix;
	Player_LoadInt("BaneUnix", unix);
	if(unix > gettime())//check ban
		SetTimerEx("KickPlayer",100,false,"i",playerid);
...