messages package

Module contents

Provides user message based functionality.

class messages.DialogAskConnect(title, time=10)[source]

Bases: messages.dialog._DialogBase

Class used to send DialogType.ASKCONNECT messages to players.

DialogType.ASKCONNECT shows a box in-game that requests the player to hit the key they have bound to “askconnect_accept” (default to F3) to connect to a different server, whose address is given as the title value.

__init__(title, time=10)[source]

Set all the base attributes on instantiation.

Parameters:
  • title (str) – The IP address to connect to.
  • time (int) – The time (in seconds) for the notification to display.
message_type = _messages.DialogType.ASKCONNECT
class messages.DialogEntry(title, msg, command, color=Color(255, 255, 255, 255), time=10)[source]

Bases: messages.dialog._DialogBase

Class used to send DialogType.ENTRY messages to players.

DialogType.ENTRY shows the title while in-game (TopText) in the given color, as well as the msg in a box when the player uses their ESC key and an entry box where they can enter any values they wish.

The values the player enters are then sent as arguments for the given client command name.

__init__(title, msg, command, color=Color(255, 255, 255, 255), time=10)[source]

Set all the base attributes on instantiation.

Parameters:
  • title (str) – The title of the entry box and top text.
  • msg (str) – The message of the entry box.
  • command (str) – The command to execute on entry. Note that the entered values are arguments of the command on entry.
  • color (Color) – The color of the toptext notification.
  • time (int) – The time (in seconds) for the notification to display.
command

Return the registered command for the Entry box.

message_type = _messages.DialogType.ENTRY
class messages.DialogMenu(title, msg, command, color=Color(255, 255, 255, 255), time=10, options=None)[source]

Bases: messages.dialog._DialogBase

Class used to send DialogType.MENU messages to players.

DialogType.MENU shows the title while in-game (TopText) in the given color, as well as the msg in a box when the player uses their ESC key and a menu for the player to choose an option from.

The value the player chooses is then sent as an argument for the given client command name.

__init__(title, msg, command, color=Color(255, 255, 255, 255), time=10, options=None)[source]

Set all the base attributes on instantiation.

Parameters:
  • title (str) – The title of the menu box and top text.
  • msg (str) – The message of the menu box.
  • command (str) – The command to execute on entry. Note that the key/item of the selected option will be the argument.
  • color (Color) – The color of the toptext notification.
  • time (int) – The time (in seconds) for the notification to display.
  • options (iterable) – The options for the menu. If a dictionary is passed, the values will be displayed while the keys will be the argument of the command when selected. If any other iterable is used, the items will be both the displayed text and the argument.
command

Return the registered command for the Menu.

message_type = _messages.DialogType.MENU
class messages.DialogMsg(title, color=Color(255, 255, 255, 255), time=10)[source]

Bases: messages.dialog._DialogBase

Class used to send DialogType.MSG messages to players.

DialogType.MSG shows the title while in-game (TopText) in the given color.

__init__(title, color=Color(255, 255, 255, 255), time=10)[source]

Set all the base attributes on instantiation.

Parameters:
  • title (str) – The top text.
  • color (Color) – The color of the toptext notification.
  • time (int) – The time (in seconds) for the notification to display.
message_type = _messages.DialogType.MSG
class messages.DialogText(title, msg, color=Color(255, 255, 255, 255), time=10)[source]

Bases: messages.dialog._DialogBase

Class used to send DialogType.TEXT messages to players.

DialogType.TEXT shows the title while in-game (TopText) in the given color, as well as the msg in a box when the player uses their ESC key.

__init__(title, msg, color=Color(255, 255, 255, 255), time=10)[source]

Set all the base attributes on instantiation.

Parameters:
  • title (str) – The title of the message box and top text.
  • msg (str) – The message of the message box.
  • color (Color) – The color of the toptext notification.
  • time (int) – The time (in seconds) for the notification to display.
message_type = _messages.DialogType.TEXT
class messages.DialogType

Bases: Boost.Python.enum

ASKCONNECT = _messages.DialogType.ASKCONNECT
ENTRY = _messages.DialogType.ENTRY
MENU = _messages.DialogType.MENU
MSG = _messages.DialogType.MSG
TEXT = _messages.DialogType.TEXT
names = {'MSG': _messages.DialogType.MSG, 'MENU': _messages.DialogType.MENU, 'TEXT': _messages.DialogType.TEXT, 'ENTRY': _messages.DialogType.ENTRY, 'ASKCONNECT': _messages.DialogType.ASKCONNECT}
values = {0: _messages.DialogType.MSG, 1: _messages.DialogType.MENU, 2: _messages.DialogType.TEXT, 3: _messages.DialogType.ENTRY, 4: _messages.DialogType.ASKCONNECT}
class messages.Fade(duration, hold_time, color=Color(255, 255, 255, 255), flags=_messages.FadeFlags.IN)[source]

Bases: messages.base.UserMessageCreator

Create a Fade.

__init__(duration, hold_time, color=Color(255, 255, 255, 255), flags=_messages.FadeFlags.IN)[source]

Initialize the Fade instance.

bitbuf(buffer, kwargs)[source]

Send the Fade with bitbuf.

protobuf(buffer, kwargs)[source]

Send the Fade with protobuf.

message_name = 'Fade'
moved_frac_bits = 512
translatable_fields = []
class messages.FadeFlags

Bases: Boost.Python.enum

IN = _messages.FadeFlags.IN
MODULATE = _messages.FadeFlags.MODULATE
OUT = _messages.FadeFlags.OUT
PURGE = _messages.FadeFlags.PURGE
STAYOUT = _messages.FadeFlags.STAYOUT
names = {'IN': _messages.FadeFlags.IN, 'OUT': _messages.FadeFlags.OUT, 'MODULATE': _messages.FadeFlags.MODULATE, 'STAYOUT': _messages.FadeFlags.STAYOUT, 'PURGE': _messages.FadeFlags.PURGE}
values = {1: _messages.FadeFlags.IN, 2: _messages.FadeFlags.OUT, 4: _messages.FadeFlags.MODULATE, 8: _messages.FadeFlags.STAYOUT, 16: _messages.FadeFlags.PURGE}
class messages.HintText(message)[source]

Bases: messages.base.UserMessageCreator

Create a HintText.

__init__(message)[source]

Initialize the HintText instance.

bitbuf(buffer, kwargs)[source]

Send the HintText with bitbuf.

protobuf(buffer, kwargs)[source]

Send the HintText with protobuf.

message_name = 'HintText'
translatable_fields = ['message']
class messages.HudDestination

Bases: Boost.Python.enum

CENTER = _messages.HudDestination.CENTER
CONSOLE = _messages.HudDestination.CONSOLE
NOTIFY = _messages.HudDestination.NOTIFY
TALK = _messages.HudDestination.TALK
names = {'NOTIFY': _messages.HudDestination.NOTIFY, 'CONSOLE': _messages.HudDestination.CONSOLE, 'TALK': _messages.HudDestination.TALK, 'CENTER': _messages.HudDestination.CENTER}
values = {1: _messages.HudDestination.NOTIFY, 2: _messages.HudDestination.CONSOLE, 3: _messages.HudDestination.TALK, 4: _messages.HudDestination.CENTER}
class messages.HudMsg(message, x=-1, y=-1, color1=Color(255, 255, 255, 255), color2=Color(255, 255, 255, 255), effect=0, fade_in=0, fade_out=0, hold_time=4, fx_time=0, channel=0)[source]

Bases: messages.base.UserMessageCreator

Create a HudMsg.

__init__(message, x=-1, y=-1, color1=Color(255, 255, 255, 255), color2=Color(255, 255, 255, 255), effect=0, fade_in=0, fade_out=0, hold_time=4, fx_time=0, channel=0)[source]

Initialize the HudMsg instance.

bitbuf(buffer, kwargs)[source]

Send the HudMsg with bitbuf.

protobuf(buffer, kwargs)[source]

Send the HudMsg with protobuf.

message_name = 'HudMsg'
translatable_fields = ['message']
class messages.KeyHintText(*hints)[source]

Bases: messages.base.UserMessageCreator

Create a KeyHintText.

__init__(*hints)[source]

Initialize the KeyHintText instance.

bitbuf(buffer, kwargs)[source]

Send the KeyHintText with bitbuf.

protobuf(buffer, kwargs)[source]

Send the KeyHintText with protobuf.

message_name = 'KeyHintText'
class messages.ResetHUD(reset=True)[source]

Bases: messages.base.UserMessageCreator

Create a ResetHUD.

__init__(reset=True)[source]

Initialize the ResetHUD instance.

bitbuf(buffer, kwargs)[source]

Send the ResetHUD with bitbuf.

protobuf(buffer, kwargs)[source]

Send the ResetHUD with protobuf.

message_name = 'ResetHud'
translatable_fields = []
class messages.SayText(message, index=0, chat=False, color='x01')[source]

Bases: messages.base.UserMessageCreator

Create a SayText.

__init__(message, index=0, chat=False, color='\x01')[source]

Initialize the SayText instance.

bitbuf(buffer, kwargs)[source]

Send the SayText with bitbuf.

protobuf(buffer, kwargs)[source]

Send the SayText with protobuf.

message_name = 'SayText'
reliable = True
translatable_fields = ['message']
class messages.SayText2(message, index=0, chat=False, param1='', param2='', param3='', param4='', color='x01')[source]

Bases: messages.base.UserMessageCreator

Create a SayText2.

__init__(message, index=0, chat=False, param1='', param2='', param3='', param4='', color='\x01')[source]

Initialize the SayText2 instance.

bitbuf(buffer, kwargs)[source]

Send the SayText2 with bitbuf.

protobuf(buffer, kwargs)[source]

Send the SayText2 with protobuf.

message_name = 'SayText2'
reliable = True
translatable_fields = ['message', 'param1', 'param2', 'param3', 'param4']
class messages.Shake(amplitude, duration, frequency=1, shake_command=_messages.ShakeCommand.START)[source]

Bases: messages.base.UserMessageCreator

Create a Shake.

__init__(amplitude, duration, frequency=1, shake_command=_messages.ShakeCommand.START)[source]

Initialize the Shake instance.

bitbuf(buffer, kwargs)[source]

Send the Shake with bitbuf.

protobuf(buffer, kwargs)[source]

Send the Shake with protobuf.

message_name = 'Shake'
translatable_fields = []
class messages.ShakeCommand

Bases: Boost.Python.enum

AMPLITUDE = _messages.ShakeCommand.AMPLITUDE
FREQUENCY = _messages.ShakeCommand.FREQUENCY
START = _messages.ShakeCommand.START
START_NORUMBLE = _messages.ShakeCommand.START_NORUMBLE
START_RUMBLEONLY = _messages.ShakeCommand.START_RUMBLEONLY
STOP = _messages.ShakeCommand.STOP
names = {'START': _messages.ShakeCommand.START, 'STOP': _messages.ShakeCommand.STOP, 'AMPLITUDE': _messages.ShakeCommand.AMPLITUDE, 'FREQUENCY': _messages.ShakeCommand.FREQUENCY, 'START_RUMBLEONLY': _messages.ShakeCommand.START_RUMBLEONLY, 'START_NORUMBLE': _messages.ShakeCommand.START_NORUMBLE}
values = {0: _messages.ShakeCommand.START, 1: _messages.ShakeCommand.STOP, 2: _messages.ShakeCommand.AMPLITUDE, 3: _messages.ShakeCommand.FREQUENCY, 4: _messages.ShakeCommand.START_RUMBLEONLY, 5: _messages.ShakeCommand.START_NORUMBLE}
class messages.ShowMenu(menu_string, valid_slots=1023, display_time=4)[source]

Bases: messages.base.UserMessageCreator

Create a radio menu.

__init__(menu_string, valid_slots=1023, display_time=4)[source]

Initialize the radio menu.

bitbuf(player_indexes, kwargs)[source]

Send the ShowMenu with bitbuf.

protobuf(buffer, kwargs)[source]

Send the ShowMenu with protobuf.

send(*player_indexes)[source]

Send the user message.

chunk_size = 62
message_name = 'ShowMenu'
translatable_fields = []
class messages.TextMsg(message, destination=_messages.HudDestination.CENTER, param1='', param2='', param3='', param4='')[source]

Bases: messages.base.UserMessageCreator

Create a TextMsg.

__init__(message, destination=_messages.HudDestination.CENTER, param1='', param2='', param3='', param4='')[source]

Initialize the TextMsg instance.

bitbuf(buffer, kwargs)[source]

Send the TextMsg with bitbuf.

protobuf(buffer, kwargs)[source]

Send the TextMsg with protobuf.

message_name = 'TextMsg'
reliable = True
translatable_fields = ['message', 'param1', 'param2', 'param3', 'param4']
class messages.UserMessage

Bases: Boost.Python.instance

__init__((object)arg1, (BaseRecipientFilter)arg2, (str)arg3) → None
static is_protobuf() → bool
send((UserMessage)arg1) → None
buffer
message_index
message_name
recipients
class messages.UserMessageCreator(**kwargs)[source]

Bases: messages.base.AttrDict

Provide an easy interface to create user messages.

Attr bool reliable:
 Whether to send message using reliable channel.
__init__(**kwargs)[source]

Initialize the usermessage creator.

Parameters:kwargs (dict) – All valid fields.
bitbuf(buffer, translated_kwargs)[source]

Bitbuf implementation of this user message.

protobuf(buffer, translated_kwargs)[source]

Protobuf implementation of this user message.

send(*player_indexes, **tokens)[source]

Send the user message.

message_name

Return the user message name.

reliable = False
translatable_fields

Return a list of translatable fields.

class messages.VGUIMenu(name, subkeys=None, show=True)[source]

Bases: messages.base.UserMessageCreator

Create a VGUIMenu.

__init__(name, subkeys=None, show=True)[source]

Initialize the VGUI menu.

Parameters:
  • name (str) – Name of the menu.
  • subkeys (dict) – Additional menu data.
  • show (bool) – If True the menu will be shown, else it will be hidden.
bitbuf(buffer, kwargs)[source]

Send the VGUIMenu with bitbuf.

protobuf(buffer, kwargs)[source]

Send the VGUIMenu with protobuf.

message_name = 'VGUIMenu'
translatable_fields = []
messages.get_message_index((str)name) → int :

Return the index of a user message. Return -1 if the user message wasn’t found.

messages.get_message_name((Channel)index) → object :

Return the name of the user message. Return None if the user message wasn’t found.

messages.get_message_size((Channel)index) → object :

Return the size of the user message. Return None if the user message wasn’t found.