AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help With more than 1 word chat detect (https://forums.alliedmods.net/showthread.php?t=216713)

MegaBeach 05-24-2013 17:23

Help With more than 1 word chat detect
 
Hey,
I have a code for a plugin that i made,
I need to detect a word that a player need to say, and if the player says the word he will win.
But... if the word that the player need to say is built from more than 1word, so it not detect it.
I mean that the 1word working fine, but more than 1 word it not detect it fine.

the part of the code:
Code:

public sayheydsc(id)
{
 new szMsg[ 192 ], Arg[ 38 ];
 read_argv( 1, szMsg, charsmax ( szMsg ) )
 parse( szMsg, Arg, charsmax ( Arg ))

 if( equal(Arg, "hey dsc"))
 {
  ColorChat(id, NORMAL, "Winner")
 }
 return PLUGIN_CONTINUE;
}


ConnorMcLeod 05-25-2013 00:29

Re: Help With more than 1 word chat detect
 
Use read_args.

PHP Code:

#include < amxmodx >
#include < colorchat >

public plugin_init()
{

    
register_clcmd("say""Host_Say"0);
    
register_clcmd("say_team""Host_Say"1);
}

public 
Host_Say(idteamonly)
{
    new 
szArgs[192];
    
read_args(szArgscharsmax(szArgs));
    
remove_quotes(szArgs);

    if( !
IsChatValid(szArgs) )
    {
        return 
PLUGIN_CONTINUE;
    }

    
// your code here
    
if( equal(szArgs"hey dsc"))
    {
        
ColorChat(idNORMAL"Winner");
        return 
PLUGIN_CONTINUE;
    }

    return 
PLUGIN_CONTINUE;
}

IsChatValid( const szChat[] )
{
    new 
cChariCharCounter;
    while ( ( 
cChar szChatiCharCounter++ ] ) != EOS )
    {
        if ( 
cChar != ' ' )
        {
            return 
1;
        }
    }
    return 
0;



MegaBeach 05-25-2013 09:04

Re: Help With more than 1 word chat detect
 
Quote:

Originally Posted by ConnorMcLeod (Post 1957944)
Use read_args.

PHP Code:

#include < amxmodx >
#include < colorchat >

public plugin_init()
{

    
register_clcmd("say""Host_Say"0);
    
register_clcmd("say_team""Host_Say"1);
}

public 
Host_Say(idteamonly)
{
    new 
szArgs[192];
    
read_args(szArgscharsmax(szArgs));
    
remove_quotes(szArgs);

    if( !
IsChatValid(szArgs) )
    {
        return 
PLUGIN_CONTINUE;
    }

    
// your code here
    
if( equal(szArgs"hey dsc"))
    {
        
ColorChat(idNORMAL"Winner");
        return 
PLUGIN_CONTINUE;
    }

    return 
PLUGIN_CONTINUE;
}

IsChatValid( const szChat[] )
{
    new 
cChariCharCounter;
    while ( ( 
cChar szChatiCharCounter++ ] ) != EOS )
    {
        if ( 
cChar != ' ' )
        {
            return 
1;
        }
    }
    return 
0;



Thank you Connor !
Works great ! :)

MegaBeach 05-25-2013 11:31

Re: Help With more than 1 word chat detect
 
Hey sorry but there is a problem.
If the word that the player need to say is for example "hey dsc"
So if the player says it different by capital letter/small letters "HeY DsC" / "heY dsC" Etc...
So It's not detecting it, can be fix ?

11922911 05-25-2013 11:42

Re: Help With more than 1 word chat detect
 
Try equali.
PHP Code:

if( equal(szArgs"hey dsc")) 

->
PHP Code:

if( equali(szArgs"hey dsc")) 


MegaBeach 05-25-2013 12:30

Re: Help With more than 1 word chat detect
 
Quote:

Originally Posted by 11922911 (Post 1958230)
Try equali.
PHP Code:

if( equal(szArgs"hey dsc")) 

->
PHP Code:

if( equali(szArgs"hey dsc")) 


Thanks ! :)

MegaBeach 06-02-2013 12:10

Re: Help With more than 1 word chat detect
 
Hey again,
I'm having a little problem on this message detect.
I use it for a plugin that I made that would play a song, and the first player
who writes the song name wins.
but now all players do binds (bind x "say rain over me").
And they wining fast by cheating, is there a way that it will detect the message
only if it was write by a messagemode ? (when you press "y" and write something).

fysiks 06-02-2013 12:48

Re: Help With more than 1 word chat detect
 
Quote:

Originally Posted by MegaBeach (Post 1963131)
Hey again,
I'm having a little problem on this message detect.
I use it for a plugin that I made that would play a song, and the first player
who writes the song name wins.
but now all players do binds (bind x "say rain over me").
And they wining fast by cheating, is there a way that it will detect the message
only if it was write by a messagemode ? (when you press "y" and write something).

No.

Play different songs and this won't happen.

MegaBeach 06-02-2013 12:55

Re: Help With more than 1 word chat detect
 
Quote:

Originally Posted by fysiks (Post 1963143)
No.

Play different songs and this won't happen.

Oh...
So if there isn't a way to detect by a messagemode,
maybe there's a way to detect if player have a specific bind (as - bind x "say rain over me" and more)
and if so. it will block this bind, or something else that can help by detecting this bind.

btw, i'm using 20-30 songs, just need a help to block this people from doing those binds...

YamiKaitou 06-02-2013 14:03

Re: Help With more than 1 word chat detect
 
You cannot get player binds


All times are GMT -4. The time now is 16:24.

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