usermessage_c.create_message

Official Announcements about Source.Python.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

usermessage_c.create_message

Postby satoon101 » Mon Feb 17, 2014 8:58 pm

Just wanted to give everyone a heads up that we now have the ability to create TopText, ESCMenu, ESCTextBox, ESCInputBox, and AskConnect messages. I have not tested AskConnect, as of yet, but the other 4 are working fine in CS:S. None of the messages seem to be working on CSGO, unfortunately. We will be working on creating wrapper classes for each of these, much like the other messages. But, until then, you can just use them directly. Here is my test script:

Syntax: Select all

from conversions_c import edict_from_playerinfo
from keyvalues_c import KeyValues
from usermessage_c import create_message
from usermessage_c import Color
from usermessage_c import DialogType

from commands.client import ClientCommand
from commands.say import SayCommand

@SayCommand('msg')
def test_msg(playerinfo, teamonly, command):
edict = edict_from_playerinfo(playerinfo)
keyvalues = KeyValues('msg')
keyvalues.set_string('title', 'This is a title')
keyvalues.set_color('color', Color(255, 0, 0, 255))
keyvalues.set_int('level', 5)
keyvalues.set_int('time', 10)
create_message(edict, DialogType.MSG, keyvalues)


@SayCommand('menu')
def test_menu(playerinfo, teamonly, command):
edict = edict_from_playerinfo(playerinfo)
keyvalues = KeyValues('menu')
keyvalues.set_string('title', 'This is a title')
keyvalues.set_int('level', 0)
keyvalues.set_color('color', Color(0, 0, 255, 0))
keyvalues.set_int('time', 15)
keyvalues.set_string('msg', 'This is a message')
for value, message in enumerate(('Yes', 'No')):
value += 1
button = keyvalues.find_key(str(value), True)
button.set_string('msg', message)
button.set_string('command', 'menuselect {0}'.format(value))
create_message(edict, DialogType.MENU, keyvalues)


@SayCommand('text')
def test_text(playerinfo, teamonly, command):
edict = edict_from_playerinfo(playerinfo)
keyvalues = KeyValues('text')
keyvalues.set_string('title', 'This is a title')
keyvalues.set_int('level', 0)
keyvalues.set_color('color', Color(255, 0, 255, 255))
keyvalues.set_int('time', 10)
keyvalues.set_string('msg', 'This is a message')
create_message(edict, DialogType.TEXT, keyvalues)


@SayCommand('entry')
def test_entry(playerinfo, teamonly, command):
edict = edict_from_playerinfo(playerinfo)
keyvalues = KeyValues('entry')
keyvalues.set_string('title', 'This is a title')
keyvalues.set_int('level', 0)
keyvalues.set_color('color', Color(0, 255, 0, 255))
keyvalues.set_int('time', 10)
keyvalues.set_string('msg', 'This is a message')
keyvalues.set_string('command', 'entry_test')
create_message(edict, DialogType.ENTRY, keyvalues)


@ClientCommand('entry_test')
def entry_client(playerinfo, command):
print(command.get_command_string())


@ClientCommand('menuselect')
def menu_select(playerinfo, command):
print(command.get_command_string())

Return to “News & Announcements”

Who is online

Users browsing this forum: No registered users and 3 guests