AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Good way to hook the chat? (https://forums.alliedmods.net/showthread.php?t=152753)

dark_style 03-13-2011 13:29

Good way to hook the chat?
 
Hello, guys. I'm looking for good way to hook the chat for this plugin - http://forums.alliedmods.net/showthread.php?t=124688. I'll fully rewritten it with the new hooking way. Thanks advance! :)

nikhilgupta345 03-13-2011 16:32

Re: Good way to hook the chat?
 
Register a clcmd by doing

register_clcmd( "say", "Say_Handler" );

ConnorMcLeod 03-13-2011 17:26

Re: Good way to hook the chat?
 
register_message(get_user_msgid("SayText"), "Message_SayText")

dark_style 03-14-2011 01:09

Re: Good way to hook the chat?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1432824)
register_message(get_user_msgid("SayText"), "Message_SayText")

Thank you. After that I have to do the same things:

PHP Code:

new Messages[192];

read_args(Messages191);
remove_quotes(Messages);

if(!
is_valid_msg(Messages))
        return 
PLUGIN_CONTINUE

or?

ConnorMcLeod 03-14-2011 01:13

Re: Good way to hook the chat?
 
No, you have to think it a way completely different, you don't even have to bother with what was actually written by the player.
If your focus is to use such a plugin, i can post you a version i have, if your focus is to release a plugin, then you have to figure out by yourself.
Anything you have to do is to simulate a channel (string 2) and use %s1 (name), %s2 (what was written), and %s3 (Location in cz with team chat).

dark_style 03-14-2011 01:21

Re: Good way to hook the chat?
 
I want to update the Country Chat plugin, becouse you said that the hook way is not good. Thank you for support, I'll do it myself. :)

ConnorMcLeod 03-14-2011 01:27

Re: Good way to hook the chat?
 
Yes, because you copy/pasted admin chat color plugin by Arion that has bugs.
Hook say and say_team commands can also be a fine method, you just have to make it a good way, now you know the 2 possible methods.

register_message against register_clcmd :

With register_message you won't have to figure out who should receive or not message because you hook all sent messages, you also directly hook message type (say_team, dead say_team, say, dead say, spectator say).
With register_clcmd you hook the command so you just hook it once but you have to manually send all messages that have to be received by players, you have to figure out teams, alives players etc....

For all those arguments, i personnally prefer register_message method, but both are fine.
I won't discuss specifically your plugin here because it has already be done in your thread.

dark_style 03-26-2011 04:03

Re: Good way to hook the chat?
 
...

lis_16 03-26-2011 08:52

Re: Good way to hook the chat?
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Forum info"
#define VERSION "1.0"
#define AUTHOR "lisek"



public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""czek")
    
register_clcmd("say_team""czek")

}


public 
czek(id)
{
    new 
said[192]
    
read_args(said,191)
    if(
contain(said"forum") !=-1){
    
client_print(idprint_chat"Forum naszego serwera")
    }
    else if(
contain(said"Forum") !=-1){
    
client_print(idprint_chat"Forum naszego serwera2")
    } 
    else return 
PLUGIN_HANDLED
    
return PLUGIN_HANDLED


Catch. I hope you know what do with this.

dark_style 03-26-2011 11:27

Re: Good way to hook the chat?
 
I know how to hook the chat with this method, thank you anyways. :)

Btw I tried this:

PHP Code:

public handle_sayid )
{
    static 
szSaid192 ];
    
read_argsszSaidcharsmaxszSaid ) );
    
remove_quotesszSaid );
    
    static 
szName32 ];
    
get_user_nameidszName31 );
    
    
formatszSaid191"[%s] : %s"szNameszSaid );


it isn't working, where's the reason?


All times are GMT -4. The time now is 14:30.

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