diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 6b75394d..ee607ffe 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -825,8 +825,14 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params) } } - // This will set the expire time of the menu to infinite - pPlayer->menuexpire = INFINITE; + int time = -1; + if (params[0] / sizeof(cell) >= 4) + time = params[4]; + + if (time < 0) + pPlayer->menuexpire = INFINITE; + else + pPlayer->menuexpire = gpGlobals->time + static_cast(time); return pMenu->Display(player, page); } diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index 1f902d34..2c0a298c 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -269,9 +269,10 @@ enum { #define INVALID_PLUGIN_ID -1 -#define MENU_EXIT -3 -#define MENU_BACK -2 -#define MENU_MORE -1 +#define MENU_TIMEOUT -4 +#define MENU_EXIT -3 +#define MENU_BACK -2 +#define MENU_MORE -1 #define ITEM_IGNORE 0 #define ITEM_ENABLED 1 #define ITEM_DISABLED 2 diff --git a/plugins/include/newmenus.inc b/plugins/include/newmenus.inc index 1da1ec76..829a8b1a 100644 --- a/plugins/include/newmenus.inc +++ b/plugins/include/newmenus.inc @@ -111,13 +111,20 @@ native menu_items(menu); * when the item is less than 0 (i.e. calling this from a cancelled menu will * result in an error). * + * Starting with 1.8.3 this allows to select a menu timeout similar to the + * show_menu native. If the menu exists on the client past the timeout *any* + * further action will send the MENU_TIMEOUT status code to the menu handler. + * That includes actions which would otherwise send MENU_EXIT, including + * client disconnect and calling menu_cancel or menu_destroy on a live menu. + * * @param id Client index. * @param menu Menu resource identifier. * @param page Page to start from (starting from 0). + * @param time If >=0 menu will timeout after this many seconds * @noreturn * @error Invalid menu resource or client index. */ -native menu_display(id, menu, page=0); +native menu_display(id, menu, page=0, time=-1); /** * Given a page on a menu and a keypress on that page, returns the item id selected.