28.02.2016, 10:29
pawn Код:
CMD:tempban( playerid, params[ ] )
{
LevelCheck( playerid, 4 );
new
liPlayer,
liDays,
lsReason[ 56 ]
;
if ( sscanf( params, "uis[56]", liPlayer, liDays, lsReason ) )
return SendClientMessage( playerid, COLOR_ULTRARED, "{FF0000}» {DB881A}USAGE: {FFE4C4}/ban [PlayerID] [Day(s)] [Reason]" );
if ( !IsPlayerConnected( liPlayer ) )
return SendError( playerid, "Player not connected !" );
if ( IsPlayerAdmin( liPlayer ) )
FormatMSG( liPlayer, COLOR_ULTRARED, "%s has tried to ban you!", PlayerName( playerid ) );
if ( strlen( lsReason ) < 3 || strlen( lsReason ) > 30 )
return SendError( playerid, "Invalid reason size. Between 3 and 30 characters !" );
if ( liPlayer == playerid )
return SendError( playerid, "You can't ban yourself!" );
if ( PlayerInfo[ playerid ][ BanTimer ] == 1 && !IsPlayerAdmin( playerid ) )
return SendError( playerid, "You can't ban another player in only 30 seconds!" );
if(IsPlayerNPC(liPlayer)) return 0;
if ( liDays < 1 || liDays > 30 )
return SendError( playerid, "Invalid day ! Write values between 1 and 30." );
if(IsPlayerNPC(liPlayer)) return 0;
gsString[ 0 ] = EOS;
TextDrawShowForPlayer( liPlayer, Ban_Backround );
TextDrawShowForPlayer( liPlayer, Ban_Info );
TextDrawShowForPlayer( liPlayer, Ban_Message );
TextDrawShowForPlayer( liPlayer, Ban_Details_TD );
TextDrawShowForPlayer( liPlayer, Ban_Mistake );
PlayerInfo[ playerid ][ PBans ]++;
format( gsString, sizeof( gsString ), "{FFFF00}- AS - {FF0000}%s(%d) has been banned by an Administrator. {778899}[Reason: %s]", PlayerName( liPlayer ),liPlayer, lsReason );
SendClientMessageToAll( COLOR_ORANGE, gsString );
TogglePlayerControllable( liPlayer, false );
new
szDay,
szMonth,
szYear,
szHour,
szMinute,
szSecond
;
getdate( szYear, szMonth, szDay );
gettime( szHour, szMinute, szSecond );
new
year,
month,
day
;
getdate( year, month, day );
day += liDays;
if ( IsMonth31( month ) )
{
if ( day > 31 )
{
month += 1;
if ( month > 12 )
{
year += 1;
while( day > 31 ) day -= 31;
}
else while( day > 31 ) day -= 31;
}
}
else if ( !IsMonth31( month ) )
{
if ( day > 30 )
{
month += 1;
if ( month > 12 )
{
year += 1;
while( day > 30 ) day -= 30;
}
else while( day > 30 ) day -= 30;
}
}
else if ( !IsMonth31( month ) && IsMonth29( year ) && month == 2 )
{
if ( day > 29 )
{
month += 1;
if ( month > 12 )
{
year += 1;
while( day > 29 ) day -= 29;
}
else while( day > 29 ) day -= 29;
}
}
else if ( !IsMonth31( month ) && !IsMonth29( year ) && month == 2 )
{
if ( day > 28 )
{
month += 1;
if ( month > 12 )
{
year += 1;
while( day > 28 ) day -= 28;
}
else while( day > 28 ) day -= 28;
}
}
format( gsQuery, 1024, "INSERT INTO `banlist` (`Key`,`IP`,`Name`,`BReason`,`BAdmin`,`BDate`,`BanTime`,`BanDays`) VALUES(0,'%s','%s','%s','%s','%d-%d-%d','%d:%d:%d',%d)", GetPlayerIPEx( liPlayer ), PlayerName( liPlayer ), lsReason, PlayerName( playerid ), szYear, szMonth, szDay, szHour, szMinute, szSecond, liDays );
mysql_query( gsQuery, THREAD_NONE );
format( gsString, sizeof( gsString ), "Banned by Administrator: %s~n~Ban Date: %d/%d/%d~n~Ban Time: %d/%d/%d~n~Ban Reason: %s~n~Un-Ban After: %d/%d/%d", PlayerName( playerid ), szDay, szMonth, szYear, szHour, szMinute, szSecond, lsReason, day, month, year );
TextDrawSetString( Ban_Details[ liPlayer ], gsString );
TextDrawShowForPlayer( liPlayer, Ban_Details[ liPlayer ] );
Kick( liPlayer );
PlayerInfo[ playerid ][ BanTimer ] = ( 1 );
SetTimerEx( "ResetBanTimer", 3*10000, 0, "i", playerid );
FormatLog( "BanCMD_Log", "Administrator %s has banned %s for reason: '%s'", PlayerName( playerid ), PlayerName( liPlayer ), lsReason );
return ( 1 );
}