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

Good way to hook the chat?


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-26-2011 , 12:19   Re: Good way to hook the chat?
Reply With Quote #11

Code works fine but you don't understand what you are doing.
You only format a string.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 03-26-2011 , 12:41   Re: Good way to hook the chat?
Reply With Quote #12

But he format szSaid and he wanna to use szSaid as string in format, it's wrong i think.

PHP Code:
public handle_sayid )
{
    static 
szSaid192 ], szSaid2[192];
    
read_argsszSaidcharsmaxszSaid ) );
    
remove_quotesszSaid );
    
    static 
szName32 ];
    
get_user_nameidszName31 );
    
    
formatszSaid2191"[%s] : %s"szNameszSaid );
    
client_print(0print_chat"%s"szSaid2);

lis_16 is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-26-2011 , 12:55   Re: Good way to hook the chat?
Reply With Quote #13

Lis, thank you. I understood how it works.

Here is working code:

PHP Code:
public handle_sayid )
{
    static 
szSaid64 ];
    
read_argsszSaidcharsmaxszSaid ) );
    
remove_quotesszSaid );
    
    static 
szName32 ];
    
get_user_nameidszName31 );
    
    
client_print0print_chat"[%s] : %s"szNameszSaid );

dark_style is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-02-2012 , 01:32   Re: Good way to hook the chat?
Reply With Quote #14

Hello again! Since I stopped scripting before I stopped looking for method, when I returned I found this method - http://forums.alliedmods.net/showpos...53&postcount=7 . It looks very clean and good method, but I can't understand it... I have tried few times to use it and got no good results... This is what I have tried :

PHP Code:
#include <amxmodx>

#define MAX_PLAYERS    32

new g_aPlayers[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin("Test""0.0.1""ConnorMcLeod")
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}

public 
Message_SayText()
{
    new 
id get_msg_arg_int(1)
    
    new 
szChannel[40]
    
get_msg_arg_string(2szChannelcharsmax(szChannel))
    
    if(
equal(szChannel"Cstrike_Chat"13))
    {
        if(
equal(szChannel"Cstrike_Chat_All"))
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] ^3%%s1 ^1: %%s2"g_aPlayers[id])
        }
        else
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] %s"g_aPlayers[id], szChannel)
        }
        
set_msg_arg_string(2szChannel)
    }

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("Test""0.0.1""ConnorMcLeod")
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}

public 
Message_SayText()
{
    new 
id get_msg_arg_int(1)
    
    new 
szChannel[40]
    
get_msg_arg_string(2szChannelcharsmax(szChannel))
    
    if(
equal(szChannel"Cstrike_Chat"13))
    {
        if(
equal(szChannel"Cstrike_Chat_All"))
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] ^3%%s1 ^1: %%s2"id)
        }
        else
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] %s"idszChannel)
        }
        
set_msg_arg_string(2szChannel)
    }

Do you mind to give me some explantations so I can understand it properly. If you say that I have no idea what am I doing, you will be absolutely right.

Thanks in advance.

Last edited by dark_style; 07-02-2012 at 01:37.
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-02-2012 , 04:35   Re: Good way to hook the chat?
Reply With Quote #15

What do you expect of g_aPlayers[id] ???

Its effect is as if you pass string ""
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-02-2012 , 04:46   Re: Good way to hook the chat?
Reply With Quote #16

I see, it just holds X number cells nothing more. Okay.. I have tried this method:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("Test""0.0.1""ConnorMcLeod")
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}

public 
Message_SayText()
{
    new 
id get_msg_arg_int(1)
    
    new 
szChannel[40]
    
get_msg_arg_string(2szChannelcharsmax(szChannel))
    
    if(
equal(szChannel"#Cstrike_Chat"13))
    {
        if(
equal(szChannel"#Cstrike_Chat_All"))
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] ^3%%s1 ^1: %%s2"id)
        }
        else
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] %s"idszChannel)
        }
        
set_msg_arg_string(2szChannel)
    }

The result was only green prefix [Haha], no name or message. Why so? Would you like to explain it to me, im really bad with the messages and I want to learn them.. The code looks like yours in the link I posted... ?

Last edited by dark_style; 07-02-2012 at 04:47.
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-02-2012 , 05:07   Re: Good way to hook the chat?
Reply With Quote #17

Seriously ?

What do you expect from 'id' in there :

PHP Code:
format(szChannelcharsmax(szChannel), "^4[Haha] ^3%%s1 ^1: %%s2"id

You should better to stick with code you understand, this string doesn't require any extra arg, %%s1 after format is %s1, same for %%s2, it's for the game to use other messages arguments, so there is no other pattern.
Also you can use formatex for that one, but stay with format for the other one.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-02-2012 at 05:09.
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-02-2012 , 05:35   Re: Good way to hook the chat?
Reply With Quote #18

Okay I manage to get it to work but not at 100%.. What I mean is - the all chat works fine but the team chat shows [Haha](Terrorist) Tonev : test Tonev instead of [Haha](Terrorist) Tonev : test. Will you help me to fix it? Here's the code:

PHP Code:
#include <amxmodx>

#define Max_Players    32

new g_aNames[Max_Players+1][32]

public 
plugin_init()
{
    
register_message(get_user_msgid("SayText"), "Message_SayText")
}

public 
Message_SayText()
{
    new 
id get_msg_arg_int(1)
    
get_user_name(idg_aNames[id], charsmax(g_aNames[]))
    
    new 
szChannel[40]
    
get_msg_arg_string(2szChannelcharsmax(szChannel))
    
    if(
equal(szChannel"#Cstrike_Chat"13))
    {
        if(
equal(szChannel"#Cstrike_Chat_All"))
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] ^3%%s1 ^1: %%s2"g_aNames[id])
        }
        else
        {
            
format(szChannelcharsmax(szChannel), "^4[Haha] %s %s"szChannelg_aNames[id])
        }
        
set_msg_arg_string(2szChannel)
    }

And if I put only one % everything stop working.

Last edited by dark_style; 07-02-2012 at 05:36.
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-02-2012 , 05:40   Re: Good way to hook the chat?
Reply With Quote #19

Again, it's because you don't understand what you are doing.
You should rather post in request forum so someone write the whole code for you.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-02-2012 at 05:41.
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-02-2012 , 05:44   Re: Good way to hook the chat?
Reply With Quote #20

Wouldn't it be easier for me and you to tell me what's wrong with the team chat and I should fix it, only this thing doesn't work.. And if I knew how to do it, I wouldn't ask, would I?

And I don't want to post in the request forum, because I don't want someone to write code for me. This forum is for scripting help - exactly what I need - I need someone to explain those things to me so I can understand them..

Last edited by dark_style; 07-02-2012 at 05:49.
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 15:54.


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