[CS:S] Closing a SP menu when a SM menu is sent.

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

[CS:S] Closing a SP menu when a SM menu is sent.

Postby Kami » Sat Feb 20, 2021 3:49 pm

Hey guys,

I noticed that SP does not play well with SM menus. If you open a SP menu and a SM menu after that the SM menu will come up shortly and be replaced by the SP menu quickly. If I go the other way around and open SM first and SP second it does work without any problems. How would I go about closing the current SP menu if a new SM menu is sent?

I used this code for testing:

Syntax: Select all

from menus import SimpleMenu, SimpleOption
from events import Event
from players.entity import Player


def __select(menu,index,choice):
print(choice.choice_index)

@Event('player_say')
def _say(ev):
if ev['text'] == "test":
player = Player.from_userid(ev['userid'])
menu = SimpleMenu(select_callback=__select)
menu.append("Test me")
menu.append(SimpleOption(1,"Yes"))
menu.append(SimpleOption(2,"No"))
menu.append(SimpleOption(0,"Close"))
menu.send(player.index)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 2 guests