[HL2DM] Menus not showing plain text

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

[HL2DM] Menus not showing plain text

Postby Kami » Thu Dec 31, 2020 3:41 pm

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2DM] Menus not showing plain text

Postby satoon101 » Thu Dec 31, 2020 4:34 pm

Unless I'm mistaken, you don't want a menu, you want a Dialog message. Specifically, DialogText.
Image
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2DM] Menus not showing plain text

Postby Kami » Thu Dec 31, 2020 4:44 pm

You are right! Thank you very much for your help.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [HL2DM] Menus not showing plain text

Postby Kami » Fri Jan 01, 2021 3:31 pm

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.
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [HL2DM] Menus not showing plain text

Postby VinciT » Sat Jan 02, 2021 12:20 am

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
ImageImageImageImageImage

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 39 guests