-87 Removals
+69 Additions
1#pragma semicolon 11#pragma semicolon 1
22
3// ====[ INCLUDES ]============================================================3// ====[ INCLUDES ]============================================================
4#include <sourcemod>4#include <sourcemod>
5#include <regex>5#include <regex>
6#include <ccc>6#include <ccc>
77
8// ====[ DEFINES ]=============================================================8// ====[ DEFINES ]=============================================================
9#define PLUGIN_NAME "Custom Chat Colors Menu"9#define PLUGIN_NAME "Custom Chat Colors Menu"
10#define PLUGIN_VERSION "2.2"10#define PLUGIN_VERSION "2.3"
11#define MAX_COLORS 25511#define MAX_COLORS 255
12#define TAG 012#define TAG 0
13#define NAME 113#define NAME 1
14#define CHAT 214#define CHAT 2
15#define ENABLEFLAG_TAG (1 << TAG)15#define ENABLEFLAG_TAG (1 << TAG)
16#define ENABLEFLAG_NAME (1 << NAME)16#define ENABLEFLAG_NAME (1 << NAME)
17#define ENABLEFLAG_CHAT (1 << CHAT)17#define ENABLEFLAG_CHAT (1 << CHAT)
1818
19// ====[ HANDLES | CVARS ]=====================================================19// ====[ HANDLES | CVARS ]=====================================================
20new Handle:g_hCvarEnabled, g_iCvarEnabled;20new Handle:g_hCvarEnabled, g_iCvarEnabled;
21new Handle:g_hCvarHideTags, bool:g_bCvarHideTags;21new Handle:g_hCvarHideTags, bool:g_bCvarHideTags;
22new Handle:g_hRegexHex;22new Handle:g_hRegexHex;
23new Handle:g_hSQL;23new Handle:g_hSQL;
2424
25// ====[ VARIABLES ]===========================================================25// ====[ VARIABLES ]===========================================================
26new g_iColorCount;26new g_iColorCount;
27new AdminFlag:g_iColorFlagList[MAX_COLORS][16];27new AdminFlag:g_iColorFlagList[MAX_COLORS][16];
28new bool:g_bColorsLoaded[MAXPLAYERS + 1];28new bool:g_bColorsLoaded[MAXPLAYERS + 1];
29new bool:g_bColorAdminFlags[MAX_COLORS];29new bool:g_bColorAdminFlags[MAX_COLORS];
30new bool:g_bHideTag[MAXPLAYERS + 1];30new bool:g_bHideTag[MAXPLAYERS + 1];
31new bool:g_bAccessColor[MAXPLAYERS + 1][3];31new bool:g_bAccessColor[MAXPLAYERS + 1][3];
32new bool:g_bAccessHideTags[MAXPLAYERS + 1];32new bool:g_bAccessHideTags[MAXPLAYERS + 1];
33new String:g_strAuth[MAXPLAYERS + 1][32];33new String:g_strAuth[MAXPLAYERS + 1][32];
34new String:g_strColor[MAXPLAYERS + 1][3][7];34new String:g_strColor[MAXPLAYERS + 1][3][7];
35new String:g_strColorName[MAX_COLORS][255];35new String:g_strColorName[MAX_COLORS][255];
36new String:g_strColorHex[MAX_COLORS][255];36new String:g_strColorHex[MAX_COLORS][255];
37new String:g_strColorFlags[MAX_COLORS][255];37new String:g_strColorFlags[MAX_COLORS][255];
38new String:g_strConfigFile[PLATFORM_MAX_PATH];38new String:g_strConfigFile[PLATFORM_MAX_PATH];
39new String:g_strSQLDriver[16];39new String:g_strSQLDriver[16];
4040
41// ====[ PLUGIN ]==============================================================41// ====[ PLUGIN ]==============================================================
42public Plugin:myinfo =42public Plugin:myinfo =
43{43{
44 name = PLUGIN_NAME,44 name = PLUGIN_NAME,
45 author = "ReFlexPoison",45 author = "ReFlexPoison, modified/fixed by JoinedSenses",
46 description = "Change Custom Chat Colors settings through easy to access menus",46 description = "Change Custom Chat Colors settings through easy to access menus",
47 version = PLUGIN_VERSION,47 version = PLUGIN_VERSION,
48 url = "http://www.sourcemod.net"48 url = "http://www.sourcemod.net"
49}49}
5050
51// ====[ EVENTS ]==============================================================51// ====[ EVENTS ]==============================================================
52public OnPluginStart()52public OnPluginStart()
53{53{
54 CreateConVar("sm_cccm_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_DONTRECORD | FCVAR_NOTIFY);54 CreateConVar("sm_cccm_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_SPONLY | FCVAR_DONTRECORD | FCVAR_NOTIFY);
5555
56 g_hCvarEnabled = CreateConVar("sm_cccm_enabled", "7", "Enable Custom Chat Colors Menu (Add up the numbers to choose)\n0 = Disabled\n1 = Tag\n2 = Name\n4 = Chat", FCVAR_PLUGIN, true, 0.0, true, 7.0);56 g_hCvarEnabled = CreateConVar("sm_cccm_enabled", "7", "Enable Custom Chat Colors Menu (Add up the numbers to choose)\n0 = Disabled\n1 = Tag\n2 = Name\n4 = Chat", 0, true, 0.0, true, 7.0);
57 g_iCvarEnabled = GetConVarInt(g_hCvarEnabled);57 g_iCvarEnabled = GetConVarInt(g_hCvarEnabled);
58 HookConVarChange(g_hCvarEnabled, OnConVarChange);58 HookConVarChange(g_hCvarEnabled, OnConVarChange);
5959
60 g_hCvarHideTags = CreateConVar("sm_cccm_hidetags", "1", "Allow players to hide their chat tags\n0 = Disabled\n1 = Enabled", FCVAR_PLUGIN, true, 0.0, true, 1.0);60 g_hCvarHideTags = CreateConVar("sm_cccm_hidetags", "1", "Allow players to hide their chat tags\n0 = Disabled\n1 = Enabled", 0, true, 0.0, true, 1.0);
61 g_bCvarHideTags = GetConVarBool(g_hCvarHideTags);61 g_bCvarHideTags = GetConVarBool(g_hCvarHideTags);
62 HookConVarChange(g_hCvarHideTags, OnConVarChange);62 HookConVarChange(g_hCvarHideTags, OnConVarChange);
6363
64 AutoExecConfig(true, "plugin.custom-chatcolors-menu");64 AutoExecConfig(true, "plugin.custom-chatcolors-menu");
6565
66 RegAdminCmd("sm_ccc", Command_Color, ADMFLAG_GENERIC, "Open Custom Chat Colors Menu");66 RegAdminCmd("sm_ccc", Command_Color, ADMFLAG_GENERIC, "Open Custom Chat Colors Menu");
67 RegAdminCmd("sm_reload_cccm", Command_Reload, ADMFLAG_ROOT, "Reloads Custom Chat Colors Menu config");67 RegAdminCmd("sm_reload_cccm", Command_Reload, ADMFLAG_ROOT, "Reloads Custom Chat Colors Menu config");
68 RegAdminCmd("sm_tagcolor", Command_TagColor, ADMFLAG_ROOT, "Change tag color to a specified hexadecimal value");68 RegAdminCmd("sm_tagcolor", Command_TagColor, ADMFLAG_ROOT, "Change tag color to a specified hexadecimal value");
69 RegAdminCmd("sm_resettag", Command_ResetTagColor, ADMFLAG_GENERIC, "Reset tag color to default");69 RegAdminCmd("sm_resettag", Command_ResetTagColor, ADMFLAG_GENERIC, "Reset tag color to default");
70 RegAdminCmd("sm_namecolor", Command_NameColor, ADMFLAG_ROOT, "Change name color to a specified hexadecimal value");70 RegAdminCmd("sm_namecolor", Command_NameColor, ADMFLAG_ROOT, "Change name color to a specified hexadecimal value");
71 RegAdminCmd("sm_resetname", Command_ResetNameColor, ADMFLAG_GENERIC, "Reset name color to default");71 RegAdminCmd("sm_resetname", Command_ResetNameColor, ADMFLAG_GENERIC, "Reset name color to default");
72 RegAdminCmd("sm_chatcolor", Command_ChatColor, ADMFLAG_ROOT, "Change chat color to a specified hexadecimal value");72 RegAdminCmd("sm_chatcolor", Command_ChatColor, ADMFLAG_ROOT, "Change chat color to a specified hexadecimal value");
73 RegAdminCmd("sm_resetchat", Command_ResetChatColor, ADMFLAG_GENERIC, "Reset chat color to default");73 RegAdminCmd("sm_resetchat", Command_ResetChatColor, ADMFLAG_GENERIC, "Reset chat color to default");
7474
75 LoadTranslations("core.phrases");75 LoadTranslations("core.phrases");
76 LoadTranslations("common.phrases");76 LoadTranslations("common.phrases");
77 LoadTranslations("custom-chatcolors-menu.phrases");77 LoadTranslations("custom-chatcolors-menu.phrases");
7878
79 g_hRegexHex = CompileRegex("([A-Fa-f0-9]{6})");79 g_hRegexHex = CompileRegex("([A-Fa-f0-9]{6})");
8080
81 BuildPath(Path_SM, g_strConfigFile, sizeof(g_strConfigFile), "configs/custom-chatcolors-menu.cfg");81 BuildPath(Path_SM, g_strConfigFile, sizeof(g_strConfigFile), "configs/custom-chatcolors-menu.cfg");
8282
83 g_hSQL = INVALID_HANDLE;83 g_hSQL = INVALID_HANDLE;
84 if(SQL_CheckConfig("cccm"))84 if(SQL_CheckConfig("cccm"))
85 SQL_TConnect(SQLQuery_Connect, "cccm");85 SQL_TConnect(SQLQuery_Connect, "cccm");
86}86}
8787
88public OnConVarChange(Handle:hConvar, const String:strOldValue[], const String:strNewValue[])88public OnConVarChange(Handle:hConvar, const String:strOldValue[], const String:strNewValue[])
89{89{
90 if(hConvar == g_hCvarEnabled)90 if(hConvar == g_hCvarEnabled)
91 g_iCvarEnabled = GetConVarInt(g_hCvarEnabled);91 g_iCvarEnabled = GetConVarInt(g_hCvarEnabled);
92 else if(hConvar == g_hCvarHideTags)92 else if(hConvar == g_hCvarHideTags)
93 g_bCvarHideTags = GetConVarBool(g_hCvarHideTags);93 g_bCvarHideTags = GetConVarBool(g_hCvarHideTags);
94}94}
9595
96public SQL_LoadColors(iClient)96public SQL_LoadColors(iClient)
97{97{
98 if(!IsClientAuthorized(iClient))98 if(!IsClientAuthorized(iClient))
99 return;99 return;
100100
101 if(g_hSQL != INVALID_HANDLE)101 if(g_hSQL != INVALID_HANDLE)
102 {102 {
103 decl String:strAuth[32];103 decl String:strAuth[32];
104 GetClientAuthString(iClient, strAuth, sizeof(strAuth));104 GetClientAuthId(iClient, AuthId_Steam2, strAuth, sizeof(strAuth));
105 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), strAuth);105 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), strAuth);
106106
107 decl String:strQuery[256];107 decl String:strQuery[256];
108 Format(strQuery, sizeof(strQuery), "SELECT hidetag, tagcolor, namecolor, chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);108 Format(strQuery, sizeof(strQuery), "SELECT hidetag, tagcolor, namecolor, chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
109 SQL_TQuery(g_hSQL, SQLQuery_LoadColors, strQuery, GetClientUserId(iClient), DBPrio_High);109 SQL_TQuery(g_hSQL, SQLQuery_LoadColors, strQuery, GetClientUserId(iClient), DBPrio_High);
110 }110 }
111}111}
112112
113public OnConfigsExecuted()113public OnConfigsExecuted()
114{114{
115 Config_Load();115 Config_Load();
116}116}
117117
118public OnClientConnected(iClient)118public OnClientConnected(iClient)
119{119{
120 g_bColorsLoaded[iClient] = false;120 g_bColorsLoaded[iClient] = false;
121 g_bHideTag[iClient] = false;121 g_bHideTag[iClient] = false;
122 g_bAccessColor[iClient][TAG] = false;122 g_bAccessColor[iClient][TAG] = false;
123 g_bAccessColor[iClient][NAME] = false;123 g_bAccessColor[iClient][NAME] = false;
124 g_bAccessColor[iClient][CHAT] = false;124 g_bAccessColor[iClient][CHAT] = false;
125 g_bAccessHideTags[iClient] = false;125 g_bAccessHideTags[iClient] = false;
126 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), "");126 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), "");
127 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "");127 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "");
128 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), "");128 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), "");
129 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), "");129 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), "");
130}130}
131131
132public CCC_OnUserConfigLoaded(iClient)132public CCC_OnUserConfigLoaded(iClient)
133{133{
134 if(g_bColorsLoaded[iClient])134 if(g_bColorsLoaded[iClient])
135 return;135 return;
136136
137 decl String:strTag[7];137 decl String:strTag[7];
138 IntToString(CCC_GetColor(iClient, CCC_TagColor), strTag, sizeof(strTag));138 IntToString(CCC_GetColor(iClient, CCC_TagColor), strTag, sizeof(strTag));
139 if(IsValidHex(strTag))139 if(IsValidHex(strTag))
140 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strTag);140 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strTag);
141141
142 decl String:strName[7];142 decl String:strName[7];
143 IntToString(CCC_GetColor(iClient, CCC_TagColor), strName, sizeof(strName));143 IntToString(CCC_GetColor(iClient, CCC_NameColor), strName, sizeof(strName));
144 if(IsValidHex(strName))144 if(IsValidHex(strName))
145 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), strName);145 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), strName);
146146
147 decl String:strChat[7];147 decl String:strChat[7];
148 IntToString(CCC_GetColor(iClient, CCC_TagColor), strChat, sizeof(strChat));148 IntToString(CCC_GetColor(iClient, CCC_ChatColor), strChat, sizeof(strChat));
149 if(IsValidHex(strChat))149 if(IsValidHex(strChat))
150 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), strChat);150 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), strChat);
151}151}
152152
153public OnClientAuthorized(iClient, const String:strAuth[])153public OnClientAuthorized(iClient, const String:strAuth[])
154{154{
155 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), strAuth);155 strcopy(g_strAuth[iClient], sizeof(g_strAuth[]), strAuth);
156}156}
157157
158public OnRebuildAdminCache(AdminCachePart:iPart)158public OnRebuildAdminCache(AdminCachePart:iPart)
159{159{
160 for(new i = 1; i <= MaxClients; i++) if(IsClientInGame(i))160 for(new i = 1; i <= MaxClients; i++) if(IsClientInGame(i))
161 {161 {
162 OnClientConnected(i);162 OnClientConnected(i);
163 OnClientPostAdminCheck(i);163 OnClientPostAdminCheck(i);
164 }164 }
165}165}
166166
167public OnClientPostAdminCheck(iClient)167public OnClientPostAdminCheck(iClient)
168{168{
169 SQL_LoadColors(iClient);169 SQL_LoadColors(iClient);
170 if(CheckCommandAccess(iClient, "sm_ccc_tag", ADMFLAG_GENERIC))170 if(CheckCommandAccess(iClient, "sm_ccc_tag", ADMFLAG_GENERIC))
171 g_bAccessColor[iClient][TAG] = true;171 g_bAccessColor[iClient][TAG] = true;
172 if(CheckCommandAccess(iClient, "sm_ccc_name", ADMFLAG_GENERIC))172 if(CheckCommandAccess(iClient, "sm_ccc_name", ADMFLAG_GENERIC))
173 g_bAccessColor[iClient][NAME] = true;173 g_bAccessColor[iClient][NAME] = true;
174 if(CheckCommandAccess(iClient, "sm_ccc_chat", ADMFLAG_GENERIC))174 if(CheckCommandAccess(iClient, "sm_ccc_chat", ADMFLAG_GENERIC))
175 g_bAccessColor[iClient][CHAT] = true;175 g_bAccessColor[iClient][CHAT] = true;
176 if(CheckCommandAccess(iClient, "sm_ccc_hidetags", ADMFLAG_GENERIC))176 if(CheckCommandAccess(iClient, "sm_ccc_hidetags", ADMFLAG_GENERIC))
177 g_bAccessHideTags[iClient] = true;177 g_bAccessHideTags[iClient] = true;
178}178}
179179
180public Action:CCC_OnColor(iClient, const String:strMessage[], CCC_ColorType:iType)180public Action:CCC_OnColor(iClient, const String:strMessage[], CCC_ColorType:iType)
181{181{
182 if(iType == CCC_TagColor)182 if(iType == CCC_TagColor)
183 {183 {
184 if(!(g_iCvarEnabled & ENABLEFLAG_TAG))184 if(!(g_iCvarEnabled & ENABLEFLAG_TAG))
185 return Plugin_Handled;185 return Plugin_Handled;
186186
187 if(g_bCvarHideTags && g_bHideTag[iClient] && g_bAccessHideTags[iClient])187 if(g_bHideTag[iClient])
188 return Plugin_Handled;
189
190 if(!StrEqual(g_strColor[iClient][TAG], "-1") && !IsValidHex(g_strColor[iClient][TAG]))
191 return Plugin_Handled;188 return Plugin_Handled;
192 }189 }
193190
194 if(iType == CCC_NameColor)191 if(iType == CCC_NameColor)
195 {192 {
196 if(!(g_iCvarEnabled & ENABLEFLAG_NAME))193 if(!(g_iCvarEnabled & ENABLEFLAG_NAME))
197 return Plugin_Handled;194 return Plugin_Handled;
198195
199 if(!IsValidHex(g_strColor[iClient][NAME]))196 if(!IsValidHex(g_strColor[iClient][NAME]))
200 return Plugin_Handled;197 return Plugin_Handled;
201 }198 }
202199
203 if(iType == CCC_ChatColor)200 if(iType == CCC_ChatColor)
204 {201 {
205 if(!(g_iCvarEnabled & ENABLEFLAG_CHAT))202 if(!(g_iCvarEnabled & ENABLEFLAG_CHAT))
206 return Plugin_Handled;203 return Plugin_Handled;
207204
208 if(!IsValidHex(g_strColor[iClient][CHAT]))205 if(!IsValidHex(g_strColor[iClient][CHAT]))
209 return Plugin_Handled;206 return Plugin_Handled;
210 }207 }
211208
212 return Plugin_Continue;209 return Plugin_Continue;
213}210}
214211
215// ====[ COMMANDS ]============================================================212// ====[ COMMANDS ]============================================================
216public Action:Command_Color(iClient, iArgs)213public Action:Command_Color(iClient, iArgs)
217{214{
218 if(!IsValidClient(iClient))215 if(!IsValidClient(iClient))
219 return Plugin_Continue;216 return Plugin_Continue;
220217
221 Menu_Settings(iClient);218 Menu_Settings(iClient);
222 return Plugin_Handled;219 return Plugin_Handled;
223}220}
224221
225public Action:Command_Reload(iClient, iArgs)222public Action:Command_Reload(iClient, iArgs)
226{223{
227 Config_Load();224 Config_Load();
228 ReplyToCommand(iClient, "[SM] Configuration file %s reloaded.", g_strConfigFile);225 ReplyToCommand(iClient, "[SM] Configuration file %s reloaded.", g_strConfigFile);
229 return Plugin_Handled;226 return Plugin_Handled;
230}227}
231228
232public Action:Command_TagColor(iClient, iArgs)229public Action:Command_TagColor(iClient, iArgs)
233{230{
234 if(!IsValidClient(iClient))231 if(!IsValidClient(iClient))
235 return Plugin_Continue;232 return Plugin_Continue;
236233
237 if(iArgs != 1)234 if(iArgs != 1)
238 {235 {
239 ReplyToCommand(iClient, "[SM] Usage: sm_tagcolor <hex>");236 ReplyToCommand(iClient, "[SM] Usage: sm_tagcolor <hex>");
240 return Plugin_Handled;237 return Plugin_Handled;
241 }238 }
242239
243 decl String:strArg[32];240 decl String:strArg[32];
244 GetCmdArgString(strArg, sizeof(strArg));241 GetCmdArgString(strArg, sizeof(strArg));
245 ReplaceString(strArg, sizeof(strArg), "#", "", false);242 ReplaceString(strArg, sizeof(strArg), "#", "", false);
246243
247 if(!IsValidHex(strArg))244 if(!IsValidHex(strArg))
248 {245 {
249 ReplyToCommand(iClient, "[SM] Usage: sm_tagcolor <hex>");246 ReplyToCommand(iClient, "[SM] Usage: sm_tagcolor <hex>");
250 return Plugin_Handled;247 return Plugin_Handled;
251 }248 }
252249
253 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "TagSet", iClient, strArg, strArg);250 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "TagSet", iClient, strArg, strArg);
254 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strArg);251 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strArg);
255 CCC_SetColor(iClient, CCC_TagColor, StringToInt(strArg, 16), false);252 CCC_SetColor(iClient, CCC_TagColor, StringToInt(strArg, 16), false);
256253
257 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))254 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
258 {255 {
259 decl String:strQuery[256];256 decl String:strQuery[256];
260 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);257 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
261 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);258 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);
262 }259 }
263260
264 return Plugin_Handled;261 return Plugin_Handled;
265}262}
266263
267public Action:Command_ResetTagColor(iClient, iArgs)264public Action:Command_ResetTagColor(iClient, iArgs)
268{265{
269 if(!IsValidClient(iClient))266 if(!IsValidClient(iClient))
270 return Plugin_Continue;267 return Plugin_Continue;
271268
272 PrintToChat(iClient, "[SM] %T", "TagReset", iClient);269 PrintToChat(iClient, "[SM] %T", "TagReset", iClient);
273 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "");270 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "");
274 CCC_ResetColor(iClient, CCC_TagColor);271 CCC_ResetColor(iClient, CCC_TagColor);
275272
276 decl String:strTag[32];
277 IntToString(CCC_GetColor(iClient, CCC_TagColor), strTag, sizeof(strTag));
278 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strTag);
279273
280 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))274 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
281 {275 {
282 decl String:strQuery[256];276 decl String:strQuery[256];
283 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);277 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
284 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);278 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);
285 }279 }
286280
287 return Plugin_Handled;281 return Plugin_Handled;
288}282}
289283
290public Action:Command_NameColor(iClient, iArgs)284public Action:Command_NameColor(iClient, iArgs)
291{285{
292 if(!IsValidClient(iClient))286 if(!IsValidClient(iClient))
293 return Plugin_Continue;287 return Plugin_Continue;
294288
295 if(iArgs != 1)289 if(iArgs != 1)
296 {290 {
297 ReplyToCommand(iClient, "[SM] Usage: sm_namecolor <hex>");291 ReplyToCommand(iClient, "[SM] Usage: sm_namecolor <hex>");
298 return Plugin_Handled;292 return Plugin_Handled;
299 }293 }
300294
301 decl String:strArg[32];295 decl String:strArg[32];
302 GetCmdArgString(strArg, sizeof(strArg));296 GetCmdArgString(strArg, sizeof(strArg));
303 ReplaceString(strArg, sizeof(strArg), "#", "", false);297 ReplaceString(strArg, sizeof(strArg), "#", "", false);
304298
305 if(!IsValidHex(strArg))299 if(!IsValidHex(strArg))
306 {300 {
307 ReplyToCommand(iClient, "[SM] Usage: sm_namecolor <hex>");301 ReplyToCommand(iClient, "[SM] Usage: sm_namecolor <hex>");
308 return Plugin_Handled;302 return Plugin_Handled;
309 }303 }
310304
311 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "NameSet", iClient, strArg, strArg);305 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "NameSet", iClient, strArg, strArg);
312 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strArg);306 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), strArg);
313 CCC_SetColor(iClient, CCC_TagColor, StringToInt(strArg, 16), false);307 CCC_SetColor(iClient, CCC_NameColor, StringToInt(strArg, 16), false);
314308
315 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))309 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
316 {310 {
317 decl String:strQuery[256];311 decl String:strQuery[256];
318 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);312 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
319 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);313 SQL_TQuery(g_hSQL, SQLQuery_NameColor, strQuery, GetClientUserId(iClient), DBPrio_High);
320 }314 }
321315
322 return Plugin_Handled;316 return Plugin_Handled;
323}317}
324318
325public Action:Command_ResetNameColor(iClient, iArgs)319public Action:Command_ResetNameColor(iClient, iArgs)
326{320{
327 if(!IsValidClient(iClient))321 if(!IsValidClient(iClient))
328 return Plugin_Continue;322 return Plugin_Continue;
329323
330 PrintToChat(iClient, "[SM] %T", "NameReset", iClient);324 PrintToChat(iClient, "[SM] %T", "NameReset", iClient);
331 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), "");325 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), "");
332 CCC_ResetColor(iClient, CCC_NameColor);326 CCC_ResetColor(iClient, CCC_NameColor);
333327
334 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))328 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
335 {329 {
336 decl String:strQuery[256];330 decl String:strQuery[256];
337 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);331 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
338 SQL_TQuery(g_hSQL, SQLQuery_NameColor, strQuery, GetClientUserId(iClient), DBPrio_High);332 SQL_TQuery(g_hSQL, SQLQuery_NameColor, strQuery, GetClientUserId(iClient), DBPrio_High);
339 }333 }
340334
341 return Plugin_Handled;335 return Plugin_Handled;
342}336}
343337
344public Action:Command_ChatColor(iClient, iArgs)338public Action:Command_ChatColor(iClient, iArgs)
345{339{
346 if(!IsValidClient(iClient))340 if(!IsValidClient(iClient))
347 return Plugin_Continue;341 return Plugin_Continue;
348342
349 if(iArgs != 1)343 if(iArgs != 1)
350 {344 {
351 ReplyToCommand(iClient, "[SM] Usage: sm_chatcolor <hex>");345 ReplyToCommand(iClient, "[SM] Usage: sm_chatcolor <hex>");
352 return Plugin_Handled;346 return Plugin_Handled;
353 }347 }
354348
355 decl String:strArg[32];349 decl String:strArg[32];
356 GetCmdArgString(strArg, sizeof(strArg));350 GetCmdArgString(strArg, sizeof(strArg));
357 ReplaceString(strArg, sizeof(strArg), "#", "", false);351 ReplaceString(strArg, sizeof(strArg), "#", "", false);
358352
359 if(!IsValidHex(strArg))353 if(!IsValidHex(strArg))
360 {354 {
361 ReplyToCommand(iClient, "[SM] Usage: sm_chatcolor <hex>");355 ReplyToCommand(iClient, "[SM] Usage: sm_chatcolor <hex>");
362 return Plugin_Handled;356 return Plugin_Handled;
363 }357 }
364358
365 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "ChatSet", iClient, strArg, strArg);359 PrintToChat(iClient, "\x01[SM] %T \x07%s#%s\x01", "ChatSet", iClient, strArg, strArg);
366 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strArg);360 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strArg);
367 CCC_SetColor(iClient, CCC_TagColor, StringToInt(strArg, 16), false);361 CCC_SetColor(iClient, CCC_TagColor, StringToInt(strArg, 16), false);
368362
369 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))363 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
370 {364 {
371 decl String:strQuery[256];365 decl String:strQuery[256];
372 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);366 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
373 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);367 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iClient), DBPrio_High);
374 }368 }
375369
376 return Plugin_Handled;370 return Plugin_Handled;
377}371}
378372
379public Action:Command_ResetChatColor(iClient, iArgs)373public Action:Command_ResetChatColor(iClient, iArgs)
380{374{
381 if(!IsValidClient(iClient))375 if(!IsValidClient(iClient))
382 return Plugin_Continue;376 return Plugin_Continue;
383377
384 PrintToChat(iClient, "[SM] %T", "ChatReset", iClient);378 PrintToChat(iClient, "[SM] %T", "ChatReset", iClient);
385 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), "");379 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), "");
386 CCC_ResetColor(iClient, CCC_ChatColor);380 CCC_ResetColor(iClient, CCC_ChatColor);
387381
388 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))382 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iClient))
389 {383 {
390 decl String:strQuery[256];384 decl String:strQuery[256];
391 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);385 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iClient]);
392 SQL_TQuery(g_hSQL, SQLQuery_ChatColor, strQuery, GetClientUserId(iClient), DBPrio_High);386 SQL_TQuery(g_hSQL, SQLQuery_ChatColor, strQuery, GetClientUserId(iClient), DBPrio_High);
393 }387 }
394388
395 return Plugin_Handled;389 return Plugin_Handled;
396}390}
397391
398// ====[ MENUS ]===============================================================392// ====[ MENUS ]===============================================================
399public Menu_Settings(iClient)393public Menu_Settings(iClient)
400{394{
401 if(IsVoteInProgress())395 if(IsVoteInProgress())
402 return;396 return;
403397
404 new Handle:hMenu = CreateMenu(MenuHandler_Settings);398 new Handle:hMenu = CreateMenu(MenuHandler_Settings);
405 SetMenuTitle(hMenu, "%T:", "Title", iClient);399 SetMenuTitle(hMenu, "%T:", "Title", iClient);
406400
407 decl String:strBuffer[32];401 decl String:strBuffer[32];
402 if(g_bCvarHideTags)
403 {
404
405 if(!g_bHideTag[iClient])
406 {
407 Format(strBuffer, sizeof(strBuffer), "%T", "HideTag", iClient);
408 AddMenuItem(hMenu, "HideTag", strBuffer);
409 }
410 else
411 {
412 Format(strBuffer, sizeof(strBuffer), "%T", "ShowTag", iClient);
413 AddMenuItem(hMenu, "HideTag", strBuffer);
414 }
415 }
408 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeTag", iClient);416 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeTag", iClient);
409 if(g_iCvarEnabled & ENABLEFLAG_TAG && (g_bAccessColor[iClient][TAG] || (g_bCvarHideTags && g_bAccessHideTags[iClient])))417 if(g_iCvarEnabled & ENABLEFLAG_TAG && g_bAccessColor[iClient][TAG])
410 AddMenuItem(hMenu, "Tag", strBuffer);418 AddMenuItem(hMenu, "Tag", strBuffer);
411 else
412 AddMenuItem(hMenu, "", strBuffer, ITEMDRAW_DISABLED);
413419
414 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeName", iClient);420 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeName", iClient);
415 if(g_iCvarEnabled & ENABLEFLAG_NAME && g_bAccessColor[iClient][NAME])421 if(g_iCvarEnabled & ENABLEFLAG_NAME && g_bAccessColor[iClient][NAME])
416 AddMenuItem(hMenu, "Name", strBuffer);422 AddMenuItem(hMenu, "Name", strBuffer);
417 else
418 AddMenuItem(hMenu, "", strBuffer, ITEMDRAW_DISABLED);
419423
420 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeChat", iClient);424 Format(strBuffer, sizeof(strBuffer), "%T", "ChangeChat", iClient);
421 if(g_iCvarEnabled & ENABLEFLAG_CHAT && g_bAccessColor[iClient][CHAT])425 if(g_iCvarEnabled & ENABLEFLAG_CHAT && g_bAccessColor[iClient][CHAT])
422 AddMenuItem(hMenu, "Chat", strBuffer);426 AddMenuItem(hMenu, "Chat", strBuffer);
423 else
424 AddMenuItem(hMenu, "", strBuffer, ITEMDRAW_DISABLED);
425427
426 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);428 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);
427}429}
428430
429public MenuHandler_Settings(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)431public MenuHandler_Settings(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)
430{432{
431 if(iAction == MenuAction_End)433 if(iAction == MenuAction_End)
432 {434 {
433 CloseHandle(hMenu);435 CloseHandle(hMenu);
434 return;436 return;
435 }437 }
436438
437 if(iAction == MenuAction_Select)439 if(iAction == MenuAction_Select)
438 {440 {
439 decl String:strBuffer[32];441 decl String:strBuffer[32];
440 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));442 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));
443 if(StrEqual(strBuffer, "HideTag"))
444 {
445 if(g_bHideTag[iParam1])
446 {
447 g_bHideTag[iParam1] = false;
448 PrintToChat(iParam1, "[SM] %T", "TagEnabled", iParam1);
449 Menu_Settings(iParam1);
450 }
451 else
452 {
453 g_bHideTag[iParam1] = true;
454 PrintToChat(iParam1, "[SM] %T", "TagDisabled", iParam1);
455 Menu_Settings(iParam1);
456 }
441457
458 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))
459 {
460 decl String:strQuery[256];
461 Format(strQuery, sizeof(strQuery), "SELECT hidetag FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);
462 SQL_TQuery(g_hSQL, SQLQuery_HideTag, strQuery, GetClientUserId(iParam1), DBPrio_High);
463 }
464 }
442 if(StrEqual(strBuffer, "Tag"))465 if(StrEqual(strBuffer, "Tag"))
443 Menu_TagColor(iParam1);466 Menu_TagColor(iParam1);
444 else if(StrEqual(strBuffer, "Name"))467 else if(StrEqual(strBuffer, "Name"))
445 Menu_NameColor(iParam1);468 Menu_NameColor(iParam1);
446 else if(StrEqual(strBuffer, "Chat"))469 else if(StrEqual(strBuffer, "Chat"))
447 Menu_ChatColor(iParam1);470 Menu_ChatColor(iParam1);
448 }471 }
449}472}
450473
451public Menu_TagColor(iClient)474public Menu_TagColor(iClient)
452{475{
453 if(IsVoteInProgress())476 if(IsVoteInProgress())
454 return;477 return;
455478
456 new Handle:hMenu = CreateMenu(MenuHandler_TagColor);479 new Handle:hMenu = CreateMenu(MenuHandler_TagColor);
457 SetMenuTitle(hMenu, "%T:", "TagColor", iClient);480 SetMenuTitle(hMenu, "%T:", "TagColor", iClient);
458 SetMenuExitBackButton(hMenu, true);481 SetMenuExitBackButton(hMenu, true);
459482
460 decl String:strBuffer[32];483 decl String:strBuffer[32];
461 if(g_bCvarHideTags && g_bAccessHideTags[iClient])
462 {
463 if(!g_bHideTag[iClient])
464 {
465 Format(strBuffer, sizeof(strBuffer), "%T", "HideTag", iClient);
466 AddMenuItem(hMenu, "HideTag", strBuffer);
467 }
468 else
469 {
470 Format(strBuffer, sizeof(strBuffer), "%T", "ShowTag", iClient);
471 AddMenuItem(hMenu, "HideTag", strBuffer);
472 }
473 }
474
475 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);484 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);
476 AddMenuItem(hMenu, "Reset", strBuffer);485 AddMenuItem(hMenu, "Reset", strBuffer);
477486
478 decl String:strColorIndex[4];487 decl String:strColorIndex[4];
479 for(new i = 0; i < g_iColorCount; i++)488 for(new i = 0; i < g_iColorCount; i++)
480 {489 {
481 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))490 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))
482 {491 {
483 IntToString(i, strColorIndex, sizeof(strColorIndex));492 IntToString(i, strColorIndex, sizeof(strColorIndex));
484 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);493 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);
485 }494 }
486 }495 }
487496
488 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);497 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);
489}498}
490499
491public MenuHandler_TagColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)500public MenuHandler_TagColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)
492{501{
493 if(iAction == MenuAction_End)502 if(iAction == MenuAction_End)
494 {503 {
495 CloseHandle(hMenu);
496 return;504 return;
497 }505 }
498506
499 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)507 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)
500 {508 {
501 Menu_Settings(iParam1);509 Menu_Settings(iParam1);
502 return;510 return;
503 }511 }
504512
505 if(iAction == MenuAction_Select)513 if(iAction == MenuAction_Select)
506 {514 {
507 decl String:strBuffer[32];515 decl String:strBuffer[32];
508 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));516 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));
509517
510 if(StrEqual(strBuffer, "HideTag"))518 if(StrEqual(strBuffer, "Reset"))
511 {519 {
512 if(g_bHideTag[iParam1])520 PrintToChat(iParam1, "[SM] %T", "TagReset", iParam1);
513 {521 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), "");
514 g_bHideTag[iParam1] = false;522 CCC_ResetColor(iParam1, CCC_TagColor);
515 PrintToChat(iParam1, "[SM] %T", "TagEnabled", iParam1);
516 }
517 else
518 {
519 g_bHideTag[iParam1] = true;
520 PrintToChat(iParam1, "[SM] %T", "TagDisabled", iParam1);
521 }
522523
523 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))524 decl String:strTag[7];
524 {525 IntToString(CCC_GetColor(iParam1, CCC_TagColor), strTag, sizeof(strTag));
525 decl String:strQuery[256];526 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), strTag);
526 Format(strQuery, sizeof(strQuery), "SELECT hidetag FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);
527 SQL_TQuery(g_hSQL, SQLQuery_HideTag, strQuery, GetClientUserId(iParam1), DBPrio_High);
528 }
529 }527 }
530 else528 else
531 {529 {
532 if(StrEqual(strBuffer, "Reset"))530 new iColorIndex = StringToInt(strBuffer);
533 {531 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "TagSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);
534 PrintToChat(iParam1, "[SM] %T", "TagReset", iParam1);532 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);
535 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), "");533 CCC_SetColor(iParam1, CCC_TagColor, StringToInt(g_strColorHex[iColorIndex], 16), false);
536 CCC_ResetColor(iParam1, CCC_TagColor);534 }
537
538 decl String:strTag[32];
539 IntToString(CCC_GetColor(iParam1, CCC_TagColor), strTag, sizeof(strTag));
540 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), strTag);
541 }
542 else
543 {
544 new iColorIndex = StringToInt(strBuffer);
545 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "TagSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);
546 strcopy(g_strColor[iParam1][TAG], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);
547 CCC_SetColor(iParam1, CCC_TagColor, StringToInt(g_strColorHex[iColorIndex], 16), false);
548 }
549535
550 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))536 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))
551 {537 {
552 decl String:strQuery[256];538 decl String:strQuery[256];
553 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);539 Format(strQuery, sizeof(strQuery), "SELECT tagcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);
554 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iParam1), DBPrio_High);540 SQL_TQuery(g_hSQL, SQLQuery_TagColor, strQuery, GetClientUserId(iParam1), DBPrio_High);
555 }
556 }541 }
557542
558 Menu_Settings(iParam1);543 DisplayMenuAtItem(hMenu, iParam1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
559 }544 }
560}545}
561546
562public Menu_NameColor(iClient)547public Menu_NameColor(iClient)
563{548{
564 if(IsVoteInProgress())549 if(IsVoteInProgress())
565 return;550 return;
566551
567 new Handle:hMenu = CreateMenu(MenuHandler_NameColor);552 new Handle:hMenu = CreateMenu(MenuHandler_NameColor);
568 SetMenuTitle(hMenu, "%T:", "NameColor", iClient);553 SetMenuTitle(hMenu, "%T:", "NameColor", iClient);
569 SetMenuExitBackButton(hMenu, true);554 SetMenuExitBackButton(hMenu, true);
570555
571 decl String:strBuffer[32];556 decl String:strBuffer[32];
572 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);557 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);
573 AddMenuItem(hMenu, "Reset", strBuffer);558 AddMenuItem(hMenu, "Reset", strBuffer);
574559
575 decl String:strColorIndex[4];560 decl String:strColorIndex[4];
576 for(new i = 0; i < g_iColorCount; i++)561 for(new i = 0; i < g_iColorCount; i++)
577 {562 {
578 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))563 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))
579 {564 {
580 IntToString(i, strColorIndex, sizeof(strColorIndex));565 IntToString(i, strColorIndex, sizeof(strColorIndex));
581 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);566 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);
582 }567 }
583 }568 }
584569
585 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);570 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);
586}571}
587572
588public MenuHandler_NameColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)573public MenuHandler_NameColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)
589{574{
590 if(iAction == MenuAction_End)575 if(iAction == MenuAction_End)
591 {576 {
592 CloseHandle(hMenu);
593 return;577 return;
594 }578 }
595579
596 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)580 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)
597 {581 {
598 Menu_Settings(iParam1);582 Menu_Settings(iParam1);
599 return;583 return;
600 }584 }
601585
602 if(iAction == MenuAction_Select)586 if(iAction == MenuAction_Select)
603 {587 {
604 decl String:strBuffer[32];588 decl String:strBuffer[32];
605 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));589 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));
606590
607 if(StrEqual(strBuffer, "Reset"))591 if(StrEqual(strBuffer, "Reset"))
608 {592 {
609 PrintToChat(iParam1, "[SM] %T", "NameReset", iParam1);593 PrintToChat(iParam1, "[SM] %T", "NameReset", iParam1);
610 strcopy(g_strColor[iParam1][NAME], sizeof(g_strColor[][]), "");594 strcopy(g_strColor[iParam1][NAME], sizeof(g_strColor[][]), "");
611 CCC_ResetColor(iParam1, CCC_NameColor);595 CCC_ResetColor(iParam1, CCC_NameColor);
612 }596 }
613 else597 else
614 {598 {
615 new iColorIndex = StringToInt(strBuffer);599 new iColorIndex = StringToInt(strBuffer);
616 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "NameSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);600 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "NameSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);
617 strcopy(g_strColor[iParam1][NAME], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);601 strcopy(g_strColor[iParam1][NAME], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);
618 CCC_SetColor(iParam1, CCC_NameColor, StringToInt(g_strColorHex[iColorIndex], 16), false);602 CCC_SetColor(iParam1, CCC_NameColor, StringToInt(g_strColorHex[iColorIndex], 16), false);
619 }603 }
620604
621 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))605 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))
622 {606 {
623 decl String:strQuery[256];607 decl String:strQuery[256];
624 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);608 Format(strQuery, sizeof(strQuery), "SELECT namecolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);
625 SQL_TQuery(g_hSQL, SQLQuery_NameColor, strQuery, GetClientUserId(iParam1), DBPrio_High);609 SQL_TQuery(g_hSQL, SQLQuery_NameColor, strQuery, GetClientUserId(iParam1), DBPrio_High);
626 }610 }
627611
628 Menu_Settings(iParam1);612 DisplayMenuAtItem(hMenu, iParam1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
629 }613 }
630}614}
631615
632public Menu_ChatColor(iClient)616public Menu_ChatColor(iClient)
633{617{
634 if(IsVoteInProgress())618 if(IsVoteInProgress())
635 return;619 return;
636620
637 new Handle:hMenu = CreateMenu(MenuHandler_ChatColor);621 new Handle:hMenu = CreateMenu(MenuHandler_ChatColor);
638 SetMenuTitle(hMenu, "%T:", "ChatColor", iClient);622 SetMenuTitle(hMenu, "%T:", "ChatColor", iClient);
639 SetMenuExitBackButton(hMenu, true);623 SetMenuExitBackButton(hMenu, true);
640624
641 decl String:strBuffer[32];625 decl String:strBuffer[32];
642 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);626 Format(strBuffer, sizeof(strBuffer), "%T", "Reset", iClient);
643 AddMenuItem(hMenu, "Reset", strBuffer);627 AddMenuItem(hMenu, "Reset", strBuffer);
644628
645 decl String:strColorIndex[4];629 decl String:strColorIndex[4];
646 for(new i = 0; i < g_iColorCount; i++)630 for(new i = 0; i < g_iColorCount; i++)
647 {631 {
648 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))632 if(!g_bColorAdminFlags[i] || (g_bColorAdminFlags[i] && HasAdminFlag(iClient, g_iColorFlagList[i])))
649 {633 {
650 IntToString(i, strColorIndex, sizeof(strColorIndex));634 IntToString(i, strColorIndex, sizeof(strColorIndex));
651 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);635 AddMenuItem(hMenu, strColorIndex, g_strColorName[i]);
652 }636 }
653 }637 }
654638
655 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);639 DisplayMenu(hMenu, iClient, MENU_TIME_FOREVER);
656}640}
657641
658public MenuHandler_ChatColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)642public MenuHandler_ChatColor(Handle:hMenu, MenuAction:iAction, iParam1, iParam2)
659{643{
660 if(iAction == MenuAction_End)644 if(iAction == MenuAction_End)
661 {645 {
662 CloseHandle(hMenu);
663 return;646 return;
664 }647 }
665648
666 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)649 if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)
667 {650 {
668 Menu_Settings(iParam1);651 Menu_Settings(iParam1);
669 return;652 return;
670 }653 }
671654
672 if(iAction == MenuAction_Select)655 if(iAction == MenuAction_Select)
673 {656 {
674 decl String:strBuffer[32];657 decl String:strBuffer[32];
675 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));658 GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));
676659
677 if(StrEqual(strBuffer, "Reset"))660 if(StrEqual(strBuffer, "Reset"))
678 {661 {
679 PrintToChat(iParam1, "[SM] %T", "ChatReset", iParam1);662 PrintToChat(iParam1, "[SM] %T", "ChatReset", iParam1);
680 strcopy(g_strColor[iParam1][CHAT], sizeof(g_strColor[][]), "");663 strcopy(g_strColor[iParam1][CHAT], sizeof(g_strColor[][]), "");
681 CCC_ResetColor(iParam1, CCC_ChatColor);664 CCC_ResetColor(iParam1, CCC_ChatColor);
682 }665 }
683 else666 else
684 {667 {
685 new iColorIndex = StringToInt(strBuffer);668 new iColorIndex = StringToInt(strBuffer);
686 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "ChatSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);669 PrintToChat(iParam1, "\x01[SM] %T \x07%s%s\x01", "ChatSet", iParam1, g_strColorHex[iColorIndex], g_strColorName[iColorIndex]);
687 strcopy(g_strColor[iParam1][CHAT], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);670 strcopy(g_strColor[iParam1][CHAT], sizeof(g_strColor[][]), g_strColorHex[iColorIndex]);
688 CCC_SetColor(iParam1, CCC_ChatColor, StringToInt(g_strColorHex[iColorIndex], 16), false);671 CCC_SetColor(iParam1, CCC_ChatColor, StringToInt(g_strColorHex[iColorIndex], 16), false);
689 }672 }
690673
691 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))674 if(g_hSQL != INVALID_HANDLE && IsClientAuthorized(iParam1))
692 {675 {
693 decl String:strQuery[256];676 decl String:strQuery[256];
694 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);677 Format(strQuery, sizeof(strQuery), "SELECT chatcolor FROM cccm_users WHERE auth = '%s'", g_strAuth[iParam1]);
695 SQL_TQuery(g_hSQL, SQLQuery_ChatColor, strQuery, GetClientUserId(iParam1), DBPrio_High);678 SQL_TQuery(g_hSQL, SQLQuery_ChatColor, strQuery, GetClientUserId(iParam1), DBPrio_High);
696 }679 }
697680
698 Menu_Settings(iParam1);681 DisplayMenuAtItem(hMenu, iParam1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
699 }682 }
700}683}
701684
702// ====[ CONFIGURATION ]=======================================================685// ====[ CONFIGURATION ]=======================================================
703public Config_Load()686public Config_Load()
704{687{
705 if(!FileExists(g_strConfigFile))688 if(!FileExists(g_strConfigFile))
706 {689 {
707 SetFailState("Configuration file %s not found!", g_strConfigFile);690 SetFailState("Configuration file %s not found!", g_strConfigFile);
708 return;691 return;
709 }692 }
710693
711 new Handle:hKeyValues = CreateKeyValues("CCC Menu Colors");694 new Handle:hKeyValues = CreateKeyValues("CCC Menu Colors");
712 if(!FileToKeyValues(hKeyValues, g_strConfigFile))695 if(!FileToKeyValues(hKeyValues, g_strConfigFile))
713 {696 {
714 SetFailState("Improper structure for configuration file %s!", g_strConfigFile);697 SetFailState("Improper structure for configuration file %s!", g_strConfigFile);
715 return;698 return;
716 }699 }
717700
718 if(!KvGotoFirstSubKey(hKeyValues))701 if(!KvGotoFirstSubKey(hKeyValues))
719 {702 {
720 SetFailState("Can't find configuration file %s!", g_strConfigFile);703 SetFailState("Can't find configuration file %s!", g_strConfigFile);
721 return;704 return;
722 }705 }
723706
724 for(new i = 0; i < MAX_COLORS; i++)707 for(new i = 0; i < MAX_COLORS; i++)
725 {708 {
726 strcopy(g_strColorName[i], sizeof(g_strColorName[]), "");709 strcopy(g_strColorName[i], sizeof(g_strColorName[]), "");
727 strcopy(g_strColorHex[i], sizeof(g_strColorHex[]), "");710 strcopy(g_strColorHex[i], sizeof(g_strColorHex[]), "");
728 strcopy(g_strColorFlags[i], sizeof(g_strColorFlags[]), "");711 strcopy(g_strColorFlags[i], sizeof(g_strColorFlags[]), "");
729 g_bColorAdminFlags[i] = false;712 g_bColorAdminFlags[i] = false;
730 for(new i2 = 0; i2 < 16; i2++)713 for(new i2 = 0; i2 < 16; i2++)
731 g_iColorFlagList[i][i2] = AdminFlag:-1;714 g_iColorFlagList[i][i2] = AdminFlag:-1;
732 }715 }
733716
734 g_iColorCount = 0;717 g_iColorCount = 0;
735 do718 do
736 {719 {
737 KvGetString(hKeyValues, "name", g_strColorName[g_iColorCount], sizeof(g_strColorName[]));720 KvGetString(hKeyValues, "name", g_strColorName[g_iColorCount], sizeof(g_strColorName[]));
738 KvGetString(hKeyValues, "hex", g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]));721 KvGetString(hKeyValues, "hex", g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]));
739 ReplaceString(g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]), "#", "", false);722 ReplaceString(g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]), "#", "", false);
740 KvGetString(hKeyValues, "flags", g_strColorFlags[g_iColorCount], sizeof(g_strColorFlags[]));723 KvGetString(hKeyValues, "flags", g_strColorFlags[g_iColorCount], sizeof(g_strColorFlags[]));
741724
742 if(!IsValidHex(g_strColorHex[g_iColorCount]))725 if(!IsValidHex(g_strColorHex[g_iColorCount]))
743 {726 {
744 LogError("Invalid hexadecimal value for color %s.", g_strColorName[g_iColorCount]);727 LogError("Invalid hexadecimal value for color %s.", g_strColorName[g_iColorCount]);
745 strcopy(g_strColorName[g_iColorCount], sizeof(g_strColorName[]), "");728 strcopy(g_strColorName[g_iColorCount], sizeof(g_strColorName[]), "");
746 strcopy(g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]), "");729 strcopy(g_strColorHex[g_iColorCount], sizeof(g_strColorHex[]), "");
747 strcopy(g_strColorFlags[g_iColorCount], sizeof(g_strColorFlags[]), "");730 strcopy(g_strColorFlags[g_iColorCount], sizeof(g_strColorFlags[]), "");
748 }731 }
749732
750 if(!StrEqual(g_strColorFlags[g_iColorCount], ""))733 if(!StrEqual(g_strColorFlags[g_iColorCount], ""))
751 {734 {
752 g_bColorAdminFlags[g_iColorCount] = true;735 g_bColorAdminFlags[g_iColorCount] = true;
753 FlagBitsToArray(ReadFlagString(g_strColorFlags[g_iColorCount]), g_iColorFlagList[g_iColorCount], sizeof(g_iColorFlagList[]));736 FlagBitsToArray(ReadFlagString(g_strColorFlags[g_iColorCount]), g_iColorFlagList[g_iColorCount], sizeof(g_iColorFlagList[]));
754 }737 }
755738
756 g_iColorCount++;739 g_iColorCount++;
757 }740 }
758 while(KvGotoNextKey(hKeyValues));741 while(KvGotoNextKey(hKeyValues));
759 CloseHandle(hKeyValues);742 CloseHandle(hKeyValues);
760743
761 LogMessage("Loaded %i colors from configuration file %s.", g_iColorCount, g_strConfigFile);744 LogMessage("Loaded %i colors from configuration file %s.", g_iColorCount, g_strConfigFile);
762}745}
763746
764// ====[ SQL QUERIES ]=========================================================747// ====[ SQL QUERIES ]=========================================================
765public SQLQuery_Connect(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)748public SQLQuery_Connect(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)
766{749{
767 if(hQuery == INVALID_HANDLE)750 if(hQuery == INVALID_HANDLE)
768 return;751 return;
769752
770 g_hSQL = hQuery;753 g_hSQL = hQuery;
771 SQL_GetDriverIdent(hOwner, g_strSQLDriver, sizeof(g_strSQLDriver));754 SQL_GetDriverIdent(hOwner, g_strSQLDriver, sizeof(g_strSQLDriver));
772755
773 if(StrEqual(g_strSQLDriver, "mysql", false))756 if(StrEqual(g_strSQLDriver, "mysql", false))
774 {757 {
775 LogMessage("MySQL server configured. Variable saving enabled.");758 LogMessage("MySQL server configured. Variable saving enabled.");
776 SQL_TQuery(g_hSQL, SQLQuery_Update, "CREATE TABLE IF NOT EXISTS cccm_users (id INT(64) NOT NULL AUTO_INCREMENT, auth varchar(32) UNIQUE, hidetag varchar(1), tagcolor varchar(7), namecolor varchar(7), chatcolor varchar(7), PRIMARY KEY (id))", _, DBPrio_High);759 SQL_TQuery(g_hSQL, SQLQuery_Update, "CREATE TABLE IF NOT EXISTS cccm_users (id INT(64) NOT NULL AUTO_INCREMENT, auth varchar(32) UNIQUE, hidetag varchar(1), tagcolor varchar(7), namecolor varchar(7), chatcolor varchar(7), PRIMARY KEY (id))", _, DBPrio_High);
777 }760 }
778 else if(StrEqual(g_strSQLDriver, "sqlite", false))761 else if(StrEqual(g_strSQLDriver, "sqlite", false))
779 {762 {
780 LogMessage("SQlite server configured. Variable saving enabled.");763 LogMessage("SQlite server configured. Variable saving enabled.");
781 SQL_TQuery(g_hSQL, SQLQuery_Update, "CREATE TABLE IF NOT EXISTS cccm_users (id INTERGER PRIMARY KEY, auth varchar(32) UNIQUE, hidetag varchar(1), tagcolor varchar(7), namecolor varchar(7), chatcolor varchar(7))", _, DBPrio_High);764 SQL_TQuery(g_hSQL, SQLQuery_Update, "CREATE TABLE IF NOT EXISTS cccm_users (id INTERGER PRIMARY KEY, auth varchar(32) UNIQUE, hidetag varchar(1), tagcolor varchar(7), namecolor varchar(7), chatcolor varchar(7))", _, DBPrio_High);
782 }765 }
783 else766 else
784 {767 {
785 LogMessage("Saved variable server not configured. Variable saving disabled.");768 LogMessage("Saved variable server not configured. Variable saving disabled.");
786 return;769 return;
787 }770 }
788771
789 for(new i = 1; i <= MaxClients; ++i) if(IsClientInGame(i))772 for(new i = 1; i <= MaxClients; ++i) if(IsClientInGame(i))
790 SQL_LoadColors(i);773 SQL_LoadColors(i);
791}774}
792775
793public SQLQuery_LoadColors(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)776public SQLQuery_LoadColors(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)
794{777{
795 new iClient = GetClientOfUserId(iData);778 new iClient = GetClientOfUserId(iData);
796 if(!IsValidClient(iClient))779 if(!IsValidClient(iClient))
797 return;780 return;
798781
799 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)782 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)
800 {783 {
801 LogError("SQL Error: %s", strError);784 LogError("SQL Error: %s", strError);
802 return;785 return;
803 }786 }
804787
805 if(SQL_FetchRow(hQuery) && SQL_GetRowCount(hQuery) != 0)788 if(SQL_FetchRow(hQuery) && SQL_GetRowCount(hQuery) != 0)
806 {789 {
807 g_bHideTag[iClient] = bool:SQL_FetchInt(hQuery, 0);790 g_bHideTag[iClient] = bool:SQL_FetchInt(hQuery, 0);
808791
809 decl String:strTag[7];792 decl String:strTag[7];
810 SQL_FetchString(hQuery, 1, strTag, sizeof(strTag));793 SQL_FetchString(hQuery, 1, strTag, sizeof(strTag));
811 if(IsValidHex(strTag))794 if(IsValidHex(strTag))
812 {795 {
813 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strTag);796 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), strTag);
814 CCC_SetColor(iClient, CCC_TagColor, StringToInt(g_strColor[iClient][TAG], 16), false);797 CCC_SetColor(iClient, CCC_TagColor, StringToInt(g_strColor[iClient][TAG], 16), false);
815 }798 }
816 else if(StrEqual(strTag, "-1"))799 else if(StrEqual(strTag, "-1"))
817 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "-1");800 strcopy(g_strColor[iClient][TAG], sizeof(g_strColor[][]), "-1");
818801
819 decl String:strName[7];802 decl String:strName[7];
820 SQL_FetchString(hQuery, 2, strName, sizeof(strName));803 SQL_FetchString(hQuery, 2, strName, sizeof(strName));
821 if(IsValidHex(strName))804 if(IsValidHex(strName))
822 {805 {
823 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), strName);806 strcopy(g_strColor[iClient][NAME], sizeof(g_strColor[][]), strName);
824 CCC_SetColor(iClient, CCC_NameColor, StringToInt(g_strColor[iClient][NAME], 16), false);807 CCC_SetColor(iClient, CCC_NameColor, StringToInt(g_strColor[iClient][NAME], 16), false);
825 }808 }
826809
827 decl String:strChat[7];810 decl String:strChat[7];
828 SQL_FetchString(hQuery, 3, strChat, sizeof(strChat));811 SQL_FetchString(hQuery, 3, strChat, sizeof(strChat));
829 if(IsValidHex(strChat))812 if(IsValidHex(strChat))
830 {813 {
831 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), strChat);814 strcopy(g_strColor[iClient][CHAT], sizeof(g_strColor[][]), strChat);
832 CCC_SetColor(iClient, CCC_ChatColor, StringToInt(g_strColor[iClient][CHAT], 16), false);815 CCC_SetColor(iClient, CCC_ChatColor, StringToInt(g_strColor[iClient][CHAT], 16), false);
833 }816 }
834817
835 g_bColorsLoaded[iClient] = true;818 g_bColorsLoaded[iClient] = true;
836 }819 }
837}820}
838821
839public SQLQuery_HideTag(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)822public SQLQuery_HideTag(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)
840{823{
841 new iClient = GetClientOfUserId(iClientId);824 new iClient = GetClientOfUserId(iClientId);
842 if(!IsValidClient(iClient))825 if(!IsValidClient(iClient))
843 return;826 return;
844827
845 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)828 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)
846 {829 {
847 LogError("SQL Error: %s", strError);830 LogError("SQL Error: %s", strError);
848 return;831 return;
849 }832 }
850833
851 if(SQL_GetRowCount(hQuery) == 0)834 if(SQL_GetRowCount(hQuery) == 0)
852 {835 {
853 decl String:strQuery[256];836 decl String:strQuery[256];
854 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (hidetag, auth) VALUES (%i, '%s')", g_bHideTag[iClient], g_strAuth[iClient]);837 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (hidetag, auth) VALUES (%i, '%s')", g_bHideTag[iClient], g_strAuth[iClient]);
855 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);838 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);
856 }839 }
857 else840 else
858 {841 {
859 decl String:strQuery[256];842 decl String:strQuery[256];
860 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET hidetag = '%i' WHERE auth = '%s'", g_bHideTag[iClient], g_strAuth[iClient]);843 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET hidetag = '%i' WHERE auth = '%s'", g_bHideTag[iClient], g_strAuth[iClient]);
861 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);844 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);
862 }845 }
863}846}
864847
865public SQLQuery_TagColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)848public SQLQuery_TagColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)
866{849{
867 new iClient = GetClientOfUserId(iClientId);850 new iClient = GetClientOfUserId(iClientId);
868 if(!IsValidClient(iClient))851 if(!IsValidClient(iClient))
869 return;852 return;
870853
871 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)854 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)
872 {855 {
873 LogError("SQL Error: %s", strError);856 LogError("SQL Error: %s", strError);
874 return;857 return;
875 }858 }
876859
877 if(SQL_GetRowCount(hQuery) == 0)860 if(SQL_GetRowCount(hQuery) == 0)
878 {861 {
879 decl String:strQuery[256];862 decl String:strQuery[256];
880 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (tagcolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][TAG], g_strAuth[iClient]);863 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (tagcolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][TAG], g_strAuth[iClient]);
881 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);864 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);
882 }865 }
883 else866 else
884 {867 {
885 decl String:strQuery[256];868 decl String:strQuery[256];
886 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET tagcolor = '%s' WHERE auth = '%s'", g_strColor[iClient][TAG], g_strAuth[iClient]);869 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET tagcolor = '%s' WHERE auth = '%s'", g_strColor[iClient][TAG], g_strAuth[iClient]);
887 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);870 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);
888 }871 }
889}872}
890873
891public SQLQuery_NameColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)874public SQLQuery_NameColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)
892{875{
893 new iClient = GetClientOfUserId(iClientId);876 new iClient = GetClientOfUserId(iClientId);
894 if(!IsValidClient(iClient))877 if(!IsValidClient(iClient))
895 return;878 return;
896879
897 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)880 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)
898 {881 {
899 LogError("SQL Error: %s", strError);882 LogError("SQL Error: %s", strError);
900 return;883 return;
901 }884 }
902885
903 if(SQL_GetRowCount(hQuery) == 0)886 if(SQL_GetRowCount(hQuery) == 0)
904 {887 {
905 decl String:strQuery[256];888 decl String:strQuery[256];
906 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (namecolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][NAME], g_strAuth[iClient]);889 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (namecolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][NAME], g_strAuth[iClient]);
907 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);890 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);
908 }891 }
909 else892 else
910 {893 {
911 decl String:strQuery[256];894 decl String:strQuery[256];
912 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET namecolor = '%s' WHERE auth = '%s'", g_strColor[iClient][NAME], g_strAuth[iClient]);895 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET namecolor = '%s' WHERE auth = '%s'", g_strColor[iClient][NAME], g_strAuth[iClient]);
913 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);896 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);
914 }897 }
915}898}
916899
917public SQLQuery_ChatColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)900public SQLQuery_ChatColor(Handle:hOwner, Handle:hQuery, const String:strError[], any:iClientId)
918{901{
919 new iClient = GetClientOfUserId(iClientId);902 new iClient = GetClientOfUserId(iClientId);
920 if(!IsValidClient(iClient))903 if(!IsValidClient(iClient))
921 return;904 return;
922905
923 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)906 if(hOwner == INVALID_HANDLE || hQuery == INVALID_HANDLE)
924 {907 {
925 LogError("SQL Error: %s", strError);908 LogError("SQL Error: %s", strError);
926 return;909 return;
927 }910 }
928911
929 if(SQL_GetRowCount(hQuery) == 0)912 if(SQL_GetRowCount(hQuery) == 0)
930 {913 {
931 decl String:strQuery[256];914 decl String:strQuery[256];
932 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (chatcolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][CHAT], g_strAuth[iClient]);915 Format(strQuery, sizeof(strQuery), "INSERT INTO cccm_users (chatcolor, auth) VALUES ('%s', '%s')", g_strColor[iClient][CHAT], g_strAuth[iClient]);
933 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);916 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_High);
934 }917 }
935 else918 else
936 {919 {
937 decl String:strQuery[256];920 decl String:strQuery[256];
938 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET chatcolor = '%s' WHERE auth = '%s'", g_strColor[iClient][CHAT], g_strAuth[iClient]);921 Format(strQuery, sizeof(strQuery), "UPDATE cccm_users SET chatcolor = '%s' WHERE auth = '%s'", g_strColor[iClient][CHAT], g_strAuth[iClient]);
939 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);922 SQL_TQuery(g_hSQL, SQLQuery_Update, strQuery, _, DBPrio_Normal);
940 }923 }
941}924}
942925
943public SQLQuery_Update(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)926public SQLQuery_Update(Handle:hOwner, Handle:hQuery, const String:strError[], any:iData)
944{927{
945 if(hQuery == INVALID_HANDLE)928 if(hQuery == INVALID_HANDLE)
946 LogError("SQL Error: %s", strError);929 LogError("SQL Error: %s", strError);
947}930}
948931
949// ====[ STOCKS ]==============================================================932// ====[ STOCKS ]==============================================================
950stock bool:IsValidClient(iClient)933stock bool:IsValidClient(iClient)
951{934{
952 if(iClient <= 0 || iClient > MaxClients || !IsClientInGame(iClient))935 if(iClient <= 0 || iClient > MaxClients || !IsClientInGame(iClient))
953 return false;936 return false;
954 return true;937 return true;
955}938}
956939
957stock bool:IsValidHex(const String:strHex[])940stock bool:IsValidHex(const String:strHex[])
958{941{
959 if(strlen(strHex) == 6 && MatchRegex(g_hRegexHex, strHex))942 if(strlen(strHex) == 6 && MatchRegex(g_hRegexHex, strHex))
960 return true;943 return true;
961 return false;944 return false;
962}945}
963946
964stock bool:HasAdminFlag(iClient, const AdminFlag:iFlagList[16])947stock bool:HasAdminFlag(iClient, const AdminFlag:iFlagList[16])
965{948{
966 new iFlags = GetUserFlagBits(iClient);949 new iFlags = GetUserFlagBits(iClient);
967 if(iFlags & ADMFLAG_ROOT)950 if(iFlags & ADMFLAG_ROOT)
968 return true;951 return true;
969952
970 for(new i = 0; i < sizeof(iFlagList); i++)953 for(new i = 0; i < sizeof(iFlagList); i++)
971 {954 {
972 if(iFlags & FlagToBit(iFlagList[i]))955 if(iFlags & FlagToBit(iFlagList[i]))
973 return true;956 return true;
974 }957 }
975 return false;958 return false;
976}959}
Editor
Original Text
Changed Text
Recommended videos