View Single Post
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-07-2018 , 21:03   Re: [CS:S/CS:GO] blockteam
Reply With Quote #7

This plugins was making doubled stings, so map into map and than "team_blocked". I made some changes to fix that. Also, I removed the IsMapConfigured bool, since the command itself doens't duplicate existing strings, but simply edits them and now you can change the allowed team more than once, if you're not using the plugin in a MG server. No need of a config, the plugin will auto generate it when you use it for the first time.

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

public OnPluginStart()
{
    
RegAdminCmd("sm_allowteam"Command_BlockTeamADMFLAG_ROOT);
}

public 
void OnConfigsExecuted()
{
    
Parse_MapConfig(); ////Won't trigger a crash
}

public 
Action Command_BlockTeam(int clientint args)
{
    if(
IsFakeClient(client)) return Plugin_Handled;
    
    
char g_CurrentMap[128], allowedteam[6], config[PLATFORM_MAX_PATH];
    
GetCurrentMap(g_CurrentMapsizeof(g_CurrentMap));
    
BuildPath(Path_SMconfigsizeof(config), "configs/blockteam_config.cfg");
    
    
KeyValues BlockedMaps = new KeyValues("blockteam_config");
    
BlockedMaps.ImportFromFile(config);
    
BlockedMaps.JumpToKey(g_CurrentMaptrue);
    
    
GetCmdArgString(allowedteamsizeof(allowedteam));
    
    if(
StrEqual(allowedteam"ct"false))
    {
        
Format(allowedteamsizeof(allowedteam), "ct");
        
CPrintToChat(client" [{red}!{default}] Now players can only join the {green}counter-terorists {default}team.");
    }
    else if(
StrEqual(allowedteam"t"false))
    {
        
Format(allowedteamsizeof(allowedteam), "t");
        
CPrintToChat(client" [{red}!{default}] Now players can only join the {green}terorists {default}team.");
    }
    else if(
StrEqual(allowedteam"any"false)) 
    {
        
Format(allowedteamsizeof(allowedteam), "any");
        
CPrintToChat(client" [{red}!{default}] Now players can join {green}both {default}teams.");
    }
    else
    {
        
CPrintToChat(client" [{red}!{default}] Usage: {green}sm_allowteam {default}<{lightgreen}CT{default}{default}/{lightgreen}T{default}/{lightgreen}ANY{default}>");
        return 
Plugin_Handled;
    }

    
BlockedMaps.SetString("team_allowed"allowedteam);
    
BlockedMaps.Rewind();
    
BlockedMaps.ExportToFile(config);
    
delete BlockedMaps
    
    
Parse_MapConfig();
    
    return 
Plugin_Continue;
}

void Parse_MapConfig()
{
    
char g_Config[PLATFORM_MAX_PATH], g_CurrentMap[128];
    
GetCurrentMap(g_CurrentMapsizeof(g_CurrentMap));
    
BuildPath(Path_SMg_Configsizeof(g_Config), "configs/blockteam_config.cfg");

    
KeyValues block = new KeyValues("blockteam_config");

    if (
FileToKeyValues(blockg_Config))
    {
        
Handle allowedteam FindConVar("mp_humanteam");
        
        if (
KvJumpToKey(blockg_CurrentMap))
        {
            
char allowed[6];
            
KvGetString(block"team_allowed"allowedsizeof(allowed));
            if(
StrEqual(allowed"t"))
            {
                
SetConVarString(allowedteam"t"truefalse);
            }
            else if(
StrEqual(allowed"ct"))
            {
                
SetConVarString(allowedteam"ct"truefalse);
            }
            else if(
StrEqual(allowed"any"))
            {
                
SetConVarString(allowedteam"any"truefalse);
            }
        }
        else 
///If the map isn't in the config - allow all
        
{
            
SetConVarString(allowedteam"any"truefalse);
        }    
    }
    
delete block;

@Lannister, Zephyrus team bypass can't bypass this. I have it in my server and it doesn't bypass "mp_humanteam". (Had an extremely rare case, where a player was able to join the other team, but i'm pretty sure it was something else that caused it.)
Attached Files
File Type: inc csgocolors.inc (14.9 KB, 377 views)
__________________

Last edited by PinHeaDi; 01-07-2018 at 23:56.
PinHeaDi is offline