Page 1 of 1

[HL2DM] Menus not showing plain text

Posted: Thu Dec 31, 2020 3:41 pm
by Kami
Hey guys,

I have been trying to add plain text to an ESC Menu in hl2dm but have been failing to do so. With Ayutos ES Emulator it works but I could not figure out why it does. I used this code for testing:

Syntax: Select all

from events import Event 
from players.entity import Player
from menus import SimpleMenu
from menus import Text

@Event('player_say')
def say(ev):
player = Player.from_userid(ev['userid'])
menu_test = SimpleMenu(title="This is a test")
menu_test.append(Text('This is a test'))
menu_test.send(player.index)


This is what it looks like with my code
Image

This is what it is supposed to look (not the text, just the type of display)

Image

Re: [HL2DM] Menus not showing plain text

Posted: Thu Dec 31, 2020 4:34 pm
by satoon101
Unless I'm mistaken, you don't want a menu, you want a Dialog message. Specifically, DialogText.

Re: [HL2DM] Menus not showing plain text

Posted: Thu Dec 31, 2020 4:44 pm
by Kami
You are right! Thank you very much for your help.

Re: [HL2DM] Menus not showing plain text

Posted: Fri Jan 01, 2021 3:31 pm
by Kami
Okay, it seems that it is possible to display text and menu options in the same menu:

Image

Any idea how that would work? As shown above, adding text to a Menu will not display the text at all.

Re: [HL2DM] Menus not showing plain text

Posted: Sat Jan 02, 2021 12:20 am
by VinciT
You can achieve that with DialogMenu():

Syntax: Select all

# ../menu_example/menu_example.py

# Source.Python
from colors import Color
from commands import CommandReturn
from commands.client import ClientCommand
from messages import DialogMenu
from players.entity import Player


DialogMenu(
title='Menu Title',
msg='Message goes here.\nAnother line over here!\n\nAnd another..',
command='dialog_menu_command',
color=Color(255, 255, 255, 255),
time=10,
options={
# Command argument(s): Label
'kill': 'Option 1',
'disconnect': 'Option 2'
}
).send()


@ClientCommand('dialog_menu_command')
def dialog_menu_cmd(command, index):
# Get the Player instance.
player = Player(index)
args = command.arg_string
# Did the player pick Option 1?
if 'kill' in args:
player.take_damage(damage=player.health)
elif 'disconnect' in args:
player.kick(message='You chose Option 2')

return CommandReturn.BLOCK