fixed a menu bug at19364

This commit is contained in:
Borja Ferrer 2005-11-13 20:33:30 +00:00
parent c5761610b8
commit 2ac00713a7
5 changed files with 39 additions and 3 deletions

View File

@ -48,6 +48,7 @@ void CPlayer::Init(edict_t* e, int i)
aiming = 0;
menu = 0;
keys = 0;
menuexpire = 0.0;
death_weapon.clear();
name.clear();

View File

@ -89,6 +89,7 @@ public:
float time;
float playtime;
float menuexpire;
struct
{

View File

@ -920,11 +920,17 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame)
{
pPlayer->keys = keys;
pPlayer->menu = menuid;
if (time == -1)
pPlayer->menuexpire = INFINITE;
else
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
pPlayer->newmenu = -1;
pPlayer->page = 0;
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
@ -940,11 +946,17 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
{
pPlayer->keys = keys;
pPlayer->menu = menuid;
if (time == -1)
pPlayer->menuexpire = INFINITE;
else
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
pPlayer->newmenu = -1;
pPlayer->page = 0;
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
@ -2416,8 +2428,18 @@ static cell AMX_NATIVE_CALL get_user_menu(AMX *amx, cell *params) /* 3 param */
if (pPlayer->ingame)
{
if (gpGlobals->time > pPlayer->menuexpire)
{
pPlayer->menu = 0;
*cpMenu = 0;
*cpKeys = 0;
return 0;
}
*cpMenu = pPlayer->menu;
*cpKeys = pPlayer->keys;
return 1;
}

View File

@ -716,6 +716,14 @@ void C_ClientCommand(edict_t *pEntity)
if (pPlayer->keys & bit_key)
{
if (gpGlobals->time > pPlayer->menuexpire)
{
pPlayer->menu = 0;
pPlayer->keys = 0;
RETURN_META(MRES_SUPERCEDE);
}
int menuid = pPlayer->menu;
pPlayer->menu = 0;

View File

@ -351,9 +351,13 @@ static cell AMX_NATIVE_CALL menu_items(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
{
GETMENU(params[2]);
int player = params[1];
int page = params[3];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(player);
// This will set the expire time of the menu to infinite
pPlayer->menuexpire = INFINITE;
return pMenu->Display(player, page);
}