Belkashif Posted July 12, 2011 Share Posted July 12, 2011 Hello, Mostly when admins type to other players in admin chat it is usually in the same colour as the console messges. For Example It's really hard for other players to read All Admin chat. SO is it possible if we can have the color for All Admin Chat be red or blue or maybe black? It will be easier for other players to read it. #pragma semicolon 1 #include <sourcemod> public Plugin:myinfo = { name = "Basic Chat", author = "AlliedModders LLC", description = "Basic Communication Commands", version = SOURCEMOD_VERSION, url = "http://www.sourcemod.net/" }; #define CHAT_SYMBOL '@' new String:g_ColorNames[13][10] = {"White", "Red", "Green", "Blue", "Yellow", "Purple", "Cyan", "Orange", "Pink", "Olive", "Lime", "Violet", "Lightblue"}; new g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{255,128,0},{255,0,128},{128,255,0},{0,255,128},{128,0,255},{0,128,255}}; new Handle:g_Cvar_Chatmode = INVALID_HANDLE; new bool:g_DoColor = true; new g_GameEngine = SOURCE_SDK_UNKNOWN; public OnPluginStart() { LoadTranslations("common.phrases"); g_GameEngine = GuessSDKVersion(); g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0); RegConsoleCmd("say", Command_SayChat); RegConsoleCmd("say_team", Command_SayAdmin); RegAdminCmd("sm_say", Command_SmSay, ADMFLAG_CHAT, "sm_say <message> - sends message to all players"); RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay <message> - sends centered message to all players"); /* HintText does not work on Dark Messiah */ if (g_GameEngine != SOURCE_SDK_DARKMESSIAH) { RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay <message> - sends hint message to all players"); } RegAdminCmd("sm_tsay", Command_SmTsay, ADMFLAG_CHAT, "sm_tsay [color] <message> - sends top-left message to all players"); RegAdminCmd("sm_chat", Command_SmChat, ADMFLAG_CHAT, "sm_chat <message> - sends message to admins"); RegAdminCmd("sm_psay", Command_SmPsay, ADMFLAG_CHAT, "sm_psay <name or #userid> <message> - sends private message"); RegAdminCmd("sm_msay", Command_SmMsay, ADMFLAG_CHAT, "sm_msay <message> - sends message as a menu panel"); decl String:modname[64]; GetGameFolderName(modname, sizeof(modname)); if (strcmp(modname, "hl2mp") == 0) { g_DoColor = false; } } public Action:Command_SayChat(client, args) { decl String:text[192]; if (IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1) { return Plugin_Continue; } new startidx; if (text[strlen(text)-1] == '"') { text[strlen(text)-1] = '\0'; startidx = 1; } if (text[startidx] != CHAT_SYMBOL) return Plugin_Continue; new msgStart = 1; if (text[startidx+1] == CHAT_SYMBOL) { msgStart = 2; if (text[startidx+2] == CHAT_SYMBOL) msgStart = 3; } decl String:message[192]; strcopy(message, 192, text[startidx+msgStart]); decl String:name[64]; GetClientName(client, name, sizeof(name)); if (msgStart == 1 && CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT)) // sm_say alias { SendChatToAll(client, message); LogAction(client, -1, "%L triggered sm_say (text %s)", client, message); } else if (msgStart == 3 && CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT)) // sm_csay alias { DisplayCenterTextToAll(client, message); LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text); } else if (msgStart == 2 && CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT)) // sm_psay alias { decl String:arg[64]; new len = BreakString(message, arg, sizeof(arg)); new target = FindTarget(client, arg, true, false); if (target == -1 || len == -1) return Plugin_Handled; decl String:name2[64]; GetClientName(target, name2, sizeof(name2)); if (g_DoColor) { PrintToChat(client, "\x04(Private to %s) %s: \x01%s", name2, name, message[len]); PrintToChat(target, "\x04(Private to %s) %s: \x01%s", name2, name, message[len]); } else { PrintToChat(client, "(Private to %s) %s: %s", name2, name, message[len]); PrintToChat(target, "(Private to %s) %s: %s", name2, name, message[len]); } LogAction(client, -1, "%L triggered sm_psay to %L (text %s)", client, target, message); } else return Plugin_Continue; return Plugin_Handled; } public Action:Command_SayAdmin(client, args) { if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode)) { return Plugin_Continue; } decl String:text[192]; if (IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1) { return Plugin_Continue; } new startidx; if (text[strlen(text)-1] == '"') { text[strlen(text)-1] = '\0'; startidx = 1; } if (text[startidx] != CHAT_SYMBOL) return Plugin_Continue; decl String:message[192]; strcopy(message, 192, text[startidx+1]); decl String:name[64]; GetClientName(client, name, sizeof(name)); SendChatToAdmins(name, message); LogAction(client, -1, "%L triggered sm_chat (text %s)", client, message); return Plugin_Handled; } public Action:Command_SmSay(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_say <message>"); return Plugin_Handled; } decl String:text[192]; GetCmdArgString(text, sizeof(text)); SendChatToAll(client, text); LogAction(client, -1, "%L triggered sm_say (text %s)", client, text); return Plugin_Handled; } public Action:Command_SmCsay(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_csay <message>"); return Plugin_Handled; } decl String:text[192]; GetCmdArgString(text, sizeof(text)); DisplayCenterTextToAll(client, text); LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text); return Plugin_Handled; } public Action:Command_SmHsay(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_hsay <message>"); return Plugin_Handled; } decl String:text[192]; GetCmdArgString(text, sizeof(text)); decl String:nameBuf[MAX_NAME_LENGTH]; for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) { continue; } FormatActivitySource(client, i, nameBuf, sizeof(nameBuf)); PrintHintText(i, "%s: %s", nameBuf, text); } LogAction(client, -1, "%L triggered sm_hsay (text %s)", client, text); return Plugin_Handled; } public Action:Command_SmTsay(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_tsay <message>"); return Plugin_Handled; } decl String:text[192], String:colorStr[16]; GetCmdArgString(text, sizeof(text)); new len = BreakString(text, colorStr, 16); decl String:name[64]; GetClientName(client, name, sizeof(name)); new color = FindColor(colorStr); new String:nameBuf[MAX_NAME_LENGTH]; if (color == -1) { color = 0; len = 0; } for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) { continue; } FormatActivitySource(client, i, nameBuf, sizeof(nameBuf)); SendDialogToOne(i, color, "%s: %s", nameBuf, text[len]); } LogAction(client, -1, "%L triggered sm_tsay (text %s)", client, text); return Plugin_Handled; } public Action:Command_SmChat(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_chat <message>"); return Plugin_Handled; } decl String:text[192]; GetCmdArgString(text, sizeof(text)); decl String:name[64]; GetClientName(client, name, sizeof(name)); SendChatToAdmins(name, text); LogAction(client, -1, "%L triggered sm_chat (text %s)", client, text); return Plugin_Handled; } public Action:Command_SmPsay(client, args) { if (args < 2) { ReplyToCommand(client, "[sM] Usage: sm_psay <name or #userid> <message>"); return Plugin_Handled; } decl String:text[192], String:arg[64], String:message[192]; GetCmdArgString(text, sizeof(text)); new len = BreakString(text, arg, sizeof(arg)); BreakString(text[len], message, sizeof(message)); new target = FindTarget(client, arg, true, false); if (target == -1) return Plugin_Handled; decl String:name[64], String:name2[64]; if (client == 0) { name = "Console"; } else { GetClientName(client, name, sizeof(name)); } GetClientName(target, name2, sizeof(name2)); if (client == 0) { PrintToServer("(Private: %s) %s: %s", name2, name, message); } else if (g_DoColor) { PrintToChat(client, "\x04(Private: %s) %s: \x01%s", name2, name, message); } else { PrintToChat(client, "(Private: %s) %s: %s", name2, name, message); } if (g_DoColor) { PrintToChat(target, "\x04(Private: %s) %s: \x01%s", name2, name, message); } else { PrintToChat(target, "(Private: %s) %s: %s", name2, name, message); } LogAction(client, -1, "%L triggered sm_psay to %L (text %s)", client, target, message); return Plugin_Handled; } public Action:Command_SmMsay(client, args) { if (args < 1) { ReplyToCommand(client, "[sM] Usage: sm_msay <message>"); return Plugin_Handled; } decl String:text[192]; GetCmdArgString(text, sizeof(text)); decl String:name[64]; GetClientName(client, name, sizeof(name)); SendPanelToAll(name, text); LogAction(client, -1, "%L triggered sm_msay (text %s)", client, text); return Plugin_Handled; } FindColor(String:color[]) { for (new i = 0; i < 13; i++) { if (strcmp(color, g_ColorNames[i], false) == 0) return i; } return -1; } SendChatToAll(client, String:message[]) { new String:nameBuf[MAX_NAME_LENGTH]; for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) { continue; } FormatActivitySource(client, i, nameBuf, sizeof(nameBuf)); if (g_DoColor) { PrintToChat(i, "\x01\x03%s: \x01\x03%s", nameBuf, message); } else { PrintToChat(i, "%s: %s", nameBuf, message); } } } DisplayCenterTextToAll(client, String:message[]) { new String:nameBuf[MAX_NAME_LENGTH]; for (new i = 1; i < MaxClients; i++) { if (!IsClientInGame(i) || IsFakeClient(i)) { continue; } FormatActivitySource(client, i, nameBuf, sizeof(nameBuf)); PrintCenterText(i, "%s: %s", nameBuf, message); } } SendChatToAdmins(String:name[], String:message[]) { for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { if (CheckCommandAccess(i, "sm_chat", ADMFLAG_CHAT)) { if (g_DoColor) { PrintToChat(i, "\x04(ADMINS ONLY) \x04%s: \x04%s", name, message); } else { PrintToChat(i, "\x04(TO ADMINS) \x04%s: \x04%s", name, message); } } } } } SendDialogToOne(client, color, String:text[], any:...) { new String:message[100]; VFormat(message, sizeof(message), text, 4); new Handle:kv = CreateKeyValues("Stuff", "title", message); KvSetColor(kv, "color", g_Colors[color][0], g_Colors[color][1], g_Colors[color][2], 255); KvSetNum(kv, "level", 1); KvSetNum(kv, "time", 10); CreateDialog(client, kv, DialogType_Msg); CloseHandle(kv); } SendPanelToAll(String:name[], String:message[]) { decl String:title[100]; Format(title, 64, "%s:", name); ReplaceString(message, 192, "\\n", "\n"); new Handle:mSayPanel = CreatePanel(); SetPanelTitle(mSayPanel, title); DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER); DrawPanelText(mSayPanel, message); DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER); SetPanelCurrentKey(mSayPanel, 10); DrawPanelItem(mSayPanel, "Exit", ITEMDRAW_CONTROL); for(new i = 1; i <= MaxClients; i++) { if(IsClientInGame(i) && !IsFakeClient(i)) { SendPanelToClient(mSayPanel, i, Handler_DoNothing, 10); } } CloseHandle(mSayPanel); } public Handler_DoNothing(Handle:menu, MenuAction:action, param1, param2) { /* Do nothing */ Here is the code that can change Admin Chat Colour. If Staff would like more info about the code feel free to PM me since posting links are not allowed. Quote Link to comment Share on other sites More sharing options...
Cal45 Posted July 12, 2011 Share Posted July 12, 2011 I think this is a good suggestion. With all the chat and server messages, it's really hard for an ALL chat to stand out. Quote Link to comment Share on other sites More sharing options...
l4d2bob Posted July 12, 2011 Share Posted July 12, 2011 +1 for colored admin chat Quote Link to comment Share on other sites More sharing options...
DR.OBVIOUS Posted July 12, 2011 Share Posted July 12, 2011 Great idea! Quote Link to comment Share on other sites More sharing options...
Plaayer Posted July 12, 2011 Share Posted July 12, 2011 Just do hot pink, it's going to get everyone's attention. Quote Link to comment Share on other sites More sharing options...
blackberry4511 Posted July 12, 2011 Share Posted July 12, 2011 +1, good idea Quote Link to comment Share on other sites More sharing options...
S.T.A.L.K.E.R Posted July 12, 2011 Share Posted July 12, 2011 +1 great idea Quote Link to comment Share on other sites More sharing options...
JJK Posted July 12, 2011 Share Posted July 12, 2011 AFAIK css colors are limited to the following Ill go ahead and use your code on the test server to see if its a legit plugin. Quote Link to comment Share on other sites More sharing options...
JJK Posted July 13, 2011 Share Posted July 13, 2011 (edited) EDIT : not working so far give me the link Edited July 13, 2011 by JJK Quote Link to comment Share on other sites More sharing options...
blackberry4511 Posted July 13, 2011 Share Posted July 13, 2011 I think the light green would be the best, you don't really see anything that has light green text. Quote Link to comment Share on other sites More sharing options...
lolitsjack Posted July 13, 2011 Share Posted July 13, 2011 +1, I vote for one of the green shades, blue and red could be confusing with the Ts and CTs Quote Link to comment Share on other sites More sharing options...
Guest Vao Posted July 13, 2011 Share Posted July 13, 2011 Yes this is a great idea, ive seen players miss admin warnings and this should help. Quote Link to comment Share on other sites More sharing options...
Scott Posted July 13, 2011 Share Posted July 13, 2011 if it works this should help good idea Quote Link to comment Share on other sites More sharing options...
Belkashif Posted July 13, 2011 Author Share Posted July 13, 2011 EDIT : not working so far give me the link I have Pm'd you the link Quote Link to comment Share on other sites More sharing options...
Dullknife Posted July 17, 2011 Share Posted July 17, 2011 +1 I like this idea Hope it works then I be like all *EPIC FACE* YEA!!! Quote Link to comment Share on other sites More sharing options...
Amokov Posted July 19, 2011 Share Posted July 19, 2011 You can use the characters SM already uses to print colored text. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.