SHOW:
|
|
- or go back to the newest paste.
1 | #include <sourcemod> | |
2 | #include <sdktools> | |
3 | #include <chat-processor> | |
4 | #include <colorvariables> | |
5 | ||
6 | #pragma semicolon 1 | |
7 | #pragma newdecls required | |
8 | ||
9 | - | #define PLUGIN_VERSION "1.11almostreadyforrelease" |
9 | + | #define PLUGIN_VERSION "1.0.1" |
10 | ||
11 | public Plugin myinfo = { | |
12 | - | name = "[Source 2013] Chat-Processor Module: Chat Tags", |
12 | + | name = "[Source 2013] Chat-Processor Module: Chat Tags", |
13 | - | author = "404 (abrandnewday)", |
13 | + | author = "404 (abrandnewday)", |
14 | description = "Processes chat and provides colors and tags for Source 2013 games", | |
15 | - | version = PLUGIN_VERSION, |
15 | + | version = PLUGIN_VERSION, |
16 | - | url = "http://www.unfgaming.net" |
16 | + | url = "http://www.unfgaming.net" |
17 | }; | |
18 | ||
19 | #define MAXLENGTH_NAME_NEW 256 | |
20 | ||
21 | Handle hColorForward; | |
22 | Handle hNameForward; | |
23 | Handle hTagForward; | |
24 | Handle hApplicationForward; | |
25 | Handle hMessageForward; | |
26 | Handle hPreLoadedForward; | |
27 | Handle hLoadedForward; | |
28 | - | #define MAXLENGTH_256 256 |
28 | + | |
29 | - | #define MAXLENGTH_32 32 |
29 | + | |
30 | char g_strTag[MAXPLAYERS + 1][32]; | |
31 | - | char g_strTag[MAXPLAYERS + 1][MAXLENGTH_256]; |
31 | + | char g_strTagColor[MAXPLAYERS + 1][32]; |
32 | - | char g_strTagColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
32 | + | char g_strUsernameColor[MAXPLAYERS + 1][12]; |
33 | - | char g_strUsernameColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
33 | + | char g_strChatColor[MAXPLAYERS + 1][12]; |
34 | - | char g_strTextColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
34 | + | |
35 | char g_strDefaultTag[MAXPLAYERS + 1][32]; | |
36 | - | char g_strDefaultTag[MAXPLAYERS + 1][MAXLENGTH_256]; |
36 | + | char g_strDefaultTagColor[MAXPLAYERS + 1][32]; |
37 | - | char g_strDefaultTagColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
37 | + | char g_strDefaultUsernameColor[MAXPLAYERS + 1][12]; |
38 | - | char g_strDefaultUsernameColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
38 | + | char g_strDefaultChatColor[MAXPLAYERS + 1][12]; |
39 | - | char g_strDefaultTextColor[MAXPLAYERS + 1][MAXLENGTH_32]; |
39 | + | |
40 | KeyValues kvConfigFile = null; | |
41 | ||
42 | enum CPT_ColorType { | |
43 | CPT_TagColor, | |
44 | CPT_NameColor, | |
45 | CPT_ChatColor | |
46 | - | CPT_TextColor |
46 | + | |
47 | ||
48 | #define COLOR_NONE -1 | |
49 | #define COLOR_GREEN -2 | |
50 | #define COLOR_OLIVE -3 | |
51 | #define COLOR_TEAM -4 | |
52 | ||
53 | #define UPDATE_FILE "chatcolors.txt" | |
54 | ||
55 | ||
56 | public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] strError, int iErrMax) | |
57 | { | |
58 | CreateNative("CPT_GetColor", Native_GetColor); | |
59 | CreateNative("CPT_SetColor", Native_SetColor); | |
60 | CreateNative("CPT_GetTag", Native_GetTag); | |
61 | CreateNative("CPT_SetTag", Native_SetTag); | |
62 | CreateNative("CPT_ResetColor", Native_ResetColor); | |
63 | CreateNative("CPT_ResetTag", Native_ResetTag); | |
64 | ||
65 | RegPluginLibrary("cpt"); | |
66 | ||
67 | return APLRes_Success; | |
68 | } | |
69 | ||
70 | - | RegAdminCmd("sm_printenginecodes", Command_PrintEngineCodes, ADMFLAG_ROOT, "Prints all available engine codes"); |
70 | + | |
71 | { | |
72 | RegAdminCmd("sm_reloadtags", Command_ReloadConfig, ADMFLAG_CONFIG, "Reloads Custom Chat Colors config file"); | |
73 | hColorForward = CreateGlobalForward("CPT_OnChatColor", ET_Event, Param_Cell); | |
74 | hNameForward = CreateGlobalForward("CPT_OnNameColor", ET_Event, Param_Cell); | |
75 | hTagForward = CreateGlobalForward("CPT_OnTagApplied", ET_Event, Param_Cell); | |
76 | hApplicationForward = CreateGlobalForward("CPT_OnColor", ET_Event, Param_Cell, Param_String, Param_Cell); | |
77 | hMessageForward = CreateGlobalForward("CPT_OnChatMessage", ET_Ignore, Param_Cell, Param_String, Param_Cell); | |
78 | hPreLoadedForward = CreateGlobalForward("CPT_OnUserConfigPreLoaded", ET_Event, Param_Cell); | |
79 | hLoadedForward = CreateGlobalForward("CPT_OnUserConfigLoaded", ET_Ignore, Param_Cell); | |
80 | hConfigReloadedForward = CreateGlobalForward("CPT_OnConfigReloaded", ET_Ignore); | |
81 | LoadConfig(); | |
82 | } | |
83 | ||
84 | void LoadConfig() | |
85 | { | |
86 | if(kvConfigFile != null) | |
87 | { | |
88 | delete kvConfigFile; | |
89 | } | |
90 | kvConfigFile = new KeyValues("chat_processor_tags"); | |
91 | char strPath[64]; | |
92 | BuildPath(Path_SM, strPath, sizeof(strPath), "configs/chat-processor-tags.cfg"); | |
93 | if(!kvConfigFile.ImportFromFile(strPath)) | |
94 | { | |
95 | SetFailState("Config file missing"); | |
96 | } | |
97 | for(int i = 1; i <= MaxClients; i++) | |
98 | { | |
99 | if(!IsClientInGame(i) || IsFakeClient(i)) | |
100 | { | |
101 | continue; | |
102 | } | |
103 | ClearValues(i); | |
104 | OnClientPostAdminCheck(i); | |
105 | } | |
106 | } | |
107 | ||
108 | public Action Command_ReloadConfig(int iClient, int iArgs) | |
109 | { | |
110 | LoadConfig(); | |
111 | LogAction(iClient, -1, "Reloaded Chat-Processor Tags config file"); | |
112 | ReplyToCommand(iClient, "[CPT] Reloaded config file."); | |
113 | Call_StartForward(hConfigReloadedForward); | |
114 | Call_Finish(); | |
115 | return Plugin_Handled; | |
116 | } | |
117 | - | public Action Command_PrintEngineCodes(int iClient, int iArgs) |
117 | + | |
118 | stock void ClearValues(int iClient) | |
119 | - | CPrintToChat(iClient, "\x01Test of x01"); |
119 | + | |
120 | - | CPrintToChat(iClient, "\x02Test of x02"); |
120 | + | |
121 | - | CPrintToChat(iClient, "\x03Test of x03"); |
121 | + | |
122 | - | CPrintToChat(iClient, "\x04Test of x04"); |
122 | + | |
123 | - | CPrintToChat(iClient, "\x05Test of x05"); |
123 | + | Format(g_strChatColor[iClient], sizeof(g_strChatColor[]), ""); |
124 | - | CPrintToChat(iClient, "\x06Test of x06"); |
124 | + | |
125 | - | CPrintToChat(iClient, "\x07Test of x07"); |
125 | + | |
126 | - | CPrintToChat(iClient, "\x08Test of x08"); |
126 | + | |
127 | - | CPrintToChat(iClient, "\x09Test of x09"); |
127 | + | |
128 | - | CPrintToChat(iClient, "\x0ATest of x0A"); |
128 | + | Format(g_strDefaultChatColor[iClient], sizeof(g_strDefaultChatColor[]), ""); |
129 | - | CPrintToChat(iClient, "\x0BTest of x0B"); |
129 | + | |
130 | - | CPrintToChat(iClient, "\x0CTest of x0C"); |
130 | + | |
131 | - | CPrintToChat(iClient, "\x0DTest of x0D"); |
131 | + | |
132 | - | CPrintToChat(iClient, "\x0ETest of x0E"); |
132 | + | |
133 | - | CPrintToChat(iClient, "\x0FTest of x0F"); |
133 | + | |
134 | - | CPrintToChat(iClient, "\x10Test of x10"); |
134 | + | |
135 | ||
136 | public void OnClientDisconnect(int iClient) | |
137 | { | |
138 | ClearValues(iClient); // On connect and on disconnect, just to be safe | |
139 | } | |
140 | ||
141 | public void OnClientPostAdminCheck(int iClient) | |
142 | { | |
143 | - | Format(g_strTextColor[iClient], sizeof(g_strTextColor[]), ""); |
143 | + | |
144 | { | |
145 | return; // Another plugin wants to block this | |
146 | } | |
147 | ||
148 | - | Format(g_strDefaultTextColor[iClient], sizeof(g_strDefaultTextColor[]), ""); |
148 | + | |
149 | char strAuthId2[32]; | |
150 | GetClientAuthId(iClient, AuthId_Steam2, strAuthId2, sizeof(strAuthId2)); | |
151 | kvConfigFile.Rewind(); | |
152 | if(!kvConfigFile.JumpToKey(strAuthId2)) | |
153 | { | |
154 | kvConfigFile.Rewind(); | |
155 | kvConfigFile.GotoFirstSubKey(); | |
156 | AdminId iAdmin = GetUserAdmin(iClient); | |
157 | AdminFlag fFlag; | |
158 | char strConfigFlag[2]; | |
159 | char strSection[32]; | |
160 | bool bFound = false; | |
161 | do | |
162 | { | |
163 | kvConfigFile.GetSectionName(strSection, sizeof(strSection)); | |
164 | kvConfigFile.GetString("flag", strConfigFlag, sizeof(strConfigFlag)); | |
165 | if(strlen(strConfigFlag) > 1) | |
166 | { | |
167 | LogError("Multiple flags given in section \"%s\", which is not allowed. Using first character.", strSection); | |
168 | } | |
169 | if(strlen(strConfigFlag) == 0 && StrContains(strSection, "STEAM_", false) == -1 && StrContains(strSection, "[U:1:", false) == -1) | |
170 | { | |
171 | bFound = true; | |
172 | break; | |
173 | } | |
174 | if(!FindFlagByChar(strConfigFlag[0], fFlag)) | |
175 | { | |
176 | if(strlen(strConfigFlag) > 0) | |
177 | { | |
178 | LogError("Invalid flag given for section \"%s\", skipping", strSection); | |
179 | } | |
180 | continue; | |
181 | } | |
182 | if(GetAdminFlag(iAdmin, fFlag)) | |
183 | { | |
184 | bFound = true; | |
185 | break; | |
186 | } | |
187 | } while(kvConfigFile.GotoNextKey()); | |
188 | if(!bFound) | |
189 | { | |
190 | return; | |
191 | } | |
192 | } | |
193 | char strClientTagColor[12]; | |
194 | char strClientNameColor[12]; | |
195 | char strClientChatColor[12]; | |
196 | kvConfigFile.GetString("tag", g_strTag[iClient], sizeof(g_strTag[])); | |
197 | kvConfigFile.GetString("tagcolor", strClientTagColor, sizeof(strClientTagColor)); | |
198 | kvConfigFile.GetString("namecolor", strClientNameColor, sizeof(strClientNameColor)); | |
199 | kvConfigFile.GetString("textcolor", strClientChatColor, sizeof(strClientChatColor)); | |
200 | ReplaceString(strClientTagColor, sizeof(strClientTagColor), "#", ""); | |
201 | ReplaceString(strClientNameColor, sizeof(strClientNameColor), "#", ""); | |
202 | ReplaceString(strClientChatColor, sizeof(strClientChatColor), "#", ""); | |
203 | int iTagLength = strlen(strClientTagColor); | |
204 | int iNameLength = strlen(strClientNameColor); | |
205 | int iChatLength = strlen(strClientChatColor); | |
206 | if(iTagLength == 6 || iTagLength == 8 || StrEqual(strClientTagColor, "T", false) || StrEqual(strClientTagColor, "G", false) || StrEqual(strClientTagColor, "O", false)) | |
207 | { | |
208 | strcopy(g_strTagColor[iClient], sizeof(g_strTagColor[]), strClientTagColor); | |
209 | } | |
210 | if(iNameLength == 6 || iNameLength == 8 || StrEqual(strClientNameColor, "G", false) || StrEqual(strClientNameColor, "O", false)) | |
211 | { | |
212 | strcopy(g_strUsernameColor[iClient], sizeof(g_strUsernameColor[]), strClientNameColor); | |
213 | } | |
214 | - | /* Color Handling */ |
214 | + | if(iChatLength == 6 || iChatLength == 8 || StrEqual(strClientChatColor, "T", false) || StrEqual(strClientChatColor, "G", false) || StrEqual(strClientChatColor, "O", false)) |
215 | { | |
216 | - | // Define tag/name/text color strings |
216 | + | strcopy(g_strChatColor[iClient], sizeof(g_strChatColor[]), strClientChatColor); |
217 | } | |
218 | strcopy(g_strDefaultTag[iClient], sizeof(g_strDefaultTag[]), g_strTag[iClient]); | |
219 | - | char strClientTextColor[12]; |
219 | + | |
220 | strcopy(g_strDefaultUsernameColor[iClient], sizeof(g_strDefaultUsernameColor[]), g_strUsernameColor[iClient]); | |
221 | strcopy(g_strDefaultChatColor[iClient], sizeof(g_strDefaultChatColor[]), g_strChatColor[iClient]); | |
222 | Call_StartForward(hLoadedForward); | |
223 | Call_PushCell(iClient); | |
224 | - | kvConfigFile.GetString("textcolor", strClientTextColor, sizeof(strClientTextColor)); |
224 | + | |
225 | } | |
226 | - | // Replace #'s |
226 | + | |
227 | forward Action OnChatMessage(int& author, Handle recipients, eChatFlags& flag, char[] name, char[] message, bool& bProcessColors, bool& bRemoveColors); | |
228 | { | |
229 | - | ReplaceString(strClientTextColor, sizeof(strClientTextColor), "#", ""); |
229 | + | |
230 | } | |
231 | - | int iTagColorLength = strlen(strClientTagColor); |
231 | + | |
232 | - | int iNameColorLength = strlen(strClientNameColor); |
232 | + | forward void OnChatMessagePost(int author, Handle recipients, eChatFlags flag, const char[] name, const char[] message, bool bProcessColors, bool bRemoveColors); |
233 | - | int iTextColorLength = strlen(strClientTextColor); |
233 | + | |
234 | char strNewName[MAXLENGTH_NAME_NEW]; | |
235 | - | if(iTagColorLength == 6 /* RGB */ |
235 | + | strcopy(strNewName, sizeof(strNewName), name); |
236 | - | || iTagColorLength == 8 /* RGBA */ |
236 | + | |
237 | - | || StrEqual(strClientTagColor, "T", false) /* Team-Colored */ |
237 | + | char strNewMessage[MAXLENGTH_MESSAGE]; |
238 | - | || StrEqual(strClientTagColor, "G", false) /* Green */ |
238 | + | strcopy(strNewMessage, sizeof(strNewMessage), message); |
239 | - | || StrEqual(strClientTagColor, "O", false) /* Olive */) |
239 | + | |
240 | if(CheckForward(iAuthor, strNewMessage, CPT_NameColor)) | |
241 | { | |
242 | if(StrEqual(g_strUsernameColor[iAuthor], "G", false)) | |
243 | - | if(iNameColorLength == 6 /* RGB */ |
243 | + | |
244 | - | || iNameColorLength == 8 /* RGBA */ |
244 | + | Format(strNewName, MAXLENGTH_NAME_NEW, "\x04%s", strName); |
245 | - | || StrEqual(strClientNameColor, "T", false) /* Team-Colored */ |
245 | + | |
246 | - | || StrEqual(strClientNameColor, "G", false) /* Green */ |
246 | + | |
247 | - | || StrEqual(strClientNameColor, "O", false) /* Olive */) |
247 | + | |
248 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x05%s", strName); | |
249 | } | |
250 | else if(strlen(g_strUsernameColor[iAuthor]) == 6) | |
251 | - | if(iTextColorLength == 6 /* RGB */ |
251 | + | |
252 | - | || iTextColorLength == 8 /* RGBA */ |
252 | + | Format(strNewName, MAXLENGTH_NAME_NEW, "\x07%s%s", g_strUsernameColor[iAuthor], strName); |
253 | - | || StrEqual(strClientTextColor, "T", false) /* Team-Color */ |
253 | + | |
254 | - | || StrEqual(strClientTextColor, "G", false) /* Green */ |
254 | + | |
255 | - | || StrEqual(strClientTextColor, "O", false) /* Olive */) |
255 | + | |
256 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x08%s%s", g_strUsernameColor[iAuthor], strName); | |
257 | - | strcopy(g_strTextColor[iClient], sizeof(g_strTextColor[]), strClientTextColor); |
257 | + | |
258 | else | |
259 | { | |
260 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x03%s", strName); // team color by default! | |
261 | } | |
262 | - | strcopy(g_strDefaultTextColor[iClient], sizeof(g_strDefaultTextColor[]), g_strTextColor[iClient]); |
262 | + | |
263 | else | |
264 | { | |
265 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x03%s", strName); // team color by default! | |
266 | } | |
267 | if(CheckForward(iAuthor, strNewMessage, CPT_TagColor)) | |
268 | - | public Action OnChatMessage(int& iAuthor, ArrayList hRecipients, eChatFlags& fFlag, char[] strName, char[] strMessage, bool& bProcessColors, bool& bRemoveColors) |
268 | + | |
269 | if(strlen(g_strTag[iAuthor]) > 0) | |
270 | - | bRemoveColors = true; |
270 | + | |
271 | if(StrEqual(g_strTagColor[iAuthor], "T", false)) | |
272 | { | |
273 | - | |
273 | + | Format(strNewName, MAXLENGTH_NAME_NEW, "\x03%s%s", g_strTag[iAuthor], strName); |
274 | - | public void OnChatMessagePost(int iAuthor, ArrayList hRecipients, eChatFlags fFlag, const char[] strName, const char[] strMessage, bool bProcessColors, bool bRemoveColors) |
274 | + | |
275 | else if(StrEqual(g_strTagColor[iAuthor], "G", false)) | |
276 | - | char strNewName[MAXLENGTH_256]; |
276 | + | |
277 | - | strcopy(strNewName, sizeof(strNewName), strName); |
277 | + | Format(strNewName, MAXLENGTH_NAME_NEW, "\x04%s%s", g_strTag[iAuthor], strName); |
278 | - | |
278 | + | |
279 | - | char strNewMessage[MAXLENGTH_256]; |
279 | + | |
280 | - | strcopy(strNewMessage, sizeof(strNewMessage), strMessage); |
280 | + | |
281 | - | |
281 | + | Format(strNewName, MAXLENGTH_NAME_NEW, "\x05%s%s", g_strTag[iAuthor], strName); |
282 | } | |
283 | else if(strlen(g_strTagColor[iAuthor]) == 6) | |
284 | - | if(StrEqual(g_strUsernameColor[iAuthor], "T", false)) |
284 | + | |
285 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x07%s%s%s", g_strTagColor[iAuthor], g_strTag[iAuthor], strName); | |
286 | - | // Team Colored |
286 | + | |
287 | - | Format(strNewName, MAXLENGTH_256, "\x03%s", strNewName); |
287 | + | |
288 | { | |
289 | Format(strNewName, MAXLENGTH_NAME_NEW, "\x08%s%s%s", g_strTagColor[iAuthor], g_strTag[iAuthor], strName); | |
290 | } | |
291 | - | // Green |
291 | + | |
292 | - | Format(strNewName, MAXLENGTH_256, "\x04%s", strNewName); |
292 | + | |
293 | Format(strNewName, MAXLENGTH_NAME_NEW, "%s\x01%s", g_strTag[iAuthor], strName); | |
294 | } | |
295 | } | |
296 | - | // Olive |
296 | + | |
297 | - | Format(strNewName, MAXLENGTH_256, "\x05%s", strNewName); |
297 | + | |
298 | if(strlen(g_strChatColor[iAuthor]) > 0 && CheckForward(iAuthor, strNewMessage, CPT_ChatColor)) | |
299 | { | |
300 | if(StrEqual(g_strChatColor[iAuthor], "T", false)) | |
301 | - | // RGB |
301 | + | |
302 | - | Format(strNewName, MAXLENGTH_256, "\x07%s%s", g_strUsernameColor[iAuthor], strNewName); |
302 | + | Format(strNewMessage, MAXLENGTH_MESSAGE, "\x03%s", strNewMessage); |
303 | } | |
304 | else if(StrEqual(g_strChatColor[iAuthor], "G", false)) | |
305 | { | |
306 | - | // RGBA |
306 | + | Format(strNewMessage, MAXLENGTH_MESSAGE, "\x04%s", strNewMessage); |
307 | - | Format(strNewName, MAXLENGTH_256, "\x08%s%s", g_strUsernameColor[iAuthor], strNewName); |
307 | + | |
308 | else if(StrEqual(g_strChatColor[iAuthor], "O", false)) | |
309 | { | |
310 | Format(strNewMessage, MAXLENGTH_MESSAGE, "\x05%s", strNewMessage); | |
311 | - | // Team-Colored by default |
311 | + | |
312 | - | Format(strNewName, MAXLENGTH_256, "\x03%s", strNewName); |
312 | + | else if(strlen(g_strChatColor[iAuthor]) == 6) |
313 | { | |
314 | Format(strNewMessage, MAXLENGTH_MESSAGE, "\x07%s%s", g_strChatColor[iAuthor], strNewMessage); | |
315 | } | |
316 | else if(strlen(g_strChatColor[iAuthor]) == 8) | |
317 | - | // Team-Colored by default |
317 | + | |
318 | - | Format(strNewName, MAXLENGTH_256, "\x03%s", strNewName); |
318 | + | Format(strNewMessage, MAXLENGTH_MESSAGE, "\x08%s%s", g_strChatColor[iAuthor], strNewMessage); |
319 | } | |
320 | } | |
321 | - | // Check if the tag color string is above 0 characters |
321 | + | |
322 | - | if(strlen(g_strTagColor[iAuthor]) > 0 && CheckForward(iAuthor, strNewMessage, CPT_TagColor)) |
322 | + | |
323 | GetGameFolderName(strGame, sizeof(strGame)); | |
324 | - | // Check if tag length is more than 0 |
324 | + | |
325 | { | |
326 | Format(strName, MAXLENGTH_NAME_NEW, "\x01\x0B%s", strName); | |
327 | - | if(strlen(g_strTagColor[iAuthor]) == 6) |
327 | + | |
328 | ||
329 | - | // RGB |
329 | + | |
330 | - | Format(strNewName, MAXLENGTH_256, "\x07%s%s%s", g_strTagColor[iAuthor], g_strTag[iAuthor], strNewName); |
330 | + | |
331 | Call_PushStringEx(strNewMessage, MAXLENGTH_MESSAGE, SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); | |
332 | Call_PushCell(MAXLENGTH_MESSAGE); | |
333 | - | |
333 | + | |
334 | - | // RGBA |
334 | + | |
335 | - | Format(strNewName, MAXLENGTH_256, "\x08%s%s%s", g_strTagColor[iAuthor], g_strTag[iAuthor], strNewName); |
335 | + | CPrintToChat(iAuthor, "%s{default} : %s", strNewName, strNewMessage); |
336 | } | |
337 | - | else if(StrEqual(g_strTagColor[iAuthor], "T", false)) |
337 | + | |
338 | stock bool CheckForward(int iAuthor, const char[] strMessage, CPT_ColorType tType) | |
339 | - | // Team-Colored |
339 | + | |
340 | - | Format(strNewName, MAXLENGTH_256, "\x03%s%s", g_strTag[iAuthor], strNewName); |
340 | + | |
341 | Call_StartForward(hApplicationForward); | |
342 | Call_PushCell(iAuthor); | |
343 | Call_PushString(strMessage); | |
344 | - | // Green |
344 | + | |
345 | - | Format(strNewName, MAXLENGTH_256, "\x04%s%s", g_strTag[iAuthor], strNewName); |
345 | + | |
346 | if(aResult >= Plugin_Handled) | |
347 | { | |
348 | return false; | |
349 | - | // Olive |
349 | + | |
350 | - | Format(strNewName, MAXLENGTH_256, "\x05%s%s", g_strTag[iAuthor], strNewName); |
350 | + | |
351 | // Compatibility | |
352 | switch(tType) | |
353 | { | |
354 | - | // Default Handling |
354 | + | |
355 | - | Format(strNewName, MAXLENGTH_256, "%s\x03%s", g_strTag[iAuthor], strNewName); |
355 | + | |
356 | return TagForward(iAuthor); | |
357 | } | |
358 | case CPT_NameColor: | |
359 | { | |
360 | return NameForward(iAuthor); | |
361 | - | // Team-Colored by default |
361 | + | |
362 | - | Format(strNewName, MAXLENGTH_256, "%s\x03%s", g_strTag[iAuthor], strNewName); |
362 | + | case CPT_ChatColor: |
363 | { | |
364 | - | |
364 | + | |
365 | - | if(strlen(g_strTextColor[iAuthor]) > 0 && CheckForward(iAuthor, strNewMessage, CPT_TextColor)) |
365 | + | |
366 | } | |
367 | - | if(StrEqual(g_strTextColor[iAuthor], "T", false)) |
367 | + | |
368 | return true; | |
369 | - | // Team-Colored |
369 | + | |
370 | - | Format(strNewMessage, MAXLENGTH_256, "\x03%s", strNewMessage); |
370 | + | |
371 | stock bool ColorForward(int iAuthor) | |
372 | - | else if(StrEqual(g_strTextColor[iAuthor], "G", false)) |
372 | + | |
373 | Action aResult = Plugin_Continue; | |
374 | - | // Green |
374 | + | |
375 | - | Format(strNewMessage, MAXLENGTH_256, "\x04%s", strNewMessage); |
375 | + | |
376 | Call_Finish(aResult); | |
377 | - | else if(StrEqual(g_strTextColor[iAuthor], "O", false)) |
377 | + | |
378 | { | |
379 | - | // Olive |
379 | + | |
380 | - | Format(strNewMessage, MAXLENGTH_256, "\x05%s", strNewMessage); |
380 | + | |
381 | ||
382 | - | else if(strlen(g_strTextColor[iAuthor]) == 6) |
382 | + | |
383 | } | |
384 | - | // RGB |
384 | + | |
385 | - | Format(strNewMessage, MAXLENGTH_256, "\x07%s%s", g_strTextColor[iAuthor], strNewMessage); |
385 | + | |
386 | { | |
387 | - | else if(strlen(g_strTextColor[iAuthor]) == 8) |
387 | + | |
388 | Call_StartForward(hNameForward); | |
389 | - | // RGBA |
389 | + | |
390 | - | Format(strNewMessage, MAXLENGTH_256, "\x08%s%s", g_strTextColor[iAuthor], strNewMessage); |
390 | + | |
391 | if(aResult >= Plugin_Handled) | |
392 | { | |
393 | return false; | |
394 | - | // White by default |
394 | + | |
395 | - | Format(strNewMessage, MAXLENGTH_256, "\x01%s", strNewMessage); |
395 | + | |
396 | return true; | |
397 | } | |
398 | ||
399 | stock bool TagForward(int iAuthor) | |
400 | - | // White by default |
400 | + | |
401 | - | Format(strNewMessage, MAXLENGTH_256, "\x01%s", strNewMessage); |
401 | + | |
402 | Call_StartForward(hTagForward); | |
403 | - | |
403 | + | |
404 | Call_Finish(aResult); | |
405 | if(aResult >= Plugin_Handled) | |
406 | { | |
407 | return false; | |
408 | - | // CS:GO specific name formatting |
408 | + | |
409 | - | Format(strNewName, MAXLENGTH_256, "\x01\x0B%s", strNewName); |
409 | + | |
410 | return true; | |
411 | } | |
412 | - | CPrintToChat(iAuthor, "%s : %s", strNewName, strNewMessage); |
412 | + | |
413 | - | PrintToServer("%s : %s", strNewName, strNewMessage); |
413 | + | |
414 | - | |
414 | + | |
415 | Action aResult = Plugin_Continue; | |
416 | Call_StartForward(hPreLoadedForward); | |
417 | - | Call_PushStringEx(strNewMessage, MAXLENGTH_256, SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); |
417 | + | |
418 | - | Call_PushCell(MAXLENGTH_256); |
418 | + | |
419 | if(aResult >= Plugin_Handled) | |
420 | { | |
421 | return false; | |
422 | } | |
423 | ||
424 | return true; | |
425 | } | |
426 | ||
427 | public int Native_GetColor(Handle hPlugin, int NumParams) | |
428 | { | |
429 | int iClient = GetNativeCell(1); | |
430 | if(iClient < 1 || iClient > MaxClients || !IsClientInGame(iClient)) | |
431 | { | |
432 | ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | |
433 | return COLOR_NONE; | |
434 | } | |
435 | switch(GetNativeCell(2)) | |
436 | { | |
437 | case CPT_TagColor: | |
438 | { | |
439 | if(StrEqual(g_strTagColor[iClient], "T", false)) | |
440 | { | |
441 | SetNativeCellRef(3, false); | |
442 | return COLOR_TEAM; | |
443 | } | |
444 | else if(StrEqual(g_strTagColor[iClient], "G", false)) | |
445 | { | |
446 | - | case CPT_TextColor: |
446 | + | |
447 | return COLOR_GREEN; | |
448 | } | |
449 | else if(StrEqual(g_strTagColor[iClient], "O", false)) | |
450 | { | |
451 | SetNativeCellRef(3, false); | |
452 | return COLOR_OLIVE; | |
453 | } | |
454 | else if(strlen(g_strTagColor[iClient]) == 6 || strlen(g_strTagColor[iClient]) == 8) | |
455 | { | |
456 | SetNativeCellRef(3, strlen(g_strTagColor[iClient]) == 8); | |
457 | return StringToInt(g_strTagColor[iClient], 16); | |
458 | } | |
459 | else | |
460 | { | |
461 | SetNativeCellRef(3, false); | |
462 | return COLOR_NONE; | |
463 | } | |
464 | } | |
465 | case CPT_NameColor: | |
466 | { | |
467 | if(StrEqual(g_strUsernameColor[iClient], "G", false)) | |
468 | { | |
469 | SetNativeCellRef(3, false); | |
470 | return COLOR_GREEN; | |
471 | } | |
472 | else if(StrEqual(g_strUsernameColor[iClient], "O", false)) | |
473 | { | |
474 | SetNativeCellRef(3, false); | |
475 | return COLOR_OLIVE; | |
476 | } | |
477 | else if(strlen(g_strUsernameColor[iClient]) == 6 || strlen(g_strUsernameColor[iClient]) == 8) | |
478 | { | |
479 | SetNativeCellRef(3, strlen(g_strUsernameColor[iClient]) == 8); | |
480 | return StringToInt(g_strUsernameColor[iClient], 16); | |
481 | } | |
482 | else | |
483 | { | |
484 | SetNativeCellRef(3, false); | |
485 | return COLOR_TEAM; | |
486 | } | |
487 | } | |
488 | case CPT_ChatColor: | |
489 | { | |
490 | if(StrEqual(g_strChatColor[iClient], "T", false)) | |
491 | { | |
492 | SetNativeCellRef(3, false); | |
493 | return COLOR_TEAM; | |
494 | } | |
495 | else if(StrEqual(g_strChatColor[iClient], "G", false)) | |
496 | { | |
497 | SetNativeCellRef(3, false); | |
498 | return COLOR_GREEN; | |
499 | } | |
500 | else if(StrEqual(g_strChatColor[iClient], "O", false)) | |
501 | { | |
502 | SetNativeCellRef(3, false); | |
503 | return COLOR_OLIVE; | |
504 | } | |
505 | else if(strlen(g_strChatColor[iClient]) == 6 || strlen(g_strChatColor[iClient]) == 8) | |
506 | { | |
507 | SetNativeCellRef(3, strlen(g_strChatColor[iClient]) == 8); | |
508 | return StringToInt(g_strChatColor[iClient], 16); | |
509 | } | |
510 | else | |
511 | { | |
512 | SetNativeCellRef(3, false); | |
513 | return COLOR_NONE; | |
514 | } | |
515 | } | |
516 | } | |
517 | return COLOR_NONE; | |
518 | } | |
519 | ||
520 | public int Native_SetColor(Handle hPlugin, int iNumParams) | |
521 | { | |
522 | int iClient = GetNativeCell(1); | |
523 | if(iClient < 1 || iClient > MaxClients || !IsClientInGame(iClient)) | |
524 | { | |
525 | ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | |
526 | return false; | |
527 | } | |
528 | char strColor[32]; | |
529 | if(GetNativeCell(3) < 0) | |
530 | { | |
531 | switch(GetNativeCell(3)) | |
532 | { | |
533 | case COLOR_GREEN: | |
534 | { | |
535 | Format(strColor, sizeof(strColor), "G"); | |
536 | } | |
537 | case COLOR_OLIVE: | |
538 | { | |
539 | Format(strColor, sizeof(strColor), "O"); | |
540 | } | |
541 | case COLOR_TEAM: | |
542 | { | |
543 | Format(strColor, sizeof(strColor), "T"); | |
544 | } | |
545 | case COLOR_NONE: | |
546 | { | |
547 | Format(strColor, sizeof(strColor), ""); | |
548 | } | |
549 | } | |
550 | } | |
551 | else | |
552 | { | |
553 | if(!GetNativeCell(4)) | |
554 | { | |
555 | // No alpha | |
556 | Format(strColor, sizeof(strColor), "%06X", GetNativeCell(3)); | |
557 | } | |
558 | else | |
559 | { | |
560 | // Alpha specified | |
561 | Format(strColor, sizeof(strColor), "%08X", GetNativeCell(3)); | |
562 | } | |
563 | } | |
564 | if(strlen(strColor) != 6 && strlen(strColor) != 8 && !StrEqual(strColor, "G", false) && !StrEqual(strColor, "O", false) && !StrEqual(strColor, "T", false)) | |
565 | { | |
566 | return false; | |
567 | } | |
568 | switch(GetNativeCell(2)) | |
569 | { | |
570 | case CPT_TagColor: | |
571 | { | |
572 | - | case CPT_TextColor: |
572 | + | |
573 | } | |
574 | - | if(StrEqual(g_strTextColor[iClient], "T", false)) |
574 | + | |
575 | { | |
576 | strcopy(g_strUsernameColor[iClient], sizeof(g_strUsernameColor[]), strColor); | |
577 | } | |
578 | case CPT_ChatColor: | |
579 | - | else if(StrEqual(g_strTextColor[iClient], "G", false)) |
579 | + | |
580 | strcopy(g_strChatColor[iClient], sizeof(g_strChatColor[]), strColor); | |
581 | } | |
582 | } | |
583 | return true; | |
584 | - | else if(StrEqual(g_strTextColor[iClient], "O", false)) |
584 | + | |
585 | ||
586 | public int Native_GetTag(Handle hPlugin, int iNumParams) | |
587 | { | |
588 | int iClient = GetNativeCell(1); | |
589 | - | else if(strlen(g_strTextColor[iClient]) == 6 || strlen(g_strTextColor[iClient]) == 8) |
589 | + | |
590 | { | |
591 | - | SetNativeCellRef(3, strlen(g_strTextColor[iClient]) == 8); |
591 | + | |
592 | - | return StringToInt(g_strTextColor[iClient], 16); |
592 | + | |
593 | } | |
594 | SetNativeString(2, g_strTag[iClient], GetNativeCell(3)); | |
595 | } | |
596 | ||
597 | public int Native_SetTag(Handle hPlugin, int iNumParams) | |
598 | { | |
599 | int iClient = GetNativeCell(1); | |
600 | if(iClient < 1 || iClient > MaxClients || !IsClientInGame(iClient)) | |
601 | { | |
602 | ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | |
603 | return; | |
604 | } | |
605 | GetNativeString(2, g_strTag[iClient], sizeof(g_strTag[])); | |
606 | } | |
607 | ||
608 | public int Native_ResetColor(Handle hPlugin, int iNumParams) | |
609 | { | |
610 | int iClient = GetNativeCell(1); | |
611 | if(iClient < 1 || iClient > MaxClients || !IsClientInGame(iClient)) | |
612 | { | |
613 | ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | |
614 | return; | |
615 | } | |
616 | switch(GetNativeCell(2)) | |
617 | { | |
618 | case CPT_TagColor: | |
619 | { | |
620 | strcopy(g_strTagColor[iClient], sizeof(g_strTagColor[]), g_strDefaultTagColor[iClient]); | |
621 | } | |
622 | case CPT_NameColor: | |
623 | { | |
624 | strcopy(g_strUsernameColor[iClient], sizeof(g_strUsernameColor[]), g_strDefaultUsernameColor[iClient]); | |
625 | } | |
626 | case CPT_ChatColor: | |
627 | { | |
628 | strcopy(g_strChatColor[iClient], sizeof(g_strChatColor[]), g_strDefaultChatColor[iClient]); | |
629 | } | |
630 | } | |
631 | } | |
632 | ||
633 | public int Native_ResetTag(Handle hPlugin, int iNumParams) | |
634 | { | |
635 | int iClient = GetNativeCell(1); | |
636 | if(iClient < 1 || iClient > MaxClients || !IsClientInGame(iClient)) | |
637 | { | |
638 | ThrowNativeError(SP_ERROR_PARAM, "Invalid client or client is not in game"); | |
639 | return; | |
640 | } | |
641 | strcopy(g_strTag[iClient], sizeof(g_strTag[]), g_strDefaultTag[iClient]); | |
642 | } |