Making /ban command
#1

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 );
}
Here's my /tempban command but I want a permanent /ban command :/ I don't know how to create it please someone create it for me so that I can learn! I will give +rep
Reply
#2

Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Reply
#3

The amount of time you wasted in typing that, meanwhile you could've wrote the /ban command.
In addition I'm asking for help regarding /ban command!
Reply
#4

Bump!
Reply
#5

Quote:
Originally Posted by YouServ
Посмотреть сообщение
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
Scripting Help
What u Doing ?
Just Make Your Post count Up ?
Reported ==
Reply
#6

Quote:
Originally Posted by Amunra
Посмотреть сообщение
What u Doing ?
Just Make Your Post count Up ?
Reported ==
You're doing the same thing -.-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)