Raised This Month: $ Target: $400
 0% 

Help With more than 1 word chat detect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MegaBeach
Junior Member
Join Date: May 2013
Old 05-24-2013 , 17:23   Help With more than 1 word chat detect
Reply With Quote #1

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;
}
MegaBeach is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-25-2013 , 00:29   Re: Help With more than 1 word chat detect
Reply With Quote #2

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;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MegaBeach
Junior Member
Join Date: May 2013
Old 05-25-2013 , 09:04   Re: Help With more than 1 word chat detect
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
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 is offline
MegaBeach
Junior Member
Join Date: May 2013
Old 05-25-2013 , 11:31   Re: Help With more than 1 word chat detect
Reply With Quote #4

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 ?
MegaBeach is offline
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 05-25-2013 , 11:42   Re: Help With more than 1 word chat detect
Reply With Quote #5

Try equali.
PHP Code:
if( equal(szArgs"hey dsc")) 
->
PHP Code:
if( equali(szArgs"hey dsc")) 
11922911 is offline
MegaBeach
Junior Member
Join Date: May 2013
Old 05-25-2013 , 12:30   Re: Help With more than 1 word chat detect
Reply With Quote #6

Quote:
Originally Posted by 11922911 View Post
Try equali.
PHP Code:
if( equal(szArgs"hey dsc")) 
->
PHP Code:
if( equali(szArgs"hey dsc")) 
Thanks !
MegaBeach is offline
MegaBeach
Junior Member
Join Date: May 2013
Old 06-02-2013 , 12:10   Re: Help With more than 1 word chat detect
Reply With Quote #7

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).
MegaBeach is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-02-2013 , 12:48   Re: Help With more than 1 word chat detect
Reply With Quote #8

Quote:
Originally Posted by MegaBeach View Post
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.
__________________
fysiks is offline
MegaBeach
Junior Member
Join Date: May 2013
Old 06-02-2013 , 12:55   Re: Help With more than 1 word chat detect
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
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...
MegaBeach is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-02-2013 , 14:03   Re: Help With more than 1 word chat detect
Reply With Quote #10

You cannot get player binds
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou 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 16:24.


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