#include <sourcemod>
#include <sdktools>
#pragma newdecls required
#define PREFIX "[Say Spec]"
ConVar g_Cvar_bEnable = null,
g_Cvar_bBlockSpectateMessage = null;
static const char g_sColorT[][] = {"#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10", "#OB", "#OC", "#OE", "#HC", "#HT", "#HE"},
g_sColorC[][] = {"\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x10", "\x0B", "\x0C", "\x0E", "<font color='", "'>", "</font>"};
// Regular plugin information
public Plugin myinfo =
{
name = "Say Back to Spector",
author = "GoDtm666",
description = "Say !spec | !sp (Back to Spector)",
version = "1.2",
url = "www.SourceTM.com"
}
public void OnPluginStart()
{
g_Cvar_bEnable = CreateConVar( "sm_SBtS_enable", "1", "1 = Вкл | 0 = Выкл. плагина перемещении игроков написавших в чате !sp в спектры..\n1 = On | 0 = Off. Move the players wrote in the chat! Bts in the spectors.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_Cvar_bBlockSpectateMessage = CreateConVar("sm_SBtS_BlockSpecMessage", "1", "1 = Вкл | 0 = Выкл. Отключает стандартные сообщения о переходе в спектры. \n1 = On | 0 = Off. Block standart Spectate Message",FCVAR_NOTIFY,true,0.0,true,1.0);
HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre);
LoadTranslations("sm_saybacktospector.phrases.txt");
AutoExecConfig(true, "sm_saybacktospec", "sourcemod");
}
public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
{
new flags = GetUserFlagBits(iClient);
if(!g_Cvar_bEnable.BoolValue)
return Plugin_Continue;
if(iClient > 0 && !IsFakeClient(iClient) && flags & ADMFLAG_CUSTOM1)
{
if(StrEqual(sArgs, "!spec", false) || StrEqual(sArgs, "!sp", false) || StrEqual(sArgs, "!ыз") || StrEqual(sArgs, "!ызус") || StrEqual(sArgs, "!спек"))
{
if(GetClientTeam(iClient) > 1)
{
ChangeClientTeam(iClient, 1);
if (GetUserMessageType() == UM_Protobuf)
PrintToChatAllEx(iClient, " \x01%s \x03%N \x01%T", PREFIX, iClient, "Client Back to Spector", iClient);
else
PrintToChatAllEx(iClient, "\x01%s \x03%N \x01%T", PREFIX, iClient, "Client Back to Spector", iClient);
}
else
PrintToChat2(iClient, "%T", "Client Spectors Spec", iClient);
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public Action Event_PlayerTeam(Event eEvent, const char[] sName, bool bDontBroadcast)
{
if (g_Cvar_bBlockSpectateMessage.BoolValue && g_Cvar_bEnable.BoolValue)
{
if(eEvent.GetInt("team") == 1)
eEvent.BroadcastDisabled = true;
}
return Plugin_Continue;
}
void PrintToChat2(int iClient, const char[] sMesag, any ...)
{
char sBufer[192];
VFormat(sBufer, sizeof(sBufer), sMesag, 3);
for(int i = 0; i < 16; i++)
ReplaceString(sBufer, sizeof(sBufer), g_sColorT[i], g_sColorC[i]);
if (GetUserMessageType() == UM_Protobuf)
PrintToChat(iClient, " \x01%s %s", PREFIX, sBufer);
else
PrintToChat(iClient, "\x01%s %s", PREFIX, sBufer);
}
void PrintToChatAllEx(int iClient, const char[] sMesag, any ...)
{
char sBuffer[192];
VFormat(sBuffer, sizeof(sBuffer), sMesag, 3);
for(int i = 0; i < 16; i++)
ReplaceString(sBuffer, sizeof(sBuffer), g_sColorT[i], g_sColorC[i]);
Handle hBf = StartMessageAll("SayText2");
if (GetUserMessageType() == UM_Protobuf)
{
Protobuf prPb = UserMessageToProtobuf(hBf);
if (prPb != null)
{
prPb.SetInt("ent_idx", iClient);
prPb.SetBool("chat", true);
prPb.SetString("msg_name", sBuffer);
prPb.AddString("params", "");
prPb.AddString("params", "");
prPb.AddString("params", "");
prPb.AddString("params", "");
EndMessage();
}
}
else
{
BfWrite bfWri = UserMessageToBfWrite(hBf);
if (bfWri != null)
{
bfWri.WriteByte(iClient);
bfWri.WriteByte(0);
bfWri.WriteString(sBuffer);
EndMessage();
}
}
}