· 8 years ago · Dec 03, 2017, 10:44 PM
1
2#pragma semicolon 1
3#pragma newdecls required
4//////////
5//Defines
6#define PLUGIN_AUTHOR "FliX"
7#define PLUGIN_VERSION "1.20"
8#define PLUGIN_TAG "{dodgerblue}[{valve}CCC{dodgerblue}]\x01 "
9
10//////////
11//Includes
12#include <sourcemod>
13#include <sdktools>
14#include <clientprefs>
15#include <chat-processor>
16#include <colorvariables>
17#include <regex>
18
19#pragma newdecls required
20
21//////////
22//Plugin Info
23public Plugin myinfo =
24{
25 name = "ChatColours",
26 author = PLUGIN_AUTHOR,
27 description = "Adds chat colours and Tag support for TF2",
28 version = PLUGIN_VERSION,
29 url = "pbfortress.com"
30};
31
32//////////
33//Globals
34//DATABASE
35Database db;
36
37//COOKIES
38Handle g_hClientCookieTT = INVALID_HANDLE;
39Handle g_hClientCookieTC = INVALID_HANDLE;
40Handle g_hClientCookieNC = INVALID_HANDLE;
41Handle g_hClientCookieCC = INVALID_HANDLE;
42
43Handle g_chatColoursMain = INVALID_HANDLE;
44Handle g_tagTextMenu = INVALID_HANDLE;
45Handle g_tagColourMenu = INVALID_HANDLE;
46Handle g_nameColourMenu = INVALID_HANDLE;
47Handle g_chatColourMenu = INVALID_HANDLE;
48
49//STRINGS
50char g_clientTT[MAXPLAYERS][64];
51char g_clientTC[MAXPLAYERS][64];
52char g_clientNC[MAXPLAYERS][64];
53char g_clientCC[MAXPLAYERS][64];
54char g_DisplayName[100][256];
55char g_SourceName[100][256];
56char g_tagName[100][256];
57
58//INTS
59int g_ColourCount;
60int g_ColourIndex[100];
61int g_tagCount;
62int g_tagIndex[100];
63
64//BOOLS
65bool g_readyToLoad[MAXPLAYERS + 1];
66
67enum itemTypes {
68 CCC_UNKNOWN = 1,
69 CCC_TAG,
70 CCC_COLOUR
71};
72
73public void OnPluginStart()
74{
75 //COOKIE CREATION
76 g_hClientCookieTT = RegClientCookie("clientTagText", "Text of users tag.", CookieAccess_Private);
77 g_hClientCookieTC = RegClientCookie("clientTagColour", "Colour of users tag.", CookieAccess_Private);
78 g_hClientCookieNC = RegClientCookie("clientNameColour", "Colour of users name.", CookieAccess_Private);
79 g_hClientCookieCC = RegClientCookie("clientChatColour", "Colour of users chat.", CookieAccess_Private);
80 for (int i = MaxClients; i > 0; --i)
81 {
82 if (!AreClientCookiesCached(i))
83 {
84 continue;
85 }
86 OnClientCookiesCached(i);
87 }
88
89 //ROOT COMMANDS
90 RegAdminCmd("sm_reloadccc", CC_Reload, ADMFLAG_ROOT, "[CCC] Reloads colours from database.");
91 //RegAdminCmd("sm_addccc", CC_AddItem, ADMFLAG_ROOT, "[CCC]");
92
93 //ADMIN COMMANDS
94 RegAdminCmd("sm_settag", CC_SetTag, ADMFLAG_CHEATS, "[CCC] sm_settag <client> <tag>");
95 RegAdminCmd("sm_settagcolour", CC_SetTagColour, ADMFLAG_CHEATS, "[CCC] sm_settag <client> <colour> Supported colours can be found here https://www.doctormckay.com/morecolors.php");
96 RegAdminCmd("sm_setnamecolour", CC_SetNameColour, ADMFLAG_CHEATS, "[CCC] sm_settag <client> <colour> Supported colours can be found here https://www.doctormckay.com/morecolors.php");
97 RegAdminCmd("sm_setchatcolour", CC_SetChatColour, ADMFLAG_CHEATS, "[CCC] sm_settag <client> <colour> Supported colours can be found here https://www.doctormckay.com/morecolors.php");
98
99 //USER COMMANDS
100 RegAdminCmd("sm_ccc", CC_Menu, ADMFLAG_RESERVATION, "[CCC] Command to bring up CCC menu");
101
102 MenuCreation();
103}
104
105public void LoadPlayerInfo(int client)
106{
107 char cookieBuffer[32];
108 GetClientCookie(client, g_hClientCookieTT, cookieBuffer, sizeof(cookieBuffer));
109 g_clientTT[client] = cookieBuffer;
110 GetClientCookie(client, g_hClientCookieTC, cookieBuffer, sizeof(cookieBuffer));
111 g_clientTC[client] = cookieBuffer;
112 GetClientCookie(client, g_hClientCookieNC, cookieBuffer, sizeof(cookieBuffer));
113 g_clientNC[client] = cookieBuffer;
114 GetClientCookie(client, g_hClientCookieCC, cookieBuffer, sizeof(cookieBuffer));
115 g_clientCC[client] = cookieBuffer;
116 if(GetUserFlagBits(client) & (ADMFLAG_GENERIC) == (ADMFLAG_GENERIC)) {
117 if(StrEqual(g_clientTT[client], "")) {
118 ResetTag(client);
119 }
120 }
121 else if (!GetUserFlagBits(client) && StrEqual(g_clientTT[client], ""))
122 {
123 ResetTag(client);
124 }
125}
126
127
128//To Ensure players cannot end up with staff tags
129public void OnClientDisconnect(int client)
130{
131 SetClientCookie(client, g_hClientCookieTC, g_clientTC[client]);
132 SetClientCookie(client, g_hClientCookieTT, g_clientTT[client]);
133 SetClientCookie(client, g_hClientCookieNC, g_clientNC[client]);
134 SetClientCookie(client, g_hClientCookieCC, g_clientCC[client]);
135
136 g_clientTT[client] = "";
137 g_clientTC[client] = "";
138 g_clientNC[client] = "";
139 g_clientCC[client] = "";
140}
141
142public Action CP_OnChatMessage(int& author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool& processcolors, bool& removecolors)
143{
144 char clientNameBuffer[MAXLENGTH_NAME];
145 GetClientName(author, clientNameBuffer, sizeof(clientNameBuffer));
146
147 if(!StrEqual(g_clientNC[author], ""))
148 {
149 Format(name, MAXLENGTH_NAME, "%s%s\x01",g_clientNC[author], clientNameBuffer);
150 }
151 else
152 {
153 Format(name, MAXLENGTH_NAME, "\x03%s\x01", clientNameBuffer);
154 }
155 //Format name to include colours
156 Format(name, MAXLENGTH_NAME, "%s%s %s", g_clientTC[author], g_clientTT[author], name);
157 //Format message to include colours
158 Format(message, MAXLENGTH_MESSAGE, "%s%s", g_clientCC[author], message);
159 return Plugin_Changed;
160}
161
162//Loading Player info
163
164public void OnClientCookiesCached(int client) {
165 if (g_readyToLoad[client]) {
166 LoadPlayerInfo(client);
167 }
168
169 g_readyToLoad[client] = true;
170}
171
172public void OnClientPostAdminCheck(int client) {
173 if (g_readyToLoad[client]) {
174 LoadPlayerInfo(client);
175 }
176
177 g_readyToLoad[client] = true;
178}
179
180//COMMANDS
181
182public Action CC_SetTag(int client, int args)
183{
184 if (args != 2)
185 {
186 ReplyToCommand(client, "[SM] Incorrect Usage: sm_settag <client> <tag>");
187 return Plugin_Handled;
188 }
189 char arg1[32], arg2[32];
190 GetCmdArg(1, arg1, sizeof(arg1));
191 GetCmdArg(2, arg2, sizeof(arg2));
192 int target = FindTarget(client, arg1);
193 if (target == -1)
194 {
195 return Plugin_Handled;
196 }
197 TagSet(target, arg2);
198 CPrintToChat(client, "%sSuccessfully changed %N's tag to %s", PLUGIN_TAG, target, arg2);
199 return Plugin_Handled;
200}
201
202public Action CC_SetTagColour(int client, int args)
203{
204 if (args != 2)
205 {
206 ReplyToCommand(client, "[SM] Incorrect Usage: sm_settagcolour <client> <colour>");
207 return Plugin_Handled;
208 }
209 char arg1[32], arg2[32];
210 GetCmdArg(1, arg1, sizeof(arg1));
211 GetCmdArg(2, arg2, sizeof(arg2));
212 int target = FindTarget(client, arg1);
213 if (target == -1)
214 {
215 return Plugin_Handled;
216 }
217 TagColourSet(target, arg2);
218 CPrintToChat(client, "%sSuccessfully changed %N's Tag colour to %s", PLUGIN_TAG, target, arg2);
219 return Plugin_Handled;
220}
221
222public Action CC_SetNameColour(int client, int args)
223{
224 if (args != 2)
225 {
226 ReplyToCommand(client, "[SM] Incorrect Usage: sm_setnamecolour <client> <colour>");
227 return Plugin_Handled;
228 }
229 char arg1[32], arg2[32];
230 GetCmdArg(1, arg1, sizeof(arg1));
231 GetCmdArg(2, arg2, sizeof(arg2));
232 int target = FindTarget(client, arg1);
233 if (target == -1)
234 {
235 return Plugin_Handled;
236 }
237 NameColourSet(target, arg2);
238 CPrintToChat(client, "%sSuccessfully changed %N's Name colour to %s", PLUGIN_TAG, target, arg2);
239 return Plugin_Handled;
240}
241
242public Action CC_SetChatColour(int client, int args)
243{
244 if (args != 2)
245 {
246 ReplyToCommand(client, "[SM] Incorrect Usage: sm_setchatcolour <client> <colour>");
247 return Plugin_Handled;
248 }
249 char arg1[32], arg2[32];
250 GetCmdArg(1, arg1, sizeof(arg1));
251 GetCmdArg(2, arg2, sizeof(arg2));
252 int target = FindTarget(client, arg1);
253 if (target == -1)
254 {
255 return Plugin_Handled;
256 }
257 ChatColourSet(target, arg2);
258 CPrintToChat(client, "%sSuccessfully changed %N's Chat colour to %s", PLUGIN_TAG, target, arg2);
259 return Plugin_Handled;
260}
261
262public Action CC_Menu(int client, int args)
263{
264 if(IsVoteInProgress())
265 {
266 CPrintToChat(client, "%sA vote is currently in progress. Please wait until it is over.", PLUGIN_TAG);
267 return Plugin_Handled;
268 }
269 //Create Menu Items.
270 g_chatColoursMain = CreateMenu(CCMainHandler);
271 SetMenuTitle(g_chatColoursMain, "Custom Chat Colours");
272 AddMenuItem(g_chatColoursMain, "TT", "Tag Text");
273 AddMenuItem(g_chatColoursMain, "TC", "Tag Colour");
274 AddMenuItem(g_chatColoursMain, "NC", "Name Colour");
275 AddMenuItem(g_chatColoursMain, "CC", "Chat Colour");
276 AddMenuItem(g_chatColoursMain, "RA", "Reset All");
277 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
278
279 return Plugin_Handled;
280}
281
282public Action CC_Reload(int client, int args)
283{
284 MenuCreation();
285 ReplyToCommand(client, "[SM] CustomChatColours reloaded.");
286 return Plugin_Handled;
287}
288
289//FUNCTIONS
290
291void TagSet(int client, char[] tag, bool checkCorrect = true)
292{
293 if(!SimpleRegexMatch(tag, "^\\[.*\\]$") && checkCorrect)
294 {
295 Format(tag, 64, "[%s]", tag);
296 }
297 Format(g_clientTT[client], 16, tag);
298}
299
300void TagColourSet(int client, char[] colour)
301{
302 if(!SimpleRegexMatch(colour, "^\\{.*\\}$"))
303 {
304 Format(colour, 64, "{%s}", colour);
305 }
306 Format(g_clientTC[client], 16, colour);
307}
308
309void NameColourSet(int client, char[] colour)
310{
311 if(!SimpleRegexMatch(colour, "^\\{.*\\}$"))
312 {
313 Format(colour, 64, "{%s}", colour);
314 }
315 Format(g_clientNC[client], 16, colour);
316}
317
318void ChatColourSet(int client, char[] colour)
319{
320 if(!SimpleRegexMatch(colour, "^\\{.*\\}$"))
321 {
322 Format(colour, 64, "{%s}", colour);
323 }
324 Format(g_clientCC[client], 16, colour);
325}
326
327void ResetTagColour(int client)
328{
329 Format(g_clientTC[client], 16, "");
330}
331
332void ResetNameColour(int client)
333{
334 Format(g_clientNC[client], 16, "");
335}
336
337void ResetChatColour(int client)
338{
339
340 Format(g_clientCC[client], 16, "");
341}
342
343void ResetTag(int client)
344{
345 //Cycles through user and if flags match admin setup, gives them staff TAG
346 if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_ROOT) == (ADMFLAG_GENERIC | ADMFLAG_ROOT)) {
347 TagSet(client,"[WIZARD]");
348 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_CUSTOM6) == (ADMFLAG_GENERIC | ADMFLAG_CUSTOM6)) {
349 TagSet(client,"[Director]");
350 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_CHEATS) == (ADMFLAG_GENERIC | ADMFLAG_CHEATS)) {
351 TagSet(client,"[Root]");
352 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_PASSWORD) == (ADMFLAG_GENERIC | ADMFLAG_PASSWORD)) {
353 TagSet(client,"[Tech]");
354 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_CHANGEMAP) == (ADMFLAG_GENERIC | ADMFLAG_CHANGEMAP)) {
355 TagSet(client,"[Manager]");
356 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC | ADMFLAG_CUSTOM3) == (ADMFLAG_GENERIC | ADMFLAG_CUSTOM3)) {
357 TagSet(client,"[Admin]");
358 } else if (GetUserFlagBits(client) & (ADMFLAG_GENERIC) == (ADMFLAG_GENERIC)) {
359 TagSet(client,"[Mod]");
360 } else {
361 TagSet(client, "", false);
362 }
363}
364
365void ResetCCC(int client)
366{
367 ResetTagColour(client);
368 ResetNameColour(client);
369 ResetChatColour(client);
370 ResetTag(client);
371}
372/*
373public Action CC_AddItem(int client, int args)
374{
375 // sm_addccc <type> <displayName> <sourceName>
376 if(db == null)
377 {
378 CReplyToCommand(client, "%sDatabase not connected. Please try again later.", PLUGIN_TAG);
379 return Plugin_Handled;
380 }
381 char itemType[32];
382 PrintToChatAll("%s", itemType);
383 char displayName[32];
384 char sourceName[32];
385 GetCmdArg(1, itemType, sizeof(itemType));
386 GetCmdArg(2, displayName, sizeof(displayName));
387 GetCmdArg(3, sourceName, sizeof(sourceName));
388 if(args != 3)
389 {
390 CReplyToCommand(client, "%sIncorrect Usage: sm_addccc <type> <displayName> <sourceName> where 1 is a tag and 0 is a colour", PLUGIN_TAG);
391 return Plugin_Handled;
392 }
393 int itemTypeAsInt = StringToInt(itemType);
394 PrintToChatAll("%d", itemTypeAsInt);
395 char escapedDisplayName[64];
396 char escapedSourceName[64];
397 SQL_EscapeString(db, displayName, escapedDisplayName, sizeof(escapedDisplayName));
398 SQL_EscapeString(db, sourceName, escapedSourceName, sizeof(escapedSourceName));
399 char query[128];
400 Format(query, sizeof(query), "INSERT INTO customChatColours VALUES ('%s','%s','%s')", itemType, escapedDisplayName, escapedSourceName);
401 if(!SQL_FastQuery(db, query))
402 {
403 char error[255];
404 SQL_GetError(db, error, sizeof(error));
405 CReplyToCommand(client, "%sAn unexpected error occured. Please contact a server operator");
406 PrintToServer("Failed to query (error: %s)", error);
407 return Plugin_Handled;
408 }
409 CReplyToCommand(client, "%sSuccessfully added %s (Source - %s) as a %s)", displayName, sourceName, itemType);
410 return Plugin_Handled;
411}
412*/
413//MENU ITEMS
414
415void MenuCreation()
416{
417 if(!CCC_Load())
418 {
419 SetFailState("Unable to connect to the MySQL server.");
420 }
421 else
422 {
423 g_tagColourMenu = CreateMenu(TCHandler);
424 SetMenuTitle(g_tagColourMenu, "Tag Colour");
425 AddMenuItem(g_tagColourMenu, "RC", "Reset Tag Colour");
426 g_nameColourMenu = CreateMenu(NCHandler);
427 SetMenuTitle(g_nameColourMenu, "Name Colour");
428 AddMenuItem(g_nameColourMenu, "RC", "Reset Name Colour");
429 g_chatColourMenu = CreateMenu(CCHandler);
430 SetMenuTitle(g_chatColourMenu, "Chat Colour");
431 AddMenuItem(g_chatColourMenu, "RC", "Reset Chat Colour");
432 int i = 0;
433 char strColourIndex[4];
434 while(i < g_ColourCount)
435 {
436 IntToString(i, strColourIndex, 4);
437 AddMenuItem(g_tagColourMenu, strColourIndex, g_DisplayName[i], 0);
438 AddMenuItem(g_nameColourMenu, strColourIndex, g_DisplayName[i], 0);
439 AddMenuItem(g_chatColourMenu, strColourIndex, g_DisplayName[i], 0);
440 i++;
441 }
442
443 g_tagTextMenu = CreateMenu(TTHandler);
444 SetMenuTitle(g_tagTextMenu, "Tag Text");
445 AddMenuItem(g_tagTextMenu, "RT", "Reset Tag");
446 i = 0;
447 char strTagIndex[4];
448 while(i < g_tagCount)
449 {
450 IntToString(i, strTagIndex, 4);
451 AddMenuItem(g_tagTextMenu, strTagIndex, g_tagName[i], 0);
452 i++;
453 }
454 }
455}
456
457public int CCMainHandler(Handle menu, MenuAction action, int client, int item) {
458 char cValue[32];
459 GetMenuItem(menu, item, cValue, sizeof(cValue));
460 if (action == MenuAction_Select) {
461 if (StrEqual(cValue, "TT")) {
462 DisplayMenu(g_tagTextMenu, client, MENU_TIME_FOREVER);
463 } else if (StrEqual(cValue, "TC")) {
464 DisplayMenu(g_tagColourMenu, client, MENU_TIME_FOREVER);
465 } else if (StrEqual(cValue, "NC")) {
466 DisplayMenu(g_nameColourMenu, client, MENU_TIME_FOREVER);
467 } else if (StrEqual(cValue, "CC")) {
468 DisplayMenu(g_chatColourMenu, client, MENU_TIME_FOREVER);
469 } else if (StrEqual(cValue, "RA")) {
470 ResetCCC(client);
471 }
472 }
473}
474
475public int TTHandler(Handle menu, MenuAction action, int client, int item) {
476 char cValue[32];
477 GetMenuItem(menu, item, cValue, sizeof(cValue));
478 if (action == MenuAction_Select) {
479 if (StrEqual(cValue, "RT"))
480 {
481 ResetTag(client);
482 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
483 }
484 else
485 {
486 int indexBuffer = StringToInt(cValue, 10);
487 TagSet(client, g_tagName[indexBuffer]);
488 CPrintToChat(client, "%sNew Tag - %s%s", PLUGIN_TAG, g_clientTC[client], g_tagName[indexBuffer]);
489 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
490 }
491 }
492}
493
494public int TCHandler(Handle menu, MenuAction action, int client, int item) {
495 char cValue[32];
496 GetMenuItem(menu, item, cValue, sizeof(cValue));
497 if (action == MenuAction_Select) {
498 if (StrEqual(cValue, "RC"))
499 {
500 ResetTagColour(client);
501 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
502 }
503 else
504 {
505 int indexBuffer = StringToInt(cValue, 10);
506 TagColourSet(client, g_SourceName[indexBuffer]);
507 CPrintToChat(client, "%sNew Tag Colour - %sThe quick brown fox jumped over the lazy dogs.", PLUGIN_TAG, g_clientTC[client]);
508 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
509 }
510 }
511}
512
513public int NCHandler(Handle menu, MenuAction action, int client, int item) {
514 char cValue[32];
515 GetMenuItem(menu, item, cValue, sizeof(cValue));
516 if (action == MenuAction_Select) {
517 if (StrEqual(cValue, "RC"))
518 {
519 ResetNameColour(client);
520 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
521 }
522 else
523 {
524 int indexBuffer = StringToInt(cValue, 10);
525 NameColourSet(client, g_SourceName[indexBuffer]);
526 CPrintToChat(client, "%sNew Name Colour - %sThe quick brown fox jumped over the lazy dogs.", PLUGIN_TAG, g_clientNC[client]);
527 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
528 }
529 }
530}
531
532public int CCHandler(Handle menu, MenuAction action, int client, int item) {
533 char cValue[32];
534 GetMenuItem(menu, item, cValue, sizeof(cValue));
535 if (action == MenuAction_Select) {
536 if (StrEqual(cValue, "RC"))
537 {
538 ResetChatColour(client);
539 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
540 }
541 else
542 {
543 int indexBuffer = StringToInt(cValue, 10);
544 ChatColourSet(client, g_SourceName[indexBuffer]);
545 CPrintToChat(client, "%sNew Chat Colour - %sThe quick brown fox jumped over the lazy dogs.", PLUGIN_TAG, g_clientCC[client]);
546 DisplayMenu(g_chatColoursMain, client, MENU_TIME_FOREVER);
547 }
548 }
549}
550
551//Load Tags and colours from db.
552
553public bool CCC_Load()
554{
555 char error[255];
556 db = SQL_Connect("CustomChatColours", true, error, sizeof(error));
557
558 if(db == null)
559 {
560 PrintToServer("Could not connect: %s", error);
561 return false;
562 }
563 else
564 {
565 SQL_LockDatabase(db);
566 if(!SQL_FastQuery(db, "CREATE TABLE IF NOT EXISTS customChatColours(ItemType VARCHAR(20) NOT NULL, displayName VARCHAR(20) NOT NULL, sourceName VARCHAR(20) NOT NULL)"))
567 {
568 error = "";
569 SQL_GetError(db, error, sizeof(error));
570 PrintToServer("Failed to query (error: %s)", error);
571 return false;
572 }
573 SQL_UnlockDatabase(db);
574 }
575
576 g_tagCount = FetchResults(db, "CCC_TAG");
577 PrintToServer("Loaded %i tags for CCC", g_tagCount);
578
579 g_ColourCount = FetchResults(db, "CCC_COLOUR");
580 PrintToServer("Loaded %i colours for CCC", g_ColourCount);
581 return true;
582}
583
584public int FetchResults(Database database, char[] itemType)
585{
586 /*
587 Returns number of rows found.
588 */
589 char query[100];
590
591 SQL_LockDatabase(db);
592 Format(query, sizeof(query), "SELECT displayName, sourceName from customChatColours where ItemType = '%s'", itemType);
593 DBResultSet results = SQL_Query(database, query);
594 if(results == null)
595 {
596 return 0;
597 }
598
599 int count = SQL_GetRowCount(results);
600 int counter = 0;
601
602 while(SQL_FetchRow(results))
603 {
604 char displayName[64];
605 char sourceName[64];
606 SQL_FetchString(results, 0, displayName, sizeof(displayName));
607 SQL_FetchString(results, 1, sourceName, sizeof(sourceName));
608 if(StrEqual(itemType, "CCC_COLOUR"))
609 {
610 Format(g_DisplayName[counter], 64, "%s", displayName);
611 Format(g_SourceName[counter], 64, "%s", sourceName);
612 g_ColourIndex[counter] = counter;
613 }
614 if(StrEqual(itemType, "CCC_TAG"))
615 {
616 Format(g_tagName[counter], 64, "%s", displayName);
617 g_tagIndex[counter] = counter;
618 }
619 counter++;
620 }
621 SQL_UnlockDatabase(db);
622 delete results;
623 return count;
624}
625
626//TODO Look at previous CCC, see how it checks a-z admin flags.
627
628stock bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
629{
630 if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
631 {
632 return false;
633 }
634 return true;
635}