Raised This Month: $2 Target: $400
 0% 

[REQ] Word Color


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alferd
Senior Member
Join Date: Dec 2019
Old 06-20-2020 , 14:07   [REQ] Word Color
Reply With Quote #1

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

Image:



Last edited by alferd; 06-20-2020 at 14:11.
alferd is online now
thEsp
Veteran Member
Join Date: Aug 2017
Location: Land of Eagles
Old 06-20-2020 , 14:23   Re: [REQ] Word Color
Reply With Quote #2

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.

Last edited by thEsp; 06-20-2020 at 17:05. Reason: typo
thEsp is offline
alferd
Senior Member
Join Date: Dec 2019
Old 06-21-2020 , 02:27   Re: [REQ] Word Color
Reply With Quote #3

Quote:
Originally Posted by thEsp View Post
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?? )

Last edited by alferd; 06-21-2020 at 02:29.
alferd is online now
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: Catlands
Old 06-21-2020 , 03:49   Re: [REQ] Word Color
Reply With Quote #4

Set case sensitive to false and search for " mr " and replace that with " &x05Mr ".
http://amxmodx.org/api/string/replace_stringex
__________________

Last edited by Relaxing; 06-21-2020 at 03:50. Reason: C
Relaxing is offline
alferd
Senior Member
Join Date: Dec 2019
Old 06-21-2020 , 04:28   Re: [REQ] Word Color
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
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
??
alferd is online now
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: Catlands
Old 06-21-2020 , 05:44   Re: [REQ] Word Color
Reply With Quote #6

Code:
replace_string(message, charsmax(message), " mr ", " &x05Mr&x04 ", false)
__________________
Relaxing is offline
thEsp
Veteran Member
Join Date: Aug 2017
Location: Land of Eagles
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
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 06-21-2020 , 14:58   Re: [REQ] Word Color
Reply With Quote #8

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.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
iceeedr is offline
Send a message via Skype™ to iceeedr
alferd
Senior Member
Join Date: Dec 2019
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 online now
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:32.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode