AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block message in message hook, but continue in code (https://forums.alliedmods.net/showthread.php?t=94185)

Silencer123 06-07-2009 16:38

Block message in message hook, but continue in code
 
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. }

Bugsy 06-07-2009 16:43

Re: Block message in message hook, but continue in code
 
Use set_task?

Silencer123 06-07-2009 17:07

Re: Block message in message hook, but continue in code
 
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.


All times are GMT -4. The time now is 19:26.

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