Raised This Month: $51 Target: $400
 12% 

Good way to hook the chat?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-13-2011 , 13:29   Good way to hook the chat?
Reply With Quote #1

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!
dark_style is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 03-13-2011 , 16:32   Re: Good way to hook the chat?
Reply With Quote #2

Register a clcmd by doing

register_clcmd( "say", "Say_Handler" );
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-13-2011 , 17:26   Re: Good way to hook the chat?
Reply With Quote #3

register_message(get_user_msgid("SayText"), "Message_SayText")
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-14-2011 , 01:09   Re: Good way to hook the chat?
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
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?
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-14-2011 , 01:13   Re: Good way to hook the chat?
Reply With Quote #5

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).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-14-2011 , 01:21   Re: Good way to hook the chat?
Reply With Quote #6

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.

Last edited by dark_style; 03-14-2011 at 01:26.
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-14-2011 , 01:27   Re: Good way to hook the chat?
Reply With Quote #7

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-14-2011 at 01:33.
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-26-2011 , 04:03   Re: Good way to hook the chat?
Reply With Quote #8

...

Last edited by dark_style; 03-26-2011 at 06:11. Reason: nvm
dark_style is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 03-26-2011 , 08:52   Re: Good way to hook the chat?
Reply With Quote #9

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.
lis_16 is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-26-2011 , 11:27   Re: Good way to hook the chat?
Reply With Quote #10

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?

Last edited by dark_style; 03-26-2011 at 11:55.
dark_style 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 23:58.


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