#pragma semicolon 1 #define PLUGIN_VERSION "1.3" #include #include new Handle:g_hConsoleName = INVALID_HANDLE; new String:g_sConsoleName[64]; new Handle:g_hConsoleChatColor = INVALID_HANDLE; new String:g_sConsoleChatColor[32]; char C_Tag[][] = {"{default}", "{red}", "{lightpurple}", "{green}", "{lime}", "{lightgreen}", "{lightred}", "{gray}", "{lightolive}", "{olive}", "{purple}", "{lightblue}", "{blue}"}; char C_Code[][]= {"\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x10", "\x0E", "\x0B", "\x0C"}; #define MAX_COLORS 13 public Plugin:myinfo = { name = "Console Colors", author = "That One Guy + xen", description = "Colors chat output from CONSOLE", version = PLUGIN_VERSION, url = "https://forums.alliedmods.net" } public OnPluginStart() { g_hConsoleName = CreateConVar("togcc_consolename", "CONSOLE", "Name to use for console.", FCVAR_NONE); GetConVarString(g_hConsoleName, g_sConsoleName, sizeof(g_sConsoleName)); HookConVarChange(g_hConsoleName, OnCVarChange); g_hConsoleChatColor = CreateConVar("togcc_chatcolor", "\x04", "Hexadecimal value to use for console chat color (do not include #)", FCVAR_NONE); GetConVarString(g_hConsoleChatColor, g_sConsoleChatColor, sizeof(g_sConsoleChatColor)); HookConVarChange(g_hConsoleChatColor, OnCVarChange); AddCommandListener(Command_Say, "say"); AddCommandListener(Command_Say, "say_team"); AutoExecConfig(true, "TOGConsoleColors"); } public Action:Command_Say(client, String:Command[], ArgC) { if(client) { return Plugin_Continue; } decl String:sMessage[512]; GetCmdArgString(sMessage, 512); StripQuotes(sMessage); TrimString(sMessage); ConPrintToChatAll("\x02\x0E%s %s%s", g_sConsoleName, g_sConsoleChatColor, sMessage); PrintToServer("%s: %s", g_sConsoleName, sMessage); return Plugin_Handled; } public OnCVarChange(Handle:cvar, const String:oldvalue[], const String:newvalue[]) { if(cvar == g_hConsoleName) { GetConVarString(g_hConsoleName, g_sConsoleName, sizeof(g_sConsoleName)); } if(cvar == g_hConsoleChatColor) { GetConVarString(g_hConsoleChatColor, g_sConsoleChatColor, sizeof(g_sConsoleChatColor)); } } stock ConPrintToChatAll(const String:message[], any:...) { decl String:text0[512], String:text[512]; FormatEx(text0, sizeof(text0), " %s", message); VFormat(text, sizeof(text), text0, 2); for (int i = 0; i < MAX_COLORS; i++) ReplaceString(text, sizeof(text), C_Tag[i], C_Code[i]); PrintToChatAll(text); }