Raised This Month: $51 Target: $400
 12% 

Solved MSG_ONE vs MSG_ONE_UNRELIABLE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-29-2022 , 15:51   MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #1

Is it really that dangerous to send MSG_ONE messages? I saw on this forum that if it fails it can crash the server. I did several tests with some random player ids.

PHP Code:
message_begin(MSG_ONEreset_hud_msg_id, {000}, 22);
message_end(); 
The above code, for example, did not crash the server even while there were only 2 players playing with ids 1 and 2. However, other values like 31, 32 or 0 indeed caused the server to crash. I have plugin that draws StatusIcon and Scenario icons. The problem occurs when the game sends ResetHUD message and those icons are removed from the screen. I try to catch this event and redraw desired icons but with no luck because MSG_ONE_UNRELIABLE fails half the time. What is the point to have functionality that works sometimes? I have to use MSG_ONE_UNRELIABLE because I do not want the server to crash but is it really that dangerous when we are talking about correct player ids? In which situations the worst scenario could happen? Does it happen when the player connection is unexpectedly broken?

More specific question: How can I be sure that StatusIcon/Scenario message is delivered to the client after ResetHUD and do not crash the server, or is it something I have to put up with?
BTW, MSG_ONE_UNRELIABLE fails for me after ResetHUD on new round event. It looks like in any other situation it works fine.

Last edited by damage220; 12-30-2022 at 06:17. Reason: Solved
damage220 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-29-2022 , 20:00   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #2

Inside message_end()

PHP Code:
// With `REHLDS_FIXES` enabled meaning of `svc_startofusermessages` changed a bit: now it is an id of the first user message
#ifdef REHLDS_FIXES
        
if (gMsgType >= svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE))
#else // REHLDS_FIXES
        
if (gMsgType svc_startofusermessages && (gMsgDest == MSG_ONE || gMsgDest == MSG_ONE_UNRELIABLE))
#endif // REHLDS_FIXES
        
{
            
int entnum NUM_FOR_EDICT((const edict_t *)gMsgEntity);
            if (
entnum || entnum g_psvs.maxclients)
                
Host_Error("%s: not a client"__func__);

            
client_tclient = &g_psvs.clients[entnum 1];
            if (
client->fakeclient || !client->hasusrmsgs || (!client->active && !client->spawned))
                return;
        } 
Inside message_begin()

PHP Code:
    case MSG_ONE:
    case 
MSG_ONE_UNRELIABLE:
        
entnum NUM_FOR_EDICT(gMsgEntity);
        if (
entnum <= || entnum g_psvs.maxclients)
        {
            
Host_Error("%s: not a client"__func__);
        } 
Server do crashes if an invalid player index is pushed into the 4th argument.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-30-2022 , 02:13   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #3

If all we need is correct player index, why do we not use MSG_ONE all the time? What is the point to have unreliable stream then? Like I said I have to redraw icons after ResetHUD. Would it be better to use MSG_ONE in ResetHUD event hook and MSG_ONE_UNRELIABLE during the round when messages are being sent even with unreliable stream? Or I can safely replace MSG_ONE_UNRELIABLE with MSG_ONE?
damage220 is offline
McTavish
Senior Member
Join Date: May 2021
Old 12-30-2022 , 05:09   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #4

I'm not that good but I can give some information,

Using the MSG_ONE flag with the message_begin native function will send a message to a single player, whereas MSG_ONE_UNRELIABLE will send an unreliable message to a single player.

The main difference between reliable and unreliable messages is that reliable messages are guaranteed to be delivered to the recipient, whereas unreliable messages are not. This means that if you send an unreliable message, there is a possibility that the message may not be delivered to the recipient at all.

In the case of ResetHUD, it would be better to use the MSG_ONE flag to ensure that the message is delivered reliably to the correct player. This is because the ResetHUD event is important and you want to make sure that the message is received by the player.

On the other hand, if you are sending messages during the round that are not critical to the gameplay, you can use the MSG_ONE_UNRELIABLE flag to save bandwidth and reduce the load on the server. This is because unreliable messages are generally faster to send than reliable ones, and are less likely to cause delays or lag on the server.

In summary, it is generally a good idea to use reliable messages for important events and unreliable messages for less critical ones. However, the specific choice of whether to use MSG_ONE or MSG_ONE_UNRELIABLE will depend on the specific requirements of your plugin and the needs of your server.
__________________
No Steam = No Support.

Last edited by McTavish; 12-30-2022 at 05:14.
McTavish is offline
Old 12-30-2022, 05:12
McTavish
This message has been deleted by McTavish.
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 12-30-2022 , 05:32   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #5

Quote:
Originally Posted by damage220 View Post
If all we need is correct player index, why do we not use MSG_ONE all the time? What is the point to have unreliable stream then? Like I said I have to redraw icons after ResetHUD. Would it be better to use MSG_ONE in ResetHUD event hook and MSG_ONE_UNRELIABLE during the round when messages are being sent even with unreliable stream? Or I can safely replace MSG_ONE_UNRELIABLE with MSG_ONE?
Reliable channel have limited queue's size, u just can crash server (or got endless loop,when server will try to resend rel.data to client)
__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc
DeMNiX is offline
McTavish
Senior Member
Join Date: May 2021
Old 12-30-2022 , 05:39   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #6

Quote:
Originally Posted by DeMNiX View Post
Reliable channel have limited queue's size, u just can crash server (or got endless loop,when server will try to resend rel.data to client)
correct me if I'm wrong,

It is generally not a good idea to send a large number of reliable messages in quick succession, as this can potentially cause problems on the server. This is because reliable messages are guaranteed to be delivered to the recipient, which means that the server will keep trying to send the message until it is successfully received. If the server is unable to send the message due to network issues or other problems, it may retry sending the message multiple times, which can use up a lot of bandwidth and processing power on the server.

To avoid these issues, it is generally a good idea to limit the number of reliable messages that you send and to ensure that your plugins do not send an excessive number of reliable messages in quick succession. If you do need to send a large number of reliable messages, you should consider using a rate-limiting mechanism to ensure that the messages are sent at a reasonable rate.

Additionally, it is also important to make sure that your plugin does not get stuck in an infinite loop when sending reliable messages. This can happen if the server is unable to send the message due to network issues or other problems, and the plugin continues to try and send the message indefinitely. To avoid this, you should make sure that your plugin has appropriate error handling in place to detect and handle these situations.
__________________
No Steam = No Support.
McTavish is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-30-2022 , 06:10   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #7

Quote:
Originally Posted by DeMNiX View Post
Reliable channel have limited queue's size, u just can crash server (or got endless loop,when server will try to resend rel.data to client)
Oh, I see. I got this error today when I tested these messages. Client was kicked from the server with error "Reliable channel overflowed".
damage220 is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 12-30-2022 , 06:17   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #8

DeMNiX, McTavish
Thank you. I came up to the idea that it is not bad or wrong to use MSG_ONE messages, though their usage should be reasonable. I will use it for critical parts of my plugins.
damage220 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-30-2022 , 07:33   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #9

Quote:
Originally Posted by DeMNiX View Post
Reliable channel have limited queue's size, u just can crash server (or got endless loop,when server will try to resend rel.data to client)
Server won't crash but client will surely get kicked.

When unreliable message get sent to the player if the player has an overflow on messages the message will be ignored as it is not nessccacry to show.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-30-2022 at 07:35.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
McTavish
Senior Member
Join Date: May 2021
Old 12-30-2022 , 07:54   Re: MSG_ONE vs MSG_ONE_UNRELIABLE
Reply With Quote #10

Quote:
Originally Posted by damage220 View Post
DeMNiX, McTavish
Thank you. I came up to the idea that it is not bad or wrong to use MSG_ONE messages, though their usage should be reasonable. I will use it for critical parts of my plugins.
np mate!
__________________
No Steam = No Support.
McTavish is offline
Reply



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 12:56.


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