Raised This Month: $219 Target: $400
 54% 

Block message in message hook, but continue in code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Location: Germany (GMT+1)
Old 06-07-2009 , 16:38   Block message in message hook, but continue in code
Reply With Quote #1

I want to block a message in its hook, yet have the code move on.
To a block a message you would return PLUGIN_HANDLED, but I cannot
chronologically append my code directly after it.
Code:
public plugin_init() {     register_message(somemsg, "msg_hook"); } public msg_hook(msg_id, msg_dest, id) {     // <-- Block the message here, as return PLUGIN_HANDLED would do ...     // ... yet have more code be executed after it ...     // ... like other message calls which would crash the game otherwise. }
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-07-2009 , 16:43   Re: Block message in message hook, but continue in code
Reply With Quote #2

Use set_task?
__________________
Bugsy is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Location: Germany (GMT+1)
Old 06-07-2009 , 17:07   Re: Block message in message hook, but continue in code
Reply With Quote #3

Set_task is uber cheap since you are forced to at least 0.1 seconds.
Found a solution already. Using the example from above:
Code:
public plugin_init() {     register_message(somemsg, "msg_hook"); } public msg_hook(msg_id, msg_dest, id) {     // Do or don't do anything with the original message here         for(new i = 64; i <= 100; i++) { // In HL, 64 to 100 is the range of all messages         msg_state[i] = get_msg_block(i);         set_msg_block(i, BLOCK_SET);     }         // Do stuff         for(new i = 64; i <= 100; i++) {         set_msg_block(i, msg_state[i]);     }         // Do or don't do anything with the original message here }
Works like a charm. Lucky enough I need no message calls there.
I only need to block message calls caused by some of the stuff done there.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Reply


Thread Tools
Display Modes

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 11:00.


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