View Single Post
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 09-02-2017 , 18:51   Re: Help, I need to limit the input of the command
Reply With Quote #6

Quote:
Originally Posted by Bruno_Ferrari View Post
How to ban a command? !powerups for example, a blue team! Reds, they can use. Tell me please!!!!
Completely wrong section lmao but this template should work for ya:

PHP Code:
#include <sourcemod>
#include <tf2_stocks>

ConVar cv_BlueTeam;
ConVar cv_RedTeam;

new 
bool:bBlueTeamCvar;
new 
bool:bRedTeamCvar;

public 
OnPluginStart()
{
    
// Replace with whatever command you want to block for a team
    
AddCommandListener(CommandBlock"command_you_want_to_block");

    
cv_BlueTeam CreateConVar("sm_command_block_blue""1""Block the blue team from using the command?"_true0.0true1.0);
    
bBlueTeamCvar GetConVarBool(cv_BlueTeam);

    
cv_RedTeam CreateConVar("sm_command_block_red""1""Block the blue team from using the command?"_true0.0true1.0);
    
bRedTeamCvar GetConVarBool(cv_RedTeam);
}

public 
Action CommandBlock(int client, const char[] commandint argc)
{
    if (
IsValidClient(client))
    {
        if (
bBlueTeamCvar && TF2_GetClientTeam(client) == TFTeam_Blue)
        {
            return 
Plugin_Stop;
            
// Blocks the command for the client on the blue team
        
}
        else if (
bRedTeamCvar && TF2_GetClientTeam(client) == TFTeam_Red)
        {
            return 
Plugin_Stop;
            
// Blocks the command for the client on the red team            
        
}
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true

    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client))) 
    { 
        return 
false
    }
    return 
true;

Attached Files
File Type: sp Get Plugin or Get Source (tutorial.sp - 277 views - 1.4 KB)
ThatKidWhoGames is offline