View Single Post
Author Message
E1_531G
Senior Member
Join Date: Dec 2017
Old 08-08-2018 , 17:58   Suggestion about register_message
Reply With Quote #1

Hello.

I have a new idea about register_message.

But first, the explanation.
If we want to block (for example) only "Terrorist win" sound, we have to hook SendAudio message using register_message:
PHP Code:
register_messageget_user_msgid("SendAudio"), "Message_SendAudio" 
and do something like this:
PHP Code:
public Message_SendAudio()
{
    static 
arg2[16]
    
get_msg_arg_string2arg2charsmax(arg2) )

    if( 
equali(arg2"%!MRAD_terwin") )
        return 
1;

    return 
0;

All fine but, if we have 32 players online the server will execute this function 32 times, doing the same job again and again.

Now, my suggestion.
We should have new native: register_message_pre or another good name
Usage remains the same:
PHP Code:
register_message_preget_user_msgid("SendAudio"), "Message_SendAudio_Pre" 
But now, the server before looping over online players executes our function.
If it find "return 1" in the our func, it won't looping over players, and (in our example) it does not send "Terrorist win" sound to anyone.

What do you think, guys?
__________________
My English is A0
E1_531G is offline