Raised This Month: $32 Target: $400
 8% 

Suggestion about register_message


Post New Thread Reply   
 
Thread Tools Display Modes
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
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-08-2018 , 18:43   Re: Suggestion about register_message
Reply With Quote #2

It doesn't matter that it's called 32 times, it's trivial.
__________________
klippy 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 19:24.


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