Is there a way if player is admin to disable player command ?
#3

Yes, you can.
pawn Код:
new
    bool: Disabled_Command[ MAX_PLAYERS ]
;

// OnPlayerConnect
Disabled_Command[ playerid ] = false;

// command to disable (an example)
CMD:disablecmd( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not admin" );
    new
        id
    ;
    if( sscanf( params, "r", id ) ) return SendClientMessage( playerid, -1, "Usage: /disablecmd <ID/Part Of Name>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Offline player" );
    if( Disabled_Command[ id ] ) return SendClientMessage( playerid, -1, "The commands are disabled for that player already!" );
   
    Disabled_Command[ id ] = true;
    return 1;
}

// command to enable (an example)
CMD:enablecmd( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not admin" );
    new
        id
    ;
    if( sscanf( params, "r", id ) ) return SendClientMessage( playerid, -1, "Usage: /enablecmd <ID/Part Of Name>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Offline player" );
    if( !Disabled_Command[ id ] ) return SendClientMessage( playerid, -1, "The commands are enabled for that player already!" );

    Disabled_Command[ id ] = false;
    return 1;
}

// On some commands you want to disable (an example):
CMD:heal( playerid, params[ ] )
{
    if( Disabled_Command[ playerid ] ) return SendClientMessage( playerid, -1, "That command is blocked" );
    SetPlayerHealth( playerid, 100.0 );
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)