Raised This Month: $12 Target: $400
 3% 

acronym


Post New Thread Reply   
 
Thread Tools Display Modes
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-17-2021 , 02:41   Re: acronym
Reply With Quote #21

Quote:
Originally Posted by iclassdon View Post
This one also disables chat triggers "/" <~~~

Think this plug is a great idea.
I will put a variable to check so it will pass though if there is no acronym.
Updated
__________________
My plugin:
Celena Luna is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 12-17-2021 , 02:55   Re: acronym
Reply With Quote #22

That worked! Noticed something new though. When using the keyword, the players name also shows green instead of representing the team color that player is on.
iclassdon is offline
Send a message via MSN to iclassdon
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-17-2021 , 04:53   Re: acronym
Reply With Quote #23

Quote:
Originally Posted by iclassdon View Post
That worked! Noticed something new though. When using the keyword, the players name also shows green instead of representing the team color that player is on.
PHP Code:
ColorChat(0"!x04%s%s!x01: %s"szNameis_user_alive(id) ? "" " !x01*(DEAD)*!x01"szText); 

PHP Code:
 ColorChat(0"!x03%s%s!x01: %s"szNameis_user_alive(id) ? "" " !x01*(DEAD)*!x01"szText); 
I forgot to change x04 to x01
It should work now
Updated to post #18 too
__________________
My plugin:

Last edited by Celena Luna; 12-17-2021 at 04:54.
Celena Luna is offline
SHIFT0
Senior Member
Join Date: Apr 2021
Location: Palestine
Old 12-17-2021 , 06:57   Re: acronym
Reply With Quote #24

Quote:
Originally Posted by iclassdon View Post
This one also disables chat triggers "/" <~~~

Think this plug is a great idea.
ofc great idea xd
__________________
Thank You For Helps
Discord:
null.#0096
https://www.youtube.com/@NullHere/
SHIFT0 is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 12-17-2021 , 12:37   Re: acronym
Reply With Quote #25

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
ColorChat(0"!x04%s%s!x01: %s"szNameis_user_alive(id) ? "" " !x01*(DEAD)*!x01"szText); 

PHP Code:
 ColorChat(0"!x03%s%s!x01: %s"szNameis_user_alive(id) ? "" " !x01*(DEAD)*!x01"szText); 
I forgot to change x04 to x01
It should work now
Updated to post #18 too
Super! one last thing. Space is needed between name and colon.

i.e.

Current = Player: Good Game !

Game Standard = Player : Good Game !

Edit: It's also doing matching inside already formed words. For example added "ns", "!x04Nice Shot!" We have a trigger called /guns it will replace it with /guNICE Shot! Any workaround for this?

Last edited by iclassdon; 12-17-2021 at 13:26.
iclassdon is offline
Send a message via MSN to iclassdon
SHIFT0
Senior Member
Join Date: Apr 2021
Location: Palestine
Old 12-17-2021 , 12:54   Re: acronym
Reply With Quote #26

Quote:
Originally Posted by iclassdon View Post
Super! one last thing. Space is needed between name and colon.

i.e.

Current = Player: Good Game !

Game Standard = Player : Good Game !
Go here :
null.#0096
I want fix to me errors
__________________
Thank You For Helps
Discord:
null.#0096
https://www.youtube.com/@NullHere/
SHIFT0 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-21-2021 , 08:18   Re: acronym
Reply With Quote #27

Quote:
Originally Posted by iclassdon View Post
Super! one last thing. Space is needed between name and colon.

i.e.

Current = Player: Good Game !

Game Standard = Player : Good Game !

Edit: It's also doing matching inside already formed words. For example added "ns", "!x04Nice Shot!" We have a trigger called /guns it will replace it with /guNICE Shot! Any workaround for this?

Check the slash at the beginning of the sentence and ignore the acronym.

PHP Code:
if (!szText[0])
                return 
PLUGIN_CONTINUE


PHP Code:
if (!szText[0] || szText[0] == '/')
                return 
PLUGIN_CONTINUE
__________________


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.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-21-2021 , 17:39   Re: acronym
Reply With Quote #28

Quote:
Originally Posted by iceeedr View Post
Check the slash at the beginning of the sentence and ignore the acronym.

PHP Code:
if (!szText[0])
                return 
PLUGIN_CONTINUE


PHP Code:
if (!szText[0] || szText[0] == '/')
                return 
PLUGIN_CONTINUE
That's not a valid solution, as guns would still be printed as guNice Shot!
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-21-2021 , 17:54   Re: acronym
Reply With Quote #29

The change I sent was exclusively for his problem, the way to "fix" the plugin would be this:

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 (!
equal(szTextg_ChatKeywords[iPattern][Keyword]))
            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();
            }
        }
    }

But it changes the plugin creator's initial idea, so feel free to come up with a fix and not just criticism.
__________________


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.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-22-2021 , 09:08   Re: acronym
Reply With Quote #30

Quote:
Originally Posted by iceeedr View Post
The change I sent was exclusively for his problem, the way to "fix" the plugin would be this:

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 (!
equal(szTextg_ChatKeywords[iPattern][Keyword]))
            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();
            }
        }
    }

But it changes the plugin creator's initial idea, so feel free to come up with a fix and not just criticism.
I've been working on this the past few days, don't think this is all just criticism, i just told you it wasn't a proper fix, that's it.

What you're sharing wouldn't work aswell as he wants the gg still to be called, even when it's in the middle of a sentence. just using equal isn't enough here.

This was my initial idea:

PHP Code:

if(equali(szTextszAcronym)) // Message and acronym are equal, don't do anymore unnessecary checks.
        
{
            
bContainsAcronym true;
            
replace_all(szTextcharsmax(szText), szAcronymszOutput);

            
log_amx("Acronym and message are equal, replacing %s with %s"szAcronymszOutput);

            break;
        }

        if(
containi(szTextszAcronym)) // Message contains acronym, check if it's a valid one.
        
{
            
formatex(szTempAcronymcharsmax(szTempAcronym), " %s "szAcronym);

            if(!
containi(szTempAcronymszAcronym)) // Invalid acronym.
            
{
                continue;
            }

            
bContainsAcronym true;
        } 
EDIT: After putting some time and effort in it again, i think this should be easy to do if we split up the acronym from the whole line, replace it and put it back into the text line.

Another possibility is checking if the last character of the acronym is EOS || space and first character before the acronym is a space. Been thinking a lot on how to do this, but can't seem to figure it out.
__________________

Last edited by Napoleon_be; 12-22-2021 at 10:52.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 12:01.


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