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_BlockTeam, ADMFLAG_ROOT);
}
public void OnConfigsExecuted()
{
Parse_MapConfig(); ////Won't trigger a crash
}
public Action Command_BlockTeam(int client, int args)
{
if(IsFakeClient(client)) return Plugin_Handled;
char g_CurrentMap[128], allowedteam[6], config[PLATFORM_MAX_PATH];
GetCurrentMap(g_CurrentMap, sizeof(g_CurrentMap));
BuildPath(Path_SM, config, sizeof(config), "configs/blockteam_config.cfg");
KeyValues BlockedMaps = new KeyValues("blockteam_config");
BlockedMaps.ImportFromFile(config);
BlockedMaps.JumpToKey(g_CurrentMap, true);
GetCmdArgString(allowedteam, sizeof(allowedteam));
if(StrEqual(allowedteam, "ct", false))
{
Format(allowedteam, sizeof(allowedteam), "ct");
CPrintToChat(client, " [{red}!{default}] Now players can only join the {green}counter-terorists {default}team.");
}
else if(StrEqual(allowedteam, "t", false))
{
Format(allowedteam, sizeof(allowedteam), "t");
CPrintToChat(client, " [{red}!{default}] Now players can only join the {green}terorists {default}team.");
}
else if(StrEqual(allowedteam, "any", false))
{
Format(allowedteam, sizeof(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_CurrentMap, sizeof(g_CurrentMap));
BuildPath(Path_SM, g_Config, sizeof(g_Config), "configs/blockteam_config.cfg");
KeyValues block = new KeyValues("blockteam_config");
if (FileToKeyValues(block, g_Config))
{
Handle allowedteam = FindConVar("mp_humanteam");
if (KvJumpToKey(block, g_CurrentMap))
{
char allowed[6];
KvGetString(block, "team_allowed", allowed, sizeof(allowed));
if(StrEqual(allowed, "t"))
{
SetConVarString(allowedteam, "t", true, false);
}
else if(StrEqual(allowed, "ct"))
{
SetConVarString(allowedteam, "ct", true, false);
}
else if(StrEqual(allowed, "any"))
{
SetConVarString(allowedteam, "any", true, false);
}
}
else ///If the map isn't in the config - allow all
{
SetConVarString(allowedteam, "any", true, false);
}
}
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.)