Jump to content
  • 0

pomoc Banv2


MatyOfficial

Dotaz

Zdarec,mám takový problém s timebanem (Banv2.pwn) změním příkaz na /banan , dám do AMX pak  dám na server zapíšu do configu jdu na server napíšu /rcon loadfs Banv2 Napíše mi to jakože načteno a najednou napíšu /banan a příkaz neexistuje..:/


Prosím pomoc... Moc s pawnem neumím sad.png Budu moc rád když někdo pomůže..


Code vám dávám pod mím podpisem.


Script vytvořil: Ewwe


 


              Vím , že bůh je spravedlivý , proto se někdy bojím o naší zem..



#file "Ban 1.0"
#include a_samp
#include Double-O-Files-2
#include sscanf


#pragma unused DOF2_Exit
/*----------------------------------------------------------------------------*/
#define CMD[%1] forward cmd_%1(playerid,params[],bool:help);public cmd_%1(playerid,params[],bool:help)
/*----------------------------------------------------------------------------*/
#define BANLIST_FILE "Banlist.ini"
#define HEADER "Ban Systém"
#define HLASKA "{FFFFFF}Pokud si myslíš že je ban neoprávněný, stiskni {FF0000}F8{FFFFFF}\na zašli screenshot na {00FF00}[email protected]{FFFFFF}."
/*----------------------------------------------------------------------------*/
#define SPLITTER .

new MonthTimes[12][4] =
{
{ 31, 31, 2678400, 2678400 },
{ 28, 29, 2419200, 2505600 },
{ 31, 31, 2678400, 2678400 },
{ 30, 30, 2592000, 2592000 },
{ 31, 31, 2678400, 2678400 },
{ 30, 30, 2592000, 2592000 },
{ 31, 31, 2678400, 2678400 },
{ 31, 31, 2678400, 2678400 },
{ 30, 30, 2592000, 2592000 },
{ 31, 31, 2678400, 2678400 },
{ 30, 30, 2592000, 2592000 },
{ 31, 31, 2678400, 2678400 }
};


CMD[ban]
{
if(help) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/banan [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
if(IsPlayerAdmin(playerid))
{
new player,count = 1,variable,reason[64],banstring[100],message[128];
if(sscanf(params,"iics",player,count,variable,reason) != 0) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/banan [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
new multiplier;
switch(variable)
{
case 'm':multiplier = 60;
case 'h':multiplier = 3600;
case 'd':multiplier = 86400;
case 't':multiplier = 604800;
case 'f':multiplier = 2592000;
case 'r':multiplier = 31536000;
default:return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Časový úsek zadán špatně!");
}
new tajm = gettime() + (multiplier*count);
format(banstring,100,"%s %s %i",GetName(playerid),reason,tajm);
DOF2_SetString( BANLIST_FILE , GetName(player) , banstring);
DOF2_SetString( BANLIST_FILE , GetIp(player) , banstring);
DOF2_SaveFile();
format(message,128,"[BAN] {FFFFFF}Zabanoval jsi {00FF00}%s{FFFFFF} za {FF0000}%s {FFFFFF}do {00FF00}%s",GetName(player),reason,ReturnDate(tajm));
SendClientMessage( playerid , 0xFF0000FF , message );
format(message,128,"[BAN] {FFFFFF}Byl jsi zabanován za {FF0000}%s {FFFFFF}do {00FF00}%s",reason,ReturnDate(tajm));
SendClientMessage( player , 0xFF0000FF , message );

KickPlayerAfterTime(player,3500);
}else return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Nemáš oprávnění!" );
return 1;
}
stock AutoBan( playerid , time , reason[] )
{
new string[128];
format(string,128,"%i %i %s",playerid,time,reason);
CallLocalFunction("cmd_ban","isi",255,params,0);
}
/*----------------------------------------------------------------------------*/
public OnPlayerConnect( playerid )
{
if(DOF2_IsSet( BANLIST_FILE , GetName( playerid ) ) )
{
new admin[21],reason[64],time;
sscanf( DOF2_GetString( BANLIST_FILE , GetName( playerid ) ) , "ssi",admin,reason,time);
if(time > gettime())
{
new formatr[500];
format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
{0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
KickPlayerAfterTime(playerid,3500);
}else{
SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
DOF2_Unset( BANLIST_FILE , GetName( playerid ) );
DOF2_SaveFile();
}
}else{
if(DOF2_IsSet( BANLIST_FILE , GetIp( playerid ) ) )
{
new admin[21],reason[64],time;
sscanf( DOF2_GetString( BANLIST_FILE , GetIp( playerid ) ) , "ssi",admin,reason,time);
if(time > gettime())
{
new formatr[500];
format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
{0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
KickPlayerAfterTime(playerid,3500);
}else{
SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
DOF2_Unset( BANLIST_FILE , GetIp( playerid ) );
DOF2_SaveFile();
}
}else{

}
}
return 1;
}
/*----------------------------------------------------------------------------*/
stock KickPlayerAfterTime( playerid , time )
{
SetTimerEx("KickPlayerAT",time,false,"i",playerid);
}
/*----------------------------------------------------------------------------*/
forward KickPlayerAT(playerid);
public KickPlayerAT(playerid) return Kick(playerid);
/*----------------------------------------------------------------------------*/
public OnFilterScriptInit()
{
if( !DOF2_FileExists( BANLIST_FILE ) )
{
DOF2_CreateFile( BANLIST_FILE );
DOF2_SaveFile();
print("Creating VIP file...");
}
return 1;
}
/*----------------------------------------------------------------------------*/
public OnPlayerCommandText(playerid, cmdtext[])
{

return OnPlayerCommand(playerid,cmdtext);
}
/*----------------------------------------------------------------------------*/
forward OnPlayerCommandTextEx(playerid,cmdtext[],command[],params[],bool:help);
stock OnPlayerCommand(playerid,command[])
{
new cmd[50],callback[55], params[128], size, len = strlen(command),help;
for(new i; i < len;i++)
{
if(command[i] != ' ')
{
if(command[i] >= 'A' && command[i] <= 'Z')
{
command[i] += 32;
}
}else{
size = i;
break;
}
}
if(size > 0)
{
strmid(cmd,command,1,size,50);
strmid(params,command,size+1,len,128);
}else{
format(cmd,50,command[1]);
}
if(!params[0]) params = " ";
if(!strcmp(params,"help")) help = 1;
format(callback,50,"cmd_%s",cmd);
if(CallLocalFunction(callback,"isi",playerid,params,help))
{
return true;
}else{
if(!CallLocalFunction("OnPlayerCommandTextEx","isssi",playerid,command,cmd,params,help))
{
return false;
}
}
return false;
}
/*----------------------------------------------------------------------------*/
stock GetName( i )
{
new n[ 21 ];
GetPlayerName( i , n , 21 );
return n;
}
/*----------------------------------------------------------------------------*/
stock GetIp( i )
{
new ip[16];
GetPlayerIp( i , ip , 16 );
return ip;
}
/*----------------------------------------------------------------------------*/
stock ReturnDate(timestamp)
{
new string[128];
if(timestamp == -1)
{
format(string,128,"%s","na trvalo");
}else{
new r,m,d,h,mm,s;
TimestampToDate(timestamp, r, m, d, h, mm, s, 2);
format(string,128,"%02d/%02d/%02d %02d:%02d %02ds",d,m,r,h,mm,s);
}
return string;
}
/*----------------------------------------------------------------------------*/
stock IsLeapYear(year)
{
if(year % 4 == 0) return 1;
else return 0;
}

stock TimestampToDate(Timestamp, &year, &month, &day, &hour, &minute, &second, HourGMT, MinuteGMT = 0)
{
new tmp = 2;
year = 1970;
month = 1;
Timestamp -= 172800; // Delete two days from the current timestamp. This is necessary, because the timestamp retrieved using gettime() includes two too many days.
for(;
{
if(Timestamp >= 31536000)
{
year ++;
Timestamp -= 31536000;
tmp ++;
if(tmp == 4)
{
if(Timestamp >= 31622400)
{
tmp = 0;
year ++;
Timestamp -= 31622400;
}
else break;
}
}
else break;
}
for(new i = 0; i < 12; i ++)
{
if(Timestamp >= MonthTimes[i][2 + IsLeapYear(year)])
{
month ++;
Timestamp -= MonthTimes[i][2 + IsLeapYear(year)];
}
else break;
}
day = 1 + (Timestamp / 86400);
Timestamp %= 86400;
hour = HourGMT + (Timestamp / 3600);
Timestamp %= 3600;
minute = MinuteGMT + (Timestamp / 60);
second = (Timestamp % 60);
if(minute > 59)
{
minute = 0;
hour ++;
if(hour > 23)
{
hour -= 24;
day ++;
if(day > MonthTimes[month][IsLeapYear(year)])
{
day = 1;
month ++;
if(month > 12)
{
month = 1;
year ++;
}
}
}
}
return 1;
}

stock DateToTimestamp(str[11])
{
new date[3]; // date[0] = day date[1] = month date[2] = year
if(!sscanf(str,"p<"#SPLITTER">ddd",date[0],date[1],date[2]))
{
new total = 0, tmp = 0;
total += date[0] * 86400;
if(date[1] == 2 && date[0] < 29) tmp = ((date[2] - 1968) / 4 - 2);
else tmp = ((date[2] - 1968) / 4 - 1);
total += tmp * 31622400;
total += (date[2] - 1970 - tmp) * 31536000;
for(new i = 1; i < date[1]; i ++) total += MonthTimes[i][0 + IsLeapYear(date[2])] * 86400;
return total;
}
else return -1;
}

Link to comment
Share on other sites

9 odpovědí na tuto otázku

Recommended Posts

  • 0

 

Zdarec,mám takový problém s timebanem (Banv2.pwn) změním příkaz na /banan , dám do AMX pak  dám na server zapíšu do configu jdu na server napíšu /rcon loadfs Banv2 Napíše mi to jakože načteno a najednou napíšu /banan a příkaz neexistuje..:/

Prosím pomoc... Moc s pawnem neumím sad.png Budu moc rád když někdo pomůže..

Code vám dávám pod mím podpisem.

Script vytvořil: Ewwe

 

              Vím , že bůh je spravedlivý , proto se někdy bojím o naší zem..

#file "Ban 1.0"
#include a_samp
#include Double-O-Files-2
#include sscanf


#pragma unused DOF2_Exit
/*----------------------------------------------------------------------------*/
#define CMD[%1] forward cmd_%1(playerid,params[],bool:help);public cmd_%1(playerid,params[],bool:help)
/*----------------------------------------------------------------------------*/
#define BANLIST_FILE "Banlist.ini"
#define HEADER "Ban Systém"
#define HLASKA "{FFFFFF}Pokud si myslíš že je ban neoprávněný, stiskni {FF0000}F8{FFFFFF}\na zašli screenshot na {00FF00}[email protected]{FFFFFF}."
/*----------------------------------------------------------------------------*/
#define SPLITTER .

new MonthTimes[12][4] =
{
	{ 31, 31, 2678400, 2678400 },
	{ 28, 29, 2419200, 2505600 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 }
};


CMD[ban]
{
	if(help) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/banan [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
	if(IsPlayerAdmin(playerid))
	{
		new player,count = 1,variable,reason[64],banstring[100],message[128];
		if(sscanf(params,"iics",player,count,variable,reason) != 0) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/banan [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
		new multiplier;
		switch(variable)
		{
		    case 'm':multiplier = 60;
		    case 'h':multiplier = 3600;
		    case 'd':multiplier = 86400;
		    case 't':multiplier = 604800;
		    case 'f':multiplier = 2592000;
		    case 'r':multiplier = 31536000;
		    default:return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Časový úsek zadán špatně!");
		}
		new tajm = gettime() + (multiplier*count);
		format(banstring,100,"%s %s %i",GetName(playerid),reason,tajm);
		DOF2_SetString( BANLIST_FILE , GetName(player) , banstring);
		DOF2_SetString( BANLIST_FILE , GetIp(player) , banstring);
		DOF2_SaveFile();
		format(message,128,"[BAN] {FFFFFF}Zabanoval jsi {00FF00}%s{FFFFFF} za {FF0000}%s {FFFFFF}do {00FF00}%s",GetName(player),reason,ReturnDate(tajm));
		SendClientMessage( playerid , 0xFF0000FF , message );
		format(message,128,"[BAN] {FFFFFF}Byl jsi zabanován za {FF0000}%s {FFFFFF}do {00FF00}%s",reason,ReturnDate(tajm));
		SendClientMessage( player , 0xFF0000FF , message );
		
		KickPlayerAfterTime(player,3500);
	}else return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Nemáš oprávnění!" );
	return 1;
}
stock AutoBan( playerid , time , reason[] )
{
	new string[128];
	format(string,128,"%i %i %s",playerid,time,reason);
	CallLocalFunction("cmd_ban","isi",255,params,0);
}
/*----------------------------------------------------------------------------*/
public OnPlayerConnect( playerid )
{
	if(DOF2_IsSet( BANLIST_FILE , GetName( playerid ) ) )
	{
	    new admin[21],reason[64],time;
     	sscanf( DOF2_GetString( BANLIST_FILE , GetName( playerid ) ) , "ssi",admin,reason,time);
		if(time > gettime())
		{
  			new formatr[500];
	    	format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
			                    {0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
			ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
			KickPlayerAfterTime(playerid,3500);
		}else{
		    SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
  			DOF2_Unset( BANLIST_FILE , GetName( playerid ) );
    		DOF2_SaveFile();
		}
	}else{
	    if(DOF2_IsSet( BANLIST_FILE , GetIp( playerid ) ) )
		{
            new admin[21],reason[64],time;
            sscanf( DOF2_GetString( BANLIST_FILE , GetIp( playerid ) ) , "ssi",admin,reason,time);
			if(time > gettime())
			{
			    new formatr[500];
			    format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
			                    {0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
				ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
                KickPlayerAfterTime(playerid,3500);
			}else{
			    SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
			    DOF2_Unset( BANLIST_FILE , GetIp( playerid ) );
	        	DOF2_SaveFile();
			}
		}else{

		}
	}
	return 1;
}
/*----------------------------------------------------------------------------*/
stock KickPlayerAfterTime( playerid , time )
{
	SetTimerEx("KickPlayerAT",time,false,"i",playerid);
}
/*----------------------------------------------------------------------------*/
forward KickPlayerAT(playerid);
public KickPlayerAT(playerid) return Kick(playerid);
/*----------------------------------------------------------------------------*/
public OnFilterScriptInit()
{
	if( !DOF2_FileExists( BANLIST_FILE ) )
	{
	    DOF2_CreateFile( BANLIST_FILE );
	    DOF2_SaveFile();
	    print("Creating VIP file...");
	}
	return 1;
}
/*----------------------------------------------------------------------------*/
public OnPlayerCommandText(playerid, cmdtext[])
{

	return OnPlayerCommand(playerid,cmdtext);
}
/*----------------------------------------------------------------------------*/
forward OnPlayerCommandTextEx(playerid,cmdtext[],command[],params[],bool:help);
stock OnPlayerCommand(playerid,command[])
{
	new cmd[50],callback[55], params[128], size, len = strlen(command),help;
	for(new i; i < len;i++)
	{
		if(command[i] != ' ')
		{
  			if(command[i] >= 'A' && command[i] <= 'Z')
  			{
     			command[i] += 32;
        	}
     	}else{
      		size = i;
        	break;
      	}
	}
	if(size > 0)
	{
 		strmid(cmd,command,1,size,50);
   		strmid(params,command,size+1,len,128);
   	}else{
    	format(cmd,50,command[1]);
    }
	if(!params[0]) params = " ";
 	if(!strcmp(params,"help")) help = 1;
  	format(callback,50,"cmd_%s",cmd);
   	if(CallLocalFunction(callback,"isi",playerid,params,help))
    {
    	return true;
    }else{
    	if(!CallLocalFunction("OnPlayerCommandTextEx","isssi",playerid,command,cmd,params,help))
		{
  			return false;
     	}
 	}
  	return false;
}
/*----------------------------------------------------------------------------*/
stock GetName( i )
{
	new n[ 21 ];
	GetPlayerName( i , n , 21 );
	return n;
}
/*----------------------------------------------------------------------------*/
stock GetIp( i )
{
	new ip[16];
	GetPlayerIp( i , ip , 16 );
	return ip;
}
/*----------------------------------------------------------------------------*/
stock ReturnDate(timestamp)
{
	new string[128];
	if(timestamp == -1)
	{
	    format(string,128,"%s","na trvalo");
	}else{
	    new r,m,d,h,mm,s;
        TimestampToDate(timestamp, r, m, d, h, mm, s, 2);
        format(string,128,"%02d/%02d/%02d %02d:%02d %02ds",d,m,r,h,mm,s);
	}
	return string;
}
/*----------------------------------------------------------------------------*/
stock IsLeapYear(year)
{
	if(year % 4 == 0) return 1;
	else return 0;
}

stock TimestampToDate(Timestamp, &year, &month, &day, &hour, &minute, &second, HourGMT, MinuteGMT = 0)
{
	new tmp = 2;
	year = 1970;
	month = 1;
	Timestamp -= 172800; // Delete two days from the current timestamp. This is necessary, because the timestamp retrieved using gettime() includes two too many days.
	for(;
	{
		if(Timestamp >= 31536000)
		{
			year ++;
			Timestamp -= 31536000;
			tmp ++;
			if(tmp == 4)
			{
				if(Timestamp >= 31622400)
				{
					tmp = 0;
					year ++;
					Timestamp -= 31622400;
				}
				else break;
			}
		}
		else break;
	}
	for(new i = 0; i < 12; i ++)
	{
		if(Timestamp >= MonthTimes[i][2 + IsLeapYear(year)])
		{
			month ++;
			Timestamp -= MonthTimes[i][2 + IsLeapYear(year)];
		}
		else break;
	}
	day = 1 + (Timestamp / 86400);
	Timestamp %= 86400;
	hour = HourGMT + (Timestamp / 3600);
	Timestamp %= 3600;
	minute = MinuteGMT + (Timestamp / 60);
	second = (Timestamp % 60);
	if(minute > 59)
	{
		minute = 0;
		hour ++;
		if(hour > 23)
		{
			hour -= 24;
			day ++;
			if(day > MonthTimes[month][IsLeapYear(year)])
			{
				day = 1;
				month ++;
				if(month > 12)
				{
					month = 1;
					year ++;
				}
			}
		}
	}
	return 1;
}

stock DateToTimestamp(str[11])
{
	new date[3]; // date[0] = day		date[1] = month			date[2] = year
	if(!sscanf(str,"p<"#SPLITTER">ddd",date[0],date[1],date[2]))
	{
		new total = 0, tmp = 0;
		total += date[0] * 86400;
		if(date[1] == 2 && date[0] < 29) tmp = ((date[2] - 1968) / 4 - 2);
		else tmp = ((date[2] - 1968) / 4 - 1);
		total += tmp * 31622400;
		total += (date[2] - 1970 - tmp) * 31536000;
		for(new i = 1; i < date[1]; i ++) total += MonthTimes[i][0 + IsLeapYear(date[2])] * 86400;
		return total;
	}
	else return -1;
}

WTF ? Ti tam máš CMD[ban] ? Oprav si to na CMD:ban možno to tak je aspoň si to tak myslím.

Link to comment
Share on other sites

  • 0

@*SuperManík* až budu doma zkusím :) Pak písnu.. PS: Takhle jsem to už stáhnul :) Pokud by ses na to chtěl nějak zvláštně podívat, download: http://pawno.cz/files/file/105-tban/ 

Zatím díky.:)

Skype: vokurkamaty

                    Vím , že bůh je spravedlivý , proto se někdy bojím o naší zem..

Link to comment
Share on other sites

  • 0

Jak říká :) Sanios CMD[ban] Stačí přepsat na toto CMD[banan]

 

Já to sám osobně mám :) CMD[tban] Takto :)...

 

Já mám jíný problém nevím kam se ty bany ukládají v BANLISTU nejsu :d


Zkus to ještě takto 

#file "Ban 1.0"
#include a_samp
#include Double-O-Files-2
#include sscanf


#pragma unused DOF2_Exit
/*----------------------------------------------------------------------------*/
#define CMD[%1] forward cmd_%1(playerid,params[],bool:help);public cmd_%1(playerid,params[],bool:help)
/*----------------------------------------------------------------------------*/
#define BANLIST_FILE "Banlist.ini"
#define HEADER "Ban Systém"
#define HLASKA "{FFFFFF}Pokud si myslíš že je ban neoprávněný, stiskni {FF0000}F8{FFFFFF}\na zašli screenshot na {00FF00}[email protected]{FFFFFF}."
/*----------------------------------------------------------------------------*/
#define SPLITTER .

new MonthTimes[12][4] =
{
	{ 31, 31, 2678400, 2678400 },
	{ 28, 29, 2419200, 2505600 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 },
	{ 30, 30, 2592000, 2592000 },
	{ 31, 31, 2678400, 2678400 }
};


CMD[tban]
{
	if(help) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/tban [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
	if(IsPlayerAdmin(playerid))
	{
		new player,count = 1,variable,reason[64],banstring[100],message[128];
		if(sscanf(params,"iics",player,count,variable,reason) != 0) return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Použití \"/tban [playerid] [počet] [m/h/d/t/f/r] [důvod]\"" );
		new multiplier;
		switch(variable)
		{
		    case 'm':multiplier = 60;
		    case 'h':multiplier = 3600;
		    case 'd':multiplier = 86400;
		    case 't':multiplier = 604800;
		    case 'f':multiplier = 2592000;
		    case 'r':multiplier = 31536000;
		    default:return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Časový úsek zadán špatně!");
		}
		new tajm = gettime() + (multiplier*count);
		format(banstring,100,"%s %s %i",GetName(playerid),reason,tajm);
		DOF2_SetString( BANLIST_FILE , GetName(player) , banstring);
		DOF2_SetString( BANLIST_FILE , GetIp(player) , banstring);
		DOF2_SaveFile();
		format(message,128,"[BAN] {FFFFFF}Zabanoval jsi {00FF00}%s{FFFFFF} za {FF0000}%s {FFFFFF}do {00FF00}%s",GetName(player),reason,ReturnDate(tajm));
		SendClientMessage( playerid , 0xFF0000FF , message );
		format(message,128,"[BAN] {FFFFFF}Byl jsi zabanován za {FF0000}%s {FFFFFF}do {00FF00}%s",reason,ReturnDate(tajm));
		SendClientMessage( player , 0xFF0000FF , message );
		
		KickPlayerAfterTime(player,3500);
	}else return SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Nemáš oprávnění!" );
	return 1;
}
stock AutoBan( playerid , time , reason[] )
{
	new string[128];
	format(string,128,"%i %i %s",playerid,time,reason);
	CallLocalFunction("cmd_ban","isi",255,params,0);
}
/*----------------------------------------------------------------------------*/
public OnPlayerConnect( playerid )
{
	if(DOF2_IsSet( BANLIST_FILE , GetName( playerid ) ) )
	{
	    new admin[21],reason[64],time;
     	sscanf( DOF2_GetString( BANLIST_FILE , GetName( playerid ) ) , "ssi",admin,reason,time);
		if(time > gettime())
		{
  			new formatr[500];
	    	format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
			                    {0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
			ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
			KickPlayerAfterTime(playerid,3500);
		}else{
		    SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
  			DOF2_Unset( BANLIST_FILE , GetName( playerid ) );
    		DOF2_SaveFile();
		}
	}else{
	    if(DOF2_IsSet( BANLIST_FILE , GetIp( playerid ) ) )
		{
            new admin[21],reason[64],time;
            sscanf( DOF2_GetString( BANLIST_FILE , GetIp( playerid ) ) , "ssi",admin,reason,time);
			if(time > gettime())
			{
			    new formatr[500];
			    format(formatr,500,"{FFFFFF}Na tomto serveru jsi byl zabanován.\n\
			                    {0080FF}Důvod {FFFFFF}: {FF8000}%s\n{0080FF}Admin {FFFFFF}: {FF8000}%s\n{0080FF}Trvání banu {FFFFFF}: {FF8000}%s\n%s",reason,admin,ReturnDate(time),HLASKA);
				ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"{FFFFFF}Ban Systém",formatr,"Zavřít","");
                KickPlayerAfterTime(playerid,3500);
			}else{
			    SendClientMessage( playerid , 0xFF0000FF , "[BAN] {FFFFFF}Dostal jsi unban, doufáme že jsi se poučil!");
			    DOF2_Unset( BANLIST_FILE , GetIp( playerid ) );
	        	DOF2_SaveFile();
			}
		}else{

		}
	}
	return 1;
}
/*----------------------------------------------------------------------------*/
stock KickPlayerAfterTime( playerid , time )
{
	SetTimerEx("KickPlayerAT",time,false,"i",playerid);
}
/*----------------------------------------------------------------------------*/
forward KickPlayerAT(playerid);
public KickPlayerAT(playerid) return Kick(playerid);
/*----------------------------------------------------------------------------*/
public OnFilterScriptInit()
{
	if( !DOF2_FileExists( BANLIST_FILE ) )
	{
	    DOF2_CreateFile( BANLIST_FILE );
	    DOF2_SaveFile();
	    print("Creating VIP file...");
	}
	return 1;
}
/*----------------------------------------------------------------------------*/
public OnPlayerCommandText(playerid, cmdtext[])
{

	return OnPlayerCommand(playerid,cmdtext);
}
/*----------------------------------------------------------------------------*/
forward OnPlayerCommandTextEx(playerid,cmdtext[],command[],params[],bool:help);
stock OnPlayerCommand(playerid,command[])
{
	new cmd[50],callback[55], params[128], size, len = strlen(command),help;
	for(new i; i < len;i++)
	{
		if(command[i] != ' ')
		{
  			if(command[i] >= 'A' && command[i] <= 'Z')
  			{
     			command[i] += 32;
        	}
     	}else{
      		size = i;
        	break;
      	}
	}
	if(size > 0)
	{
 		strmid(cmd,command,1,size,50);
   		strmid(params,command,size+1,len,128);
   	}else{
    	format(cmd,50,command[1]);
    }
	if(!params[0]) params = " ";
 	if(!strcmp(params,"help")) help = 1;
  	format(callback,50,"cmd_%s",cmd);
   	if(CallLocalFunction(callback,"isi",playerid,params,help))
    {
    	return true;
    }else{
    	if(!CallLocalFunction("OnPlayerCommandTextEx","isssi",playerid,command,cmd,params,help))
		{
  			return false;
     	}
 	}
  	return false;
}
/*----------------------------------------------------------------------------*/
stock GetName( i )
{
	new n[ 21 ];
	GetPlayerName( i , n , 21 );
	return n;
}
/*----------------------------------------------------------------------------*/
stock GetIp( i )
{
	new ip[16];
	GetPlayerIp( i , ip , 16 );
	return ip;
}
/*----------------------------------------------------------------------------*/
stock ReturnDate(timestamp)
{
	new string[128];
	if(timestamp == -1)
	{
	    format(string,128,"%s","na trvalo");
	}else{
	    new r,m,d,h,mm,s;
        TimestampToDate(timestamp, r, m, d, h, mm, s, 2);
        format(string,128,"%02d/%02d/%02d %02d:%02d %02ds",d,m,r,h,mm,s);
	}
	return string;
}
/*----------------------------------------------------------------------------*/
stock IsLeapYear(year)
{
	if(year % 4 == 0) return 1;
	else return 0;
}

stock TimestampToDate(Timestamp, &year, &month, &day, &hour, &minute, &second, HourGMT, MinuteGMT = 0)
{
	new tmp = 2;
	year = 1970;
	month = 1;
	Timestamp -= 172800; // Delete two days from the current timestamp. This is necessary, because the timestamp retrieved using gettime() includes two too many days.
	for(;
	{
		if(Timestamp >= 31536000)
		{
			year ++;
			Timestamp -= 31536000;
			tmp ++;
			if(tmp == 4)
			{
				if(Timestamp >= 31622400)
				{
					tmp = 0;
					year ++;
					Timestamp -= 31622400;
				}
				else break;
			}
		}
		else break;
	}
	for(new i = 0; i < 12; i ++)
	{
		if(Timestamp >= MonthTimes[i][2 + IsLeapYear(year)])
		{
			month ++;
			Timestamp -= MonthTimes[i][2 + IsLeapYear(year)];
		}
		else break;
	}
	day = 1 + (Timestamp / 86400);
	Timestamp %= 86400;
	hour = HourGMT + (Timestamp / 3600);
	Timestamp %= 3600;
	minute = MinuteGMT + (Timestamp / 60);
	second = (Timestamp % 60);
	if(minute > 59)
	{
		minute = 0;
		hour ++;
		if(hour > 23)
		{
			hour -= 24;
			day ++;
			if(day > MonthTimes[month][IsLeapYear(year)])
			{
				day = 1;
				month ++;
				if(month > 12)
				{
					month = 1;
					year ++;
				}
			}
		}
	}
	return 1;
}

stock DateToTimestamp(str[11])
{
	new date[3]; // date[0] = day		date[1] = month			date[2] = year
	if(!sscanf(str,"p<"#SPLITTER">ddd",date[0],date[1],date[2]))
	{
		new total = 0, tmp = 0;
		total += date[0] * 86400;
		if(date[1] == 2 && date[0] < 29) tmp = ((date[2] - 1968) / 4 - 2);
		else tmp = ((date[2] - 1968) / 4 - 1);
		total += tmp * 31622400;
		total += (date[2] - 1970 - tmp) * 31536000;
		for(new i = 1; i < date[1]; i ++) total += MonthTimes[i][0 + IsLeapYear(date[2])] * 86400;
		return total;
	}
	else return -1;
}

Příkaz je /tban :)..Ten kod vlož do pawna a nic neupravuj -_-....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...