AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   word 3x in a row (https://forums.alliedmods.net/showthread.php?t=147440)

JocAnis 01-09-2011 09:52

word 3x in a row
 
hi, how to detect if player say same word three times in a row?

exemple:

JocA:hi guys
klsda:hi
kekesl:hi
JocA:hi guys
pqwr:hi pro
dal;:what
JocA:hi guys

And JocA will be that player...

xakintosh 01-09-2011 09:57

Re: word 3x in a row
 
I think you must save the every message every player witch is send and then check it for equal "message" or something like that ? :)

nikhilgupta345 01-09-2011 10:08

Re: word 3x in a row
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

new gSavedSay[33][256];
new 
gAmountSame[33];
public 
plugin_init()
{
    
register_clcmd"say""cmdSay" );
    
register_clcmd"say_team""cmdSay" );
}

public 
cmdSayid )
{
    new 
message[256];
    
read_argsmessagecharsmaxmessage ) );
    if( 
gAmountSame[id] == )
        
copymessage255gSavedSay[id], 255 );
    
    else if( 
equalmessagegSavedSay[id] ) )
    {
        
gAmountSame[id]++;
        
        if( 
gAmountSame 2  )
        {
            new 
name[32];
            
get_user_nameidname31 );

            
client_print0"%s has said the same thing 3 times in a row!"name );
        }
    }

    return 
PLUGIN_HANDLED;


Try that.

JocAnis 01-09-2011 10:46

Re: word 3x in a row
 
Quote:

Originally Posted by nikhilgupta345 (Post 1389759)
PHP Code:

#include <amxmodx>
#include <amxmisc>

new gSavedSay[33][256];
new 
gAmountSame[33];
public 
plugin_init()
{
    
register_clcmd"say""cmdSay" );
    
register_clcmd"say_team""cmdSay" );
}

public 
cmdSayid )
{
    new 
message[256];
    
read_argsmessagecharsmaxmessage ) );
    if( 
gAmountSame[id] == )
        
copymessage255gSavedSay[id], 255 );
    
    else if( 
equalmessagegSavedSay[id] ) )
    {
        
gAmountSame[id]++;
        
        if( 
gAmountSame 2  )
        {
            new 
name[32];
            
get_user_nameidname31 );

            
client_print0"%s has said the same thing 3 times in a row!"name );
        }
    }

    return 
PLUGIN_HANDLED;


Try that.

tnx, but errors in compiling..:|

Xalus 01-09-2011 10:52

Re: word 3x in a row
 
Some fixes,
and added: If he says another word, it saves that..

PHP Code:

#include <amxmodx>
#include <amxmisc>

new gSavedSay[33][256];
new 
gAmountSame[33];

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

public 
cmdSayid ) {
    new 
message[256];
    
read_argsmessagecharsmaxmessage ) );

    if( 
equalmessagegSavedSay[id] ) ) {
        
gAmountSame[id]++;
        
        if( 
gAmountSame[id] > 2  ) {
            new 
name[32]; get_user_nameidname31 );
            
            
client_print0print_chat"[Spam] %s has said the same thing 3 times in a row!"name );
        }
    }
    else {
        
gAmountSame[id] = 0
        copy
message255gSavedSay[id] );
    }
    return 
PLUGIN_HANDLED;



nikhilgupta345 01-09-2011 10:56

Re: word 3x in a row
 
Need to reset gAmountSame to 1 in the else.

Xalus 01-09-2011 10:58

Re: word 3x in a row
 
To 0 U mean,
ye I edit

[Edit]

FIXED

nikhilgupta345 01-09-2011 11:00

Re: word 3x in a row
 
Wouldn't it be to 1, because that would be the first time he said it, then if he says it again that means he said the same thing twice. So I think it should be 1 right?

JocAnis 01-09-2011 11:02

Re: word 3x in a row
 
Quote:

Originally Posted by Xalus (Post 1389780)
Some fixes,
and added: If he says another word, it saves that..

PHP Code:

#include <amxmodx>
#include <amxmisc>

new gSavedSay[33][256];
new 
gAmountSame[33];

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

public 
cmdSayid ) {
    new 
message[256];
    
read_argsmessagecharsmaxmessage ) );

    if( 
equalmessagegSavedSay[id] ) ) {
        
gAmountSame[id]++;
        
        if( 
gAmountSame[id] > 2  ) {
            new 
name[32]; get_user_nameidname31 );
            
            
client_print0print_chat"[Spam] %s has said the same thing 3 times in a row!"name );
        }
    }
    else {
        
gAmountSame[id] = 0
        copy
message255gSavedSay[id] );
    }
    return 
PLUGIN_HANDLED;



with this, chat is blocked :|

nikhilgupta345 01-09-2011 11:03

Re: word 3x in a row
 
return PLUGIN_CONTINUE instead of HANDLED


All times are GMT -4. The time now is 02:06.

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