View Single Post
thEsp
BANNED
Join Date: Aug 2017
Old 06-21-2020 , 07:03   Re: [REQ] Word Color
Reply With Quote #7

Code:
#include <amxmodx> #define MAX_SAY_TEXT_LEN 128 #define MAX_KEYWORD_LEN 32 #define MAX_HIGHLIGHT_LEN 32 enum Match {     Keyword[MAX_KEYWORD_LEN],     Highlight[MAX_HIGHLIGHT_LEN] }; new g_ChatKeywords[][Match] = {     {"Relaxing", "^4Rela^3x^4ing"} }; public plugin_init() {     register_clcmd("say", "@OnCmd_Say"); } @OnCmd_Say(id) {     new szText[MAX_SAY_TEXT_LEN];     read_args(szText, charsmax(szText));     remove_quotes(szText);     trim(szText);     if (!szText[0])         return PLUGIN_CONTINUE;     for (new iPattern = 0, szHighlight[MAX_HIGHLIGHT_LEN], iPatterns = sizeof(g_ChatKeywords); iPattern < iPatterns; iPattern++)     {         if (containi(szText, g_ChatKeywords[iPattern][Keyword]) == -1)             continue;         format(szHighlight, charsmax(szHighlight), "%s^1", g_ChatKeywords[iPattern][Highlight]);         replace_all(szText, charsmax(szText), g_ChatKeywords[iPattern][Keyword], szHighlight);     }     // %n was added on 1.9, but it directly parses a certain client's name.     client_print_color(0, id, "^3%n%s^1: %s", id, is_user_alive(id) ? "" : " ^1*(DEAD)*^1", szText);     return PLUGIN_HANDLED; }

Take in mind this is just an example and there are other flaws.

Last edited by thEsp; 06-21-2020 at 07:05.
thEsp is offline