AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Word Color (https://forums.alliedmods.net/showthread.php?t=325401)

alferd 06-20-2020 14:07

[REQ] Word Color
 
I want a plugin that someone has written the word "mr" in the message
The color of the word "mr" should be white

Image:
http://rozup.ir/view/3160966/9.jpg

http://rozup.ir/view/3160973/10.jpg

thEsp 06-20-2020 14:23

Re: [REQ] Word Color
 
1. Create a 2-dimensional array where you have the desired match (e.g "mr") and desired modification (e.g "&x04mr").
2. When a client says something loop through that array and check if the said text matches any pattern.
3. If it does: replace the message, print it to all players/teammates and return PLUGIN_HANDLED.

alferd 06-21-2020 02:27

Re: [REQ] Word Color
 
Quote:

Originally Posted by thEsp (Post 2706582)
1. Create a 2-dimensional array where you have the desired match (e.g "mr") and desired modification (e.g "&x04mr").
2. When a client says something loop through that array and check if the said text matches any pattern.
3. If it does: replace the message, print it to all players/teammates and return PLUGIN_HANDLED.

But I don't know exactly what code to use, And I ask you for help
The image you see was possible with the following plugin


Code:
#include <amxmodx> #include <amxmisc> #include <cromchat> #define PLUGIN   "Word Color" #define VERSION     "1.0" #define AUTHOR   "author" new message[192] new strName[191] new strText[191] new alive[11] public plugin_init() {     register_plugin (PLUGIN, VERSION, AUTHOR)         register_clcmd ("say", "cmdSay") } public cmdSay(id) {     new message[192], name[32], players[32], isAlive     read_args(message, 191)     remove_quotes(message)     get_user_name(id, name, 31)         if (is_user_alive (id))         {             isAlive = 1             alive = "^x01"         }     else         {             isAlive = 0             alive = "^x01*DEAD* "         }     CC_SendMessage(0, "%s&x05%s &x01:  &x04%s", alive, name, message[1])         return PLUGIN_HANDLED; }

Code:

say hHello &x05Mr = For Image 1
say hHello &x05Mr&x04 King | Good Game &x05mr = for Image 2

I don't want the player to add this text ( &x05mr&x04 )
:)

( I need to send this post to the Scripting Help section?? )

Relaxing 06-21-2020 03:49

Re: [REQ] Word Color
 
Set case sensitive to false and search for " mr " and replace that with " &x05Mr ".
http://amxmodx.org/api/string/replace_stringex

alferd 06-21-2020 04:28

Re: [REQ] Word Color
 
Quote:

Originally Posted by Relaxing (Post 2706659)
Set case sensitive to false and search for " mr " and replace that with " &x05Mr ".
http://amxmodx.org/api/string/replace_stringex

PHP Code:

replace_string(saidmessage"Mr""&x05Mr&x04"1

??

Relaxing 06-21-2020 05:44

Re: [REQ] Word Color
 
Code:
replace_string(message, charsmax(message), " mr ", " &x05Mr&x04 ", false)

thEsp 06-21-2020 07:03

Re: [REQ] Word Color
 
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; }
https://i.imgur.com/6RqvXz8.png
Take in mind this is just an example and there are other flaws.

iceeedr 06-21-2020 14:58

Re: [REQ] Word Color
 
Remembering that this does not guarantee that "mr" is white, as the player may very well use con_color "r g b", and "white" can be any color that he has configured.

alferd 06-24-2020 10:17

Re: [REQ] Word Color
 
Quote:

Originally Posted by thEsp (Post 2706679)
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; }
https://i.imgur.com/6RqvXz8.png
Take in mind this is just an example and there are other flaws.

Thanks a lot:)


All times are GMT -4. The time now is 02:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.