Ну вот только что проверил. Создаю зараженного, вызываю команду:
#pragma semicolon 1
//#pragma newdecls required
#include <sourcemod>
#include <colors>
public void OnPluginStart()
{
RegConsoleCmd("sm_tt", Command_Colors);
}
public Action Command_Colors(int client, int args)
{
CPrintToChatAll("{red}%s", "Test");
return Plugin_Handled;
}
Сообщение просто печатается серым цветом.
А при таком коде:
#pragma semicolon 1
//#pragma newdecls required
#include <sourcemod>
#include <colors>
#define TEAM_INFECTED 3
public void OnPluginStart()
{
RegConsoleCmd("sm_ttt", Command_Colors);
}
public Action Command_Colors(int client, int args)
{
int inf = FindRandomPlayerByTeam(TEAM_INFECTED);
if( inf )
{
CPrintToChatEx(client, inf, "{red}%s", "Test");
}
return Plugin_Handled;
}
int FindRandomPlayerByTeam(int color_team)
{
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && GetClientTeam(client) == color_team)
return client;
}
return 0;
}
возбуждается ошибка:
L 01/12/2021 - 21:44:02: [SM] Exception reported: Using two team colors in one message is not allowed
L 01/12/2021 - 21:44:02: [SM] Blaming: test3.smx
L 01/12/2021 - 21:44:02: [SM] Call stack trace:
L 01/12/2021 - 21:44:02: [SM] [0] ThrowError
L 01/12/2021 - 21:44:02: [SM] [1] Line 300, d:\dev\SourceMod\addons\sourcemod\scripting\include\colors.inc::CFormat
L 01/12/2021 - 21:44:02: [SM] [2] Line 131, d:\dev\SourceMod\addons\sourcemod\scripting\include\colors.inc::CPrintToChatEx
L 01/12/2021 - 21:44:02: [SM] [3] Line 20, H:\_To_games\Left4Dead_2\My_mods\Color\test3.sp::Command_Colors