Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Basic Chat Plugin
5 * Implements basic communication commands.
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
38 public Plugin:myinfo =
41 author = "AlliedModders LLC",
42 description = "Basic Communication Commands",
43 version = SOURCEMOD_VERSION,
44 url = "http://www.sourcemod.net/"
47 #define CHAT_SYMBOL '@'
49 new String:g_ColorNames[13][10] = {"White", "Red", "Green", "Blue", "Yellow", "Purple", "Cyan", "Orange", "Pink", "Olive", "Lime", "Violet", "Lightblue"};
50 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}};
52 new Handle:g_Cvar_Chatmode = INVALID_HANDLE;
54 new EngineVersion:g_GameEngine = Engine_Unknown;
56 public OnPluginStart()
58 LoadTranslations("common.phrases");
60 g_GameEngine = GetEngineVersion();
62 g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0);
64 RegAdminCmd("sm_say", Command_SmSay, ADMFLAG_CHAT, "sm_say <message> - sends message to all players");
65 RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay <message> - sends centered message to all players");
67 /* HintText does not work on Dark Messiah */
68 if (g_GameEngine != Engine_DarkMessiah)
70 RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay <message> - sends hint message to all players");
73 RegAdminCmd("sm_tsay", Command_SmTsay, ADMFLAG_CHAT, "sm_tsay [color] <message> - sends top-left message to all players");
74 RegAdminCmd("sm_chat", Command_SmChat, ADMFLAG_CHAT, "sm_chat <message> - sends message to admins");
75 RegAdminCmd("sm_psay", Command_SmPsay, ADMFLAG_CHAT, "sm_psay <name or #userid> <message> - sends private message");
76 RegAdminCmd("sm_msay", Command_SmMsay, ADMFLAG_CHAT, "sm_msay <message> - sends message as a menu panel");
79 public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
82 if (sArgs[startidx] != CHAT_SYMBOL)
83 return Plugin_Continue;
87 if (strcmp(command, "say", false) == 0)
89 if (sArgs[startidx] != CHAT_SYMBOL) // sm_say alias
91 if (!CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT))
93 return Plugin_Continue;
96 SendChatToAll(client, sArgs[startidx]);
97 LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, sArgs[startidx]);
104 if (sArgs[startidx] != CHAT_SYMBOL) // sm_psay alias
106 if (!CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT))
108 return Plugin_Continue;
113 new len = BreakString(sArgs[startidx], arg, sizeof(arg));
114 new target = FindTarget(client, arg, true, false);
116 if (target == -1 || len == -1)
119 SendPrivateChat(client, target, sArgs[startidx+len]);
127 if (!CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT))
129 return Plugin_Continue;
132 DisplayCenterTextToAll(client, sArgs[startidx]);
133 LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, sArgs[startidx]);
137 else if (strcmp(command, "say_team", false) == 0 || strcmp(command, "say_squad", false) == 0)
139 if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode))
141 return Plugin_Continue;
144 SendChatToAdmins(client, sArgs[startidx]);
145 LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, sArgs[startidx]);
150 return Plugin_Continue;
153 public Action:Command_SmSay(client, args)
157 ReplyToCommand(client, "[SM] Usage: sm_say <message>");
158 return Plugin_Handled;
161 decl String:text[192];
162 GetCmdArgString(text, sizeof(text));
164 SendChatToAll(client, text);
165 LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, text);
167 return Plugin_Handled;
170 public Action:Command_SmCsay(client, args)
174 ReplyToCommand(client, "[SM] Usage: sm_csay <message>");
175 return Plugin_Handled;
178 decl String:text[192];
179 GetCmdArgString(text, sizeof(text));
181 DisplayCenterTextToAll(client, text);
183 LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, text);
185 return Plugin_Handled;
188 public Action:Command_SmHsay(client, args)
192 ReplyToCommand(client, "[SM] Usage: sm_hsay <message>");
193 return Plugin_Handled;
196 decl String:text[192];
197 GetCmdArgString(text, sizeof(text));
199 decl String:nameBuf[MAX_NAME_LENGTH];
201 for (new i = 1; i <= MaxClients; i++)
203 if (!IsClientInGame(i) || IsFakeClient(i))
207 FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
208 PrintHintText(i, "%s: %s", nameBuf, text);
211 LogAction(client, -1, "\"%L\" triggered sm_hsay (text %s)", client, text);
213 return Plugin_Handled;
216 public Action:Command_SmTsay(client, args)
220 ReplyToCommand(client, "[SM] Usage: sm_tsay <message>");
221 return Plugin_Handled;
224 decl String:text[192], String:colorStr[16];
225 GetCmdArgString(text, sizeof(text));
227 new len = BreakString(text, colorStr, 16);
229 new color = FindColor(colorStr);
230 new String:nameBuf[MAX_NAME_LENGTH];
238 for (new i = 1; i <= MaxClients; i++)
240 if (!IsClientInGame(i) || IsFakeClient(i))
244 FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
245 SendDialogToOne(i, color, "%s: %s", nameBuf, text[len]);
248 LogAction(client, -1, "\"%L\" triggered sm_tsay (text %s)", client, text);
250 return Plugin_Handled;
253 public Action:Command_SmChat(client, args)
257 ReplyToCommand(client, "[SM] Usage: sm_chat <message>");
258 return Plugin_Handled;
261 decl String:text[192];
262 GetCmdArgString(text, sizeof(text));
264 SendChatToAdmins(client, text);
265 LogAction(client, -1, "\"%L\" triggered sm_chat (text %s)", client, text);
267 return Plugin_Handled;
270 public Action:Command_SmPsay(client, args)
274 ReplyToCommand(client, "[SM] Usage: sm_psay <name or #userid> <message>");
275 return Plugin_Handled;
278 decl String:text[192], String:arg[64], String:message[192];
279 GetCmdArgString(text, sizeof(text));
281 new len = BreakString(text, arg, sizeof(arg));
282 BreakString(text[len], message, sizeof(message));
284 new target = FindTarget(client, arg, true, false);
287 return Plugin_Handled;
289 SendPrivateChat(client, target, message);
291 return Plugin_Handled;
294 public Action:Command_SmMsay(client, args)
298 ReplyToCommand(client, "[SM] Usage: sm_msay <message>");
299 return Plugin_Handled;
302 decl String:text[192];
303 GetCmdArgString(text, sizeof(text));
305 SendPanelToAll(client, text);
307 LogAction(client, -1, "\"%L\" triggered sm_msay (text %s)", client, text);
309 return Plugin_Handled;
312 FindColor(String:color[])
314 for (new i = 0; i < 13; i++)
316 if (strcmp(color, g_ColorNames[i], false) == 0)
323 SendChatToAll(client, const String:message[])
325 new String:nameBuf[MAX_NAME_LENGTH];
327 for (new i = 1; i <= MaxClients; i++)
329 if (!IsClientInGame(i) || IsFakeClient(i))
333 FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
335 PrintToChat(i, "\x04(ALL) %s: \x01%s", nameBuf, message);
339 DisplayCenterTextToAll(client, const String:message[])
341 new String:nameBuf[MAX_NAME_LENGTH];
343 for (new i = 1; i <= MaxClients; i++)
345 if (!IsClientInGame(i) || IsFakeClient(i))
349 FormatActivitySource(client, i, nameBuf, sizeof(nameBuf));
350 PrintCenterText(i, "%s: %s", nameBuf, message);
354 SendChatToAdmins(from, const String:message[])
356 new fromAdmin = CheckCommandAccess(from, "sm_chat", ADMFLAG_CHAT);
357 for (new i = 1; i <= MaxClients; i++)
359 if (IsClientInGame(i) && (from == i || CheckCommandAccess(i, "sm_chat", ADMFLAG_CHAT)))
361 PrintToChat(i, "\x04(%sADMINS) %N: \x01%s", fromAdmin ? "" : "TO ", from, message);
366 SendDialogToOne(client, color, const String:text[], any:...)
368 new String:message[100];
369 VFormat(message, sizeof(message), text, 4);
371 new Handle:kv = CreateKeyValues("Stuff", "title", message);
372 KvSetColor(kv, "color", g_Colors[color][0], g_Colors[color][1], g_Colors[color][2], 255);
373 KvSetNum(kv, "level", 1);
374 KvSetNum(kv, "time", 10);
376 CreateDialog(client, kv, DialogType_Msg);
381 SendPrivateChat(client, target, const String:message[])
385 PrintToServer("(Private to %N) %N: %s", target, client, message);
387 else if (target != client)
389 PrintToChat(client, "\x04(Private to %N) %N: \x01%s", target, client, message);
392 PrintToChat(target, "\x04(Private to %N) %N: \x01%s", target, client, message);
393 LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message);
396 SendPanelToAll(from, String:message[])
398 decl String:title[100];
399 Format(title, 64, "%N:", from);
401 ReplaceString(message, 192, "\\n", "\n");
403 new Handle:mSayPanel = CreatePanel();
404 SetPanelTitle(mSayPanel, title);
405 DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER);
406 DrawPanelText(mSayPanel, message);
407 DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER);
409 SetPanelCurrentKey(mSayPanel, 10);
410 DrawPanelItem(mSayPanel, "Exit", ITEMDRAW_CONTROL);
412 for(new i = 1; i <= MaxClients; i++)
414 if(IsClientInGame(i) && !IsFakeClient(i))
416 SendPanelToClient(mSayPanel, i, Handler_DoNothing, 10);
420 CloseHandle(mSayPanel);
423 public Handler_DoNothing(Handle:menu, MenuAction:action, param1, param2)