View Single Post
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-24-2020 , 10:17   Re: [REQ] Word Color
Reply With Quote #9

Quote:
Originally Posted by thEsp View Post
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.
Thanks a lot
alferd is offline