sscanf + PlayerInfo (pEnum) + text + zcmd = impossible?
#2

If you use the new sscanf plugin that would ease your work alot!

Here is my /ban command using the new sscanf.

pawn Код:
CMD:ban( zParams )
{
    LoginCheck( playerid );
    LevelCheck( playerid, 5 );

    new Player, IpBan, Reason[ 40 ];
    if ( sscanf( params, "udS(No Reason)[40]", Player, IpBan, Reason ) || IpBan > 1 || IpBan < 0 ) return SendUsage( playerid, "/ban "GREY"<id> <ipban 1/0> [reason]     "GREY"(1 - It will IP Ban the player | 0 - Only account ban!)", "Will ban the specified player, a log of this ban will be created" );
    else
    {
        if ( playerid == Player ) return SendError( playerid,  "You can't ban yourself!");
        if ( Player  == (0xFFFF)) return SendError( playerid,  "Player not connected!");
        CheckImune( playerid, Player );

        if ( IpBan )    BanEx2( Player, Name( playerid ), Reason, 1);
        else
        {
            if ( !fexist( pFile( Player ) ) )
            {
                FormatMSG( playerid, Color:ORAN, "* Player "ORAN"%s"GREY" doesn't have an account to be account banned! Choose ipban!", Name( Player ) );
                return 1;
            }
            new INI:pAcc = INI_Open( pFile( Player ) );
            INI_WriteInt( pAcc, "Banned", 1 );
            INI_WriteString( pAcc, "Reason", Reason );
            INI_WriteString( pAcc, "BanDate", zDate( ) );
            INI_Close( pAcc );

            BanEx2( Player, Name( playerid ), Reason, 0);
        }
        SendAdminCMD( playerid, ""W"Player "ORAN"%s[%i]"W" has been %s by "ORAN"%s[%i] "W"with reason"ORAN" \"%s\"",Name( Player ),Player,( IpBan ) ? ("IP banned") : ("account banned"),Name( playerid ),playerid,Reason );
        FormatMSG( playerid, -1, "You have %s "ORAN"%s[%i] "W"from the server "GREE"["W" %s "GREE"]", ( IpBan ) ? ("IP banned") : ("account banned"), Name( Player ), Player, Reason );
    }
    return 1;
}
Ignore the other code, just watch the sscanf code.
Reply


Messages In This Thread
sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by SaW_[VrTx] - 01.05.2011, 18:09
Re: sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by Zh3r0 - 01.05.2011, 18:11
Re: sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by SaW_[VrTx] - 01.05.2011, 18:25

Forum Jump:


Users browsing this thread: 1 Guest(s)