03.09.2013, 12:48
If player is admin is there a way to dizable command and player cant use that command ?
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;
}
// command to disable (an example)
CMD:disablecmd( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not admin" );
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( !IsPlayerConnected( i ) || IsPlayerNPC( i ) ) continue;
Disabled_Command[ i ] = true;
}
return 1;
}
// command to enable (an example)
CMD:enablecmd( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not admin" );
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( !IsPlayerConnected( i ) || IsPlayerNPC( i ) ) continue;
Disabled_Command[ i ] = false;
}
return 1;
}
Then change the 2 commands to:
pawn Код:
|
if( Disabled_Command[ playerid ] ) return SendClientMessage( playerid, -1, "That command is blocked" );
// 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;
}
CMD:hi(playerid, params[])
{
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Admins cannot use this command."); //This checks if they're logged in as RCON Admin, change it to what you use
SendClientMessage(playerid, -1, "Hello");
return 1;
}