Newmenus: Add necessary API changes for newmenu timeouts

This commit is contained in:
Valentin Grünbacher 2014-05-21 19:17:04 +02:00
parent c8b7a09028
commit 3b87c428dc
3 changed files with 20 additions and 6 deletions

View File

@ -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 int time = -1;
if (params[0] / sizeof(cell) >= 4)
time = params[4];
if (time < 0)
pPlayer->menuexpire = INFINITE; pPlayer->menuexpire = INFINITE;
else
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
return pMenu->Display(player, page); return pMenu->Display(player, page);
} }

View File

@ -269,6 +269,7 @@ enum {
#define INVALID_PLUGIN_ID -1 #define INVALID_PLUGIN_ID -1
#define MENU_TIMEOUT -4
#define MENU_EXIT -3 #define MENU_EXIT -3
#define MENU_BACK -2 #define MENU_BACK -2
#define MENU_MORE -1 #define MENU_MORE -1

View File

@ -111,13 +111,20 @@ native menu_items(menu);
* when the item is less than 0 (i.e. calling this from a cancelled menu will * when the item is less than 0 (i.e. calling this from a cancelled menu will
* result in an error). * 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 id Client index.
* @param menu Menu resource identifier. * @param menu Menu resource identifier.
* @param page Page to start from (starting from 0). * @param page Page to start from (starting from 0).
* @param time If >=0 menu will timeout after this many seconds
* @noreturn * @noreturn
* @error Invalid menu resource or client index. * @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. * Given a page on a menu and a keypress on that page, returns the item id selected.