Raised This Month: $ Target: $400
 0% 

Get the Content of a Chat Message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KillhemAll
Member
Join Date: Jun 2008
Old 01-05-2009 , 11:30   Get the Content of a Chat Message
Reply With Quote #1

Hi guys,

in my newest script i want to get the content of a chat message. e.g. Someone says noob then the script will return a message that a bad word was said.


How can I do that ?


KillhemAll
__________________

KillhemAll is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 01-05-2009 , 11:57   Re: Get the Content of a Chat Message
Reply With Quote #2

something like this ?


PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New PlugIn"
#define VERSION "1.0"
#define AUTHOR "tuty"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
// Add your code here...
    
register_clcmd("say""handle_say");
    
register_clcmd("say_team""handle_say");
}
public 
handle_say(id)
{
    new 
said[192];
    
read_args(said191);

    
    if(
contain(said"noob"/* && contain(said, "word") && contain(sai, "word2")) */)
    {
        
client_print(idprint_chat"Hey, you are a noob not him xD!");
    }
    return 
PLUGIN_CONTINUE;

__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-05-2009 , 12:14   Re: Get the Content of a Chat Message
Reply With Quote #3

More efficient this way
PHP Code:
#include <amxmodx>

new g_Words[ ][ ] =
{
    
"noob",
    
"amxx",
    
"etc"
};

public 
plugin_init()
{
    
register_clcmd"say""hook_say" );
    
register_clcmd"say_team""hook_say" );
}

public 
hook_sayid )
{
    new 
said192 ];
    
read_argssaidcharsmaxsaid ) );
    
remove_quotessaid );
    
    new 
name32 ];
    
get_user_nameidnamecharsmaxname ) );
    
    for( new 
0sizeof g_Wordsi++ )
    {
        if( 
containisaidg_Words] ) )
            
client_print0print_chat"%s just said a nasty word ;-0"name );
    }
    return 
0;

PS: tuty. you have to use || instead of &&
__________________


Last edited by anakin_cstrike; 01-05-2009 at 12:16.
anakin_cstrike is offline
KillhemAll
Member
Join Date: Jun 2008
Old 01-09-2009 , 11:52   Re: Get the Content of a Chat Message
Reply With Quote #4

Thank you all +Karma . There should be more people like you thx
__________________

KillhemAll is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-09-2009 , 15:47   Re: Get the Content of a Chat Message
Reply With Quote #5

If you're going for ultramax efficiency, you may want to add a secondary handle_say type function to implement string slicing, that way you can hack off the "say " part of the said[] string. If you have a huge list of bad words to check against, I can imagine it would be checking those first four irrelevant cells countless times.

...or "say_team" for the say_team one.

Also, not sure there's a reason to use a charsmax function when you just defined how large the array was and could easily type it in...
__________________

Last edited by Bad_Bud; 01-09-2009 at 15:51.
Bad_Bud is offline
Reply



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 09:11.


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