Thread: acronym
View Single Post
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-16-2021 , 21:13   Re: acronym
Reply With Quote #18

Quote:
Originally Posted by iceeedr View Post
Code:
ColorChat(0, "!x04%n%s!x01: %s", id, is_user_alive(id) ? "" : " !x01*(DEAD)*!x01", szText);
You forgot to redo %n to 1.8.2.

And replacing !x01
Thanks for pointing that out

@SHIFT0 Another try
- %n fix

#Update 1:
- Forgot to remove id in Color Chat

#Update 2:
- Adding a variable to check to not break any trigger.

#Update 3
- Making player name back to team color

PHP 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] =
{
    {
"gg""!x04Good Game !"}, //!x01 is yellow color | !x03 is team color | !x04 is green color
    
{"slm""!x04Slam Alikom"}
};

new 
g_msgSayText;

public 
plugin_init()
{
    
register_clcmd("say""@OnCmd_Say");
    
g_msgSayText get_user_msgid("SayText")
}

@
OnCmd_Say(id)
{
    new 
szText[MAX_SAY_TEXT_LEN];
    new 
HasAcronym;
    
read_args(szTextcharsmax(szText));

    
remove_quotes(szText);
    
trim(szText);

    if (!
szText[0])
        return 
PLUGIN_CONTINUE;

    for (new 
iPattern 0szHighlight[MAX_HIGHLIGHT_LEN], iPatterns sizeof(g_ChatKeywords); iPattern iPatternsiPattern++)
    {
        if (
containi(szTextg_ChatKeywords[iPattern][Keyword]) == -1)
            continue;

        if(!
HasAcronymHasAcronym 1

        format
(szHighlightcharsmax(szHighlight), "%s^1"g_ChatKeywords[iPattern][Highlight]);
        
replace_all(szTextcharsmax(szText), g_ChatKeywords[iPattern][Keyword], szHighlight);
    }

    if(!
HasAcronym)
        return 
PLUGIN_CONTINUE
        
    
// %n was added on 1.9, but it directly parses a certain client's name.
    
new szName[64]
    
get_user_name(idszNamecharsmax(szName))
    
ColorChat(0"!x03%s%s!x01: %s"szNameis_user_alive(id) ? "" " !x01*(DEAD)*!x01"szText);
    return 
PLUGIN_HANDLED;

    
stock ColorChat(const id, const input[], any:...) {
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!x04""^4");
    
replace_all(msg190"!x03""^3");
    
replace_all(msg190"!x01""^1");
    
    if(
idplayers[0] = id;
    else 
get_players(playerscount"ch"); {
        for(new 
0counti++) {
            if(
is_user_connected(players[i])) {
                
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

__________________
My plugin:

Last edited by Celena Luna; 12-17-2021 at 04:51. Reason: iceeedr's and iclassdon's pointed out. Updated #3
Celena Luna is offline