Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion addons/source-python/packages/source-python/messages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class AttrDict(dict):


class UserMessageCreator(AttrDict):
"""Provide an easy interface to create user messages."""
"""Provide an easy interface to create user messages.

:attr bool reliable: Whether to send message using reliable channel.
"""

reliable = False

def __init__(self, **kwargs):
"""Initialize the usermessage creator.
Expand Down Expand Up @@ -81,6 +86,7 @@ def _send(self, player_indexes, translated_kwargs):
:param AttrDict translated_kwargs: The translated arguments.
"""
recipients = RecipientFilter(*player_indexes)
recipients.reliable = self.reliable
user_message = UserMessage(recipients, self.message_name)

if user_message.is_protobuf():
Expand Down Expand Up @@ -206,6 +212,7 @@ def send(self, *player_indexes):
# this length, we need to sent it in several parts.
if UserMessage.is_protobuf():
recipients = RecipientFilter(*player_indexes)
recipients.reliable = self.reliable
user_message = UserMessage(recipients, self.message_name)
self.protobuf(user_message.buffer, self)
user_message.send()
Expand All @@ -223,6 +230,7 @@ def bitbuf(self, player_indexes, kwargs):
menu_string = kwargs.menu_string
length = len(menu_string)
recipients = RecipientFilter(*player_indexes)
recipients.reliable = self.reliable
while True:
user_message = UserMessage(recipients, self.message_name)

Expand All @@ -246,6 +254,7 @@ class SayText2(UserMessageCreator):

message_name = 'SayText2'
translatable_fields = ['message', 'param1', 'param2', 'param3', 'param4']
reliable = True

def __init__(
self, message, index=0, chat=False,
Expand Down Expand Up @@ -301,6 +310,7 @@ class SayText(UserMessageCreator):

message_name = 'SayText'
translatable_fields = ['message']
reliable = True

def __init__(self, message, index=0, chat=False):
"""Initialize the SayText instance."""
Expand Down Expand Up @@ -372,6 +382,7 @@ class TextMsg(UserMessageCreator):

message_name = 'TextMsg'
translatable_fields = ['message', 'param1', 'param2', 'param3', 'param4']
reliable = True

def __init__(
self, message, destination=HudDestination.CENTER,
Expand Down