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

Hook function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tripc
Senior Member
Join Date: Aug 2006
Old 11-12-2010 , 16:25   Hook function
Reply With Quote #1

I have plugin that use client_print(print_chat)
I want to hook it and get the text.

Is it possible, if so then how?
PHP Code:
client_print(id,print_chat,"TEXT"
tripc is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-13-2010 , 20:39   Re: Hook function
Reply With Quote #2

Quote:
Originally Posted by tripc View Post
I have plugin that use client_print(print_chat)
I want to hook it and get the text.

Is it possible, if so then how?
PHP Code:
client_print(id,print_chat,"TEXT"
You can probably find the answer to your questions in 75% of the threads in this forum.

PHP Code:
//Hook any time a player chats
register_clcmd"say" "HookSay" );

//Hooks a specific chat message, in this case "hello"
register_clcmd"say hello" "HookSayHello" );

public 
HookSayid )
{
    static 
szSaid64 ];
    
read_argvszSaid charsmaxszSaid ) );
    
    
client_printprint_chat "Player said %s" szSaid );
}
    
public 
HookSayHelloid )
{
    
//Player said "hello"
    
    //This will prevent a player chat from appearing.
    //return PLUGIN_HANDLED;

__________________
Bugsy is offline
tripc
Senior Member
Join Date: Aug 2006
Old 11-13-2010 , 20:43   Re: Hook function
Reply With Quote #3

I know how to hook player chat and how to block it...

But if I have a plugin that use
client_print(0,print_chat,"[AMXX] Something HERE");

How can I get the text of the client_print function ([AMXX]...) from another plugin

Last edited by tripc; 11-13-2010 at 21:02.
tripc is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-13-2010 , 22:38   Re: Hook function
Reply With Quote #4

Sorry about that chief, I misunderstood your post.

I've never had the need to do this so I'm not sure if it can be done, according to Connor it cannot be done unless you create your own client_print function.

http://forums.alliedmods.net/showthread.php?t=85294
__________________
Bugsy is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 11-14-2010 , 03:08   Re: Hook function
Reply With Quote #5

@Bugsy:
Cant we use register_message( "TextMsg", .. ) to hook client print bcoz amx's client_print also uses emessage ?
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-14-2010 , 04:55   Re: Hook function
Reply With Quote #6

You can still hook client_print() with orpheu, it's easy.
__________________
Arkshine is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 11-14-2010 , 09:17   Re: Hook function
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
You can still hook client_print() with orpheu, it's easy.
Can you show an example pLZ
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-14-2010 , 14:16   Re: Hook function
Reply With Quote #8

Sure.

test plugin :

Code:
#include <amxmodx> #include <orpheu> public plugin_init() {     OrpheuRegisterHook( OrpheuGetFunction( "UTIL_ClientPrint" ), "UTIL_ClientPrint" ); } public UTIL_ClientPrint( const player, const messageType, const message[] ) {     log_amx( "%d - %d - %s", player, messageType, message ); }

Make sig in orpheu/functions/, named "UTIL_ClientPrint", as content :

PHP Code:
{
    
"name"        "UTIL_ClientPrint",
    
"library"     "amxmodx",
    
"arguments"   :
    [
        {
            
"type" "edict_s *"
        
},
        {
            
"type" "int"
        
},
        {
            
"type" "char *"
        
}
    ],
    
"identifiers" :
    [
        {
            
"os"    "windows",
            
"mod"   "cstrike",
            
"value" : [0x83,"*","*","*","*","*",0x00,0x74,"*",0x8B,0x44,"*","*",0x53,0x56,0x8B,0x74,"*","*",0x8A,0x9E,"*","*","*","*",0xC6,0x86,"*","*","*","*",0x00,0x85,0xC0,0x74,"*",0x50,0xA1,"*","*","*","*",0x6A,0x00,0x50,0x6A,0x01,0xEB]
        },    
        {
            
"os"    "linux",
            
"mod"   "cstrike",
            
"value" "UTIL_ClientPrint"
        
}
    ]

Important : I've attached a special version of orpheu, a new feature (thanks to joropito) has been added to register dynamically any library found. Make sure to overwrite the old binary by the provided one.
Attached Files
File Type: zip UTIL_ClientPrint.zip (396.6 KB, 151 views)
__________________
Arkshine 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 17:06.


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