From 2ac00713a70af92139e8f0c04535c727d2c3de7f Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sun, 13 Nov 2005 20:33:30 +0000 Subject: [PATCH] fixed a menu bug at19364 --- amxmodx/CMisc.cpp | 1 + amxmodx/CMisc.h | 1 + amxmodx/amxmodx.cpp | 26 ++++++++++++++++++++++++-- amxmodx/meta_api.cpp | 8 ++++++++ amxmodx/newmenus.cpp | 6 +++++- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/amxmodx/CMisc.cpp b/amxmodx/CMisc.cpp index 7fafb574..566cccc5 100755 --- a/amxmodx/CMisc.cpp +++ b/amxmodx/CMisc.cpp @@ -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(); diff --git a/amxmodx/CMisc.h b/amxmodx/CMisc.h index 68b38218..3d58eb32 100755 --- a/amxmodx/CMisc.h +++ b/amxmodx/CMisc.h @@ -89,6 +89,7 @@ public: float time; float playtime; + float menuexpire; struct { diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 7b15ec95..3bc8f40b 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -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(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(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; } diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 8a36a1e4..b1a947e6 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -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; diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 3940c188..9094b27a 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -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); }