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

Solved code Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 01-01-2021 , 08:41   code Problem
Reply With Quote #1

Hi. I have This code. This code detects the sentences I want in the chat and does something. But the problem is that if there is a space in a sentence, the code can not recognize it. This code only recognizes words and is not able to recognize sentences. This is my first problem. The second problem is that this code only recognizes words sent by users. I want, for example, if the server also sends words in the chat, the code can recognize it. Is this possible? Thanks.
Code :
PHP Code:
public ChatGlobalCommand(id)
{
    static 
lastsaid[512], said[512]
    
read_args(said512)
    if(
equal(saidlastsaid))
        return 
PLUGIN_CONTINUE
        
    
for(new 0sizeof BAD_WORDSi++)
    {
        if(
containi(saidBAD_WORDS[i]))
            
replace_all(saidcharsmax(said), BAD_WORDS[i], "***")    
    }
    
formatex(lastsaidcharsmax(lastsaid), "%s"said)
    
client_cmd(id"say %s"said)
    return 
PLUGIN_HANDLED


Last edited by ho83; 01-05-2021 at 07:22.
ho83 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-01-2021 , 09:20   Re: code Problem
Reply With Quote #2

Show plugin_init
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 01-01-2021 , 09:36   Re: code Problem
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Show plugin_init
Thanks for reply
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "work"
#define VERSION "1.0"
#define AUTHOR "RateX"

new BAD_WORDS[][] = 
{
    
// Add the bad words here. Ex:
    
"Today is Gang War Day, Given By",
    
"ass"
}

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say ""ChatGlobalCommand")
}

public 
ChatGlobalCommand(id)
{
    static 
lastsaid[512], said[512]
    
read_args(said512)
    if(
equal(saidlastsaid))
        return 
PLUGIN_CONTINUE
        
    
for(new 0sizeof BAD_WORDSi++)
    {
        if(
containi(saidBAD_WORDS[i]))
            
replace_all(saidcharsmax(said), BAD_WORDS[i], "***")    
    }
    
formatex(lastsaidcharsmax(lastsaid), "%s"said)
    
client_cmd(id"say %s"said)
    return 
PLUGIN_HANDLED


Last edited by ho83; 01-01-2021 at 09:37.
ho83 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-01-2021 , 11:43   Re: code Problem
Reply With Quote #4

Try this
Code:
public ChatGlobalCommand(id) {     static lastsaid[512], said[512] , iPos;     read_args(said, 512)         if(equal(said, lastsaid))         return PLUGIN_CONTINUE         for ( new i = 0 ; i < sizeof BAD_WORDS ; i++ )     {
        //The return value of containi() cannot be used as a bool since it returns -1 (true) if nothing is found. Always use != -1, > -1, or >= 0
        if ( ( iPos = containi( said , BAD_WORDS[i] ) ) > -1 )
        {
            //Replaced replace_all() with setc() to fill in bad word chars with *
            setc( said[ iPos ] , strlen( BAD_WORDS[ i ] ) , '*' );             //replace_all( said , charsmax( said ) , BAD_WORDS[i] , "***")         }     }         formatex(lastsaid, charsmax(lastsaid), "%s", said)     client_cmd(id, "say %s", said)         return PLUGIN_HANDLED }
__________________
Bugsy is offline
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 01-01-2021 , 12:07   Re: code Problem
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Try this
Code:
public ChatGlobalCommand(id) {     static lastsaid[512], said[512] , iPos;     read_args(said, 512)         if(equal(said, lastsaid))         return PLUGIN_CONTINUE         for ( new i = 0 ; i < sizeof BAD_WORDS ; i++ )     {
        //The return value of containi() cannot be used as a bool since it returns -1 (true) if nothing is found. Always use != -1, > -1, or >= 0
        if ( ( iPos = containi( said , BAD_WORDS[i] ) ) > -1 )
        {
            //Replaced replace_all() with setc() to fill in bad word chars with *
            setc( said[ iPos ] , strlen( BAD_WORDS[ i ] ) , '*' );             //replace_all( said , charsmax( said ) , BAD_WORDS[i] , "***")         }     }         formatex(lastsaid, charsmax(lastsaid), "%s", said)     client_cmd(id, "say %s", said)         return PLUGIN_HANDLED }
Thank you dear. Can you change this code to work only for messages sent by the server?
For example, when the server said in chat "Today is Gang WarDay" plugin do this : server_cmd("amx_omenu 1")

Thanks
ho83 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-01-2021 , 18:24   Re: code Problem
Reply With Quote #6

Quote:
Originally Posted by ho83 View Post
Thank you dear. Can you change this code to work only for messages sent by the server?
For example, when the server said in chat "Today is Gang WarDay" plugin do this : server_cmd("amx_omenu 1")
That seems like an entirely different plugin/request. Also, it would be best if you simply edit the plugin that sends this message to do what you want. Also, if the server is sending the message, who are you expecting to get the amxmodmenu?
__________________

Last edited by fysiks; 01-01-2021 at 19:18.
fysiks is offline
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 08:03.


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