Raised This Month: $ Target: $400
 0% 

Problem with hook_say


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ex3cuTioN
Member
Join Date: May 2010
Old 07-10-2010 , 04:41   Problem with hook_say
Reply With Quote #1

LOL

Every word i say in chat, me or a random player takes like command in console.

If i write in chat "slay player" it will write in my console "amx_slay player" and works for any random player.
If i write in chat "lol_why_is_not_working" it will write in my console "amx_lol_why_is_not_working"

But i have the "if" in my hook_say, i want only to check if he says /goto or /go

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say","hook_say");
    
register_clcmd("amx_goto","cmdGOTO");
    
register_clcmd("amx_go","cmdGOTO");
}

public 
hook_say(id) {
    new 
s_Args[192];
    
    
read_args(s_Argssizeof(s_Args) - 1);
    
remove_quotes(s_Args);
    
    if(
equal(s_Args"/goto"5) || (s_Args,"/go",3)) {
        
replace(s_Argssizeof(s_Args) - 1"/""");
        
client_cmd(id"amx_%s"s_Args);
    }
    
    return 
PLUGIN_CONTINUE;

LATER EDIT :

I solved the problem, but i have a question.

Q : How could i make only 1 if ?

PHP Code:
public hook_say(id) {
    static 
s_Args[192];
    
    
read_args(s_Argssizeof(s_Args) - 1);
    
remove_quotes(s_Args);
    
    if(
equal(s_Args"/goto"5)) {
        
replace(s_Argssizeof(s_Args) - 1"/""");
        
client_cmd(id"amx_%s"s_Args);
    }
    else if(
equal(s_Args,"/go",3)) {
        
replace(s_Argssizeof(s_Args) - 1"/""");
        
client_cmd(id"amx_%s"s_Args);
    }
    
    return 
PLUGIN_CONTINUE;


Last edited by Ex3cuTioN; 07-10-2010 at 04:46.
Ex3cuTioN is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-10-2010 , 04:53   Re: Problem with hook_say
Reply With Quote #2

Read arg 1 instead of args, then you don't need to remove quotes.
And do the 2 equal checks in the same line (you forgot 'equal' in your 1st code) :

PHP Code:
public hook_say(id)
{
    static 
szSaid[192];

    
read_argv(1szSaidcharsmax(szSaid));

    if( 
equal(szSaid"/goto"5) || equal(szSaid"/go"3) )
    {
        
client_cmd(id"amx_%s"szSaid[1]);
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-10-2010 at 04:55.
ConnorMcLeod is offline
Ex3cuTioN
Member
Join Date: May 2010
Old 07-10-2010 , 04:56   Re: Problem with hook_say
Reply With Quote #3

It works

Thank you
Ex3cuTioN 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 07:06.


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