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())