#include <sourcemod>
#include <cstrike>
//#define FLAG_ADMINA ADMFLAG_UNBAN
new bool:b_en,
bool:b_team,
bool:switchEnd[MAXPLAYERS + 1] = false;
public OnPluginStart()
{
new Handle:cvar;
HookConVarChange((cvar = CreateConVar("sm_drenable", "0", "Включить/выключить плагин", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_enabled);
b_en = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_drugans", "0", "0 - T, 1 - CT", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_team);
b_team = GetConVarBool(cvar);
CloseHandle(cvar);
AddCommandListener(JoinTeams, "jointeam");
//AddCommandListener(JoinTeams, "joinclass");
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
RegAdminCmd("sm_sortings", EnAdminS, ADMFLAG_ROOT);
AutoExecConfig(true, "sm_joinfriends");
}
public Plugin:myinfo =
{
name = "[NM] JoinFriends",
author = "DarklSide",
description = "Join friends in my team",
version = "1.0.2",
url = "www.surf-4fun.com"
};
public Action:EnAdminS(client, args)
{
if (IsClientInGame(client))
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
if (b_Iadmins(i))
{
switchEnd[i] = true;
}
}
}
PrintToChat(client, "Сортировка команд, в след. раунде");
}
return Plugin_Handled;
}
public OnClientDisconnect(client)
{
if (b_en)
{
switchEnd[client] = false;
}
}
bool:b_Iadmins(client)
{
return GetUserAdmin(client) == INVALID_ADMIN_ID ? false : true;
}
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
if (b_en)
{
for (new i = 1; i <= MaxClients; i++)
{
if (switchEnd[i])
{
Switch(i);
switchEnd[i] = false;
}
}
}
}
Switch(client)
{
if (IsClientInGame(client))
{
if (GetClientTeam(client) > 1)
{
if (b_team)
{
CS_SwitchTeam(client, 2);
}
else
{
CS_SwitchTeam(client, 3);
}
}
}
}
public Cvar_b_enabled(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
b_en = GetConVarBool(cvar);
if (b_en)
{
ServerCommand("mp_limitteams 0");
ServerCommand("mp_autoteambalance 0");
}
else
{
ServerCommand("mp_limitteams 1"); // Своё значение
ServerCommand("mp_autoteambalance 1"); // Своё значение
for (new i = 1; i <= MaxClients; i++)
{
switchEnd[i] = false;
}
}
}
public Cvar_b_team(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
b_team = GetConVarBool(cvar);
}
public Action:JoinTeams(client, const String:command[], args)
{
if (client && IsClientInGame(client))
{
switch (b_en)
{
case 0:
return Plugin_Continue;
case 1:
{
decl String:s_Team[4];
GetCmdArg(1, s_Team, sizeof(s_Team));
new i_team = StringToInt(s_Team);
if (i_team == 0)
{
PrintToChat(client, "\x01Автовыбор временно \x03отключен");
return Plugin_Handled;
}
switch (b_team)
{
case 0:
{
if (i_team == CS_TEAM_T) // && (GetUserFlagBits(client) < FLAG_ADMINA))
{
//ClientCommand(client, "jointeam 3");
PrintToChat(client, "\x01Зайти за \x03T \x01можно только Админам - \x03(временно)");
return Plugin_Handled;
}
return Plugin_Continue;
}
case 1:
{
if (i_team == CS_TEAM_CT) // && (GetUserFlagBits(client) < FLAG_ADMINA))
{
//ClientCommand(client, "jointeam 2");
PrintToChat(client, "\x01Зайти за \x03СT \x01можно только Админам - \x03(временно)");
return Plugin_Handled;
}
return Plugin_Continue;
}
}
}
}
}
return Plugin_Continue;
}