AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   Suggestion about register_message (https://forums.alliedmods.net/showthread.php?t=309832)

E1_531G 08-08-2018 17:58

Suggestion about register_message
 
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?

klippy 08-08-2018 18:43

Re: Suggestion about register_message
 
It doesn't matter that it's called 32 times, it's trivial.


All times are GMT -4. The time now is 18:53.

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