diff --git a/addons/sourcemod/scripting/include/shavit/chat-colors.inc b/addons/sourcemod/scripting/include/shavit/chat-colors.inc index b3417e72..8ed792a4 100644 --- a/addons/sourcemod/scripting/include/shavit/chat-colors.inc +++ b/addons/sourcemod/scripting/include/shavit/chat-colors.inc @@ -6,12 +6,14 @@ char gS_GlobalColorNames[][] = { "{default}", + "{def}", "{team}", "{green}" }; char gS_GlobalColors[][] = { + "\x01", "\x01", "\x03", "\x04" @@ -50,3 +52,33 @@ char gS_CSGOColors[][] = "\x09", "\x07" }; + + +stock void FormatColors(char[] buffer, int size, bool colors, bool escape, bool csgo, bool funky_chars=true) +{ + if(colors) + { + for(int i = 0; i < sizeof(gS_GlobalColorNames); i++) + { + ReplaceString(buffer, size, gS_GlobalColorNames[i], gS_GlobalColors[i]); + } + + if(csgo) + { + for(int i = 0; i < sizeof(gS_CSGOColorNames); i++) + { + ReplaceString(buffer, size, gS_CSGOColorNames[i], gS_CSGOColors[i]); + } + } + + if (funky_chars) ReplaceString(buffer, size, "^", "\x07"); + ReplaceString(buffer, size, "{RGB}", "\x07"); + if (funky_chars) ReplaceString(buffer, size, "&", "\x08"); + ReplaceString(buffer, size, "{RGBA}", "\x08"); + } + + if(escape) + { + ReplaceString(buffer, size, "%%", ""); + } +} diff --git a/addons/sourcemod/scripting/shavit-chat.sp b/addons/sourcemod/scripting/shavit-chat.sp index 7975871f..c88bd751 100644 --- a/addons/sourcemod/scripting/shavit-chat.sp +++ b/addons/sourcemod/scripting/shavit-chat.sp @@ -398,7 +398,7 @@ public Action OnClientSayCommand(int client, const char[] command, const char[] void ReplaceFormats(char[] formatting, int maxlen, char[] name, char[] colon, char[] text) { - FormatColors(formatting, maxlen, true, false); + FormatColors(formatting, maxlen, true, false, gEV_Type == Engine_CSGO); FormatRandom(formatting, maxlen); ReplaceString(formatting, maxlen, "{name}", name); ReplaceString(formatting, maxlen, "{def}", "\x01"); @@ -1281,35 +1281,6 @@ public Action Command_CCDelete(int client, int args) return Plugin_Handled; } -void FormatColors(char[] buffer, int size, bool colors, bool escape) -{ - if(colors) - { - for(int i = 0; i < sizeof(gS_GlobalColorNames); i++) - { - ReplaceString(buffer, size, gS_GlobalColorNames[i], gS_GlobalColors[i]); - } - - if(gEV_Type == Engine_CSGO) - { - for(int i = 0; i < sizeof(gS_CSGOColorNames); i++) - { - ReplaceString(buffer, size, gS_CSGOColorNames[i], gS_CSGOColors[i]); - } - } - - ReplaceString(buffer, size, "^", "\x07"); - ReplaceString(buffer, size, "{RGB}", "\x07"); - ReplaceString(buffer, size, "&", "\x08"); - ReplaceString(buffer, size, "{RGBA}", "\x08"); - } - - if(escape) - { - ReplaceString(buffer, size, "%%", ""); - } -} - void FormatRandom(char[] buffer, int size) { char temp[8]; @@ -1331,7 +1302,7 @@ void FormatRandom(char[] buffer, int size) void FormatChat(int client, char[] buffer, int size) { - FormatColors(buffer, size, true, true); + FormatColors(buffer, size, true, true, gEV_Type == Engine_CSGO); FormatRandom(buffer, size); char temp[33]; diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 0f834044..cb9c4375 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -34,6 +34,7 @@ #include #include +#include #undef REQUIRE_PLUGIN #include @@ -663,9 +664,10 @@ bool LoadAdvertisementsConfig() ReplaceString(sTempMessage, 300, "{variable2}", gS_ChatStrings.sVariable2); ReplaceString(sTempMessage, 300, "{style}", gS_ChatStrings.sStyle); + FormatColors(sTempMessage, 300, true, false, gEV_Type == Engine_CSGO, false); + gA_Advertisements.PushString(sTempMessage); } - while(kv.GotoNextKey(false)); delete kv;