mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
Newmenus: Add MENU_TIMEOUT status code and pass it where necessary
This commit is contained in:
parent
cd7cb8c1a8
commit
2e8ce87c23
@ -70,13 +70,19 @@ void CPlayer::Disconnect()
|
||||
Menu *pMenu = g_NewMenus[newmenu];
|
||||
if (pMenu)
|
||||
{
|
||||
int status;
|
||||
if (gpGlobals->time > menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
//prevent recursion
|
||||
newmenu = -1;
|
||||
menu = 0;
|
||||
executeForwards(pMenu->func,
|
||||
static_cast<cell>(ENTINDEX(pEdict)),
|
||||
static_cast<cell>(pMenu->thisId),
|
||||
static_cast<cell>(MENU_EXIT));
|
||||
static_cast<cell>(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1298,10 +1298,15 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
|
||||
if (menu >= 0 && menu < (int)g_NewMenus.size() && g_NewMenus[menu])
|
||||
{
|
||||
Menu *pMenu = g_NewMenus[menu];
|
||||
int status;
|
||||
if (gpGlobals->time > pPlayer->menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
pPlayer->newmenu = -1;
|
||||
|
||||
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(MENU_EXIT));
|
||||
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(status));
|
||||
}
|
||||
|
||||
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);
|
||||
@ -1340,10 +1345,15 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
|
||||
if (menu >= 0 && menu < (int)g_NewMenus.size() && g_NewMenus[menu])
|
||||
{
|
||||
Menu *pMenu = g_NewMenus[menu];
|
||||
int status;
|
||||
if (gpGlobals->time > pPlayer->menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
pPlayer->newmenu = -1;
|
||||
|
||||
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(MENU_EXIT));
|
||||
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(status));
|
||||
}
|
||||
|
||||
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);
|
||||
|
@ -795,13 +795,18 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
Menu *pOther = g_NewMenus[menu];
|
||||
int status;
|
||||
if (gpGlobals->time > pPlayer->menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
pPlayer->newmenu = -1;
|
||||
pPlayer->menu = 0;
|
||||
executeForwards(pOther->func,
|
||||
static_cast<cell>(player),
|
||||
static_cast<cell>(pOther->thisId),
|
||||
static_cast<cell>(MENU_EXIT));
|
||||
static_cast<cell>(status));
|
||||
|
||||
/* Infinite loop counter */
|
||||
if (++loops >= 10)
|
||||
@ -1048,12 +1053,18 @@ static cell AMX_NATIVE_CALL menu_cancel(AMX *amx, cell *params)
|
||||
|
||||
Menu *pMenu = g_NewMenus[menu];
|
||||
|
||||
int status;
|
||||
if (gpGlobals->time > player->menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
player->newmenu = -1;
|
||||
player->menu = 0;
|
||||
executeForwards(pMenu->func,
|
||||
static_cast<cell>(index),
|
||||
static_cast<cell>(pMenu->thisId),
|
||||
static_cast<cell>(MENU_EXIT));
|
||||
static_cast<cell>(status));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1075,12 +1086,18 @@ static cell AMX_NATIVE_CALL menu_destroy(AMX *amx, cell *params)
|
||||
player = GET_PLAYER_POINTER_I(i);
|
||||
if (player->newmenu == pMenu->thisId)
|
||||
{
|
||||
int status;
|
||||
if (gpGlobals->time > player->menuexpire)
|
||||
status = MENU_TIMEOUT;
|
||||
else
|
||||
status = MENU_EXIT;
|
||||
|
||||
player->newmenu = -1;
|
||||
player->menu = 0;
|
||||
executeForwards(pMenu->func,
|
||||
static_cast<cell>(i),
|
||||
static_cast<cell>(pMenu->thisId),
|
||||
static_cast<cell>(MENU_EXIT));
|
||||
static_cast<cell>(status));
|
||||
}
|
||||
}
|
||||
g_NewMenus[params[1]] = NULL;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#ifndef _INCLUDE_NEWMENUS_H
|
||||
#define _INCLUDE_NEWMENUS_H
|
||||
|
||||
#define MENU_TIMEOUT -4
|
||||
#define MENU_EXIT -3
|
||||
#define MENU_BACK -2
|
||||
#define MENU_MORE -1
|
||||
|
Loading…
Reference in New Issue
Block a user