Raised This Month: $51 Target: $400
 12% 

Checking if a menu is open


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-18-2017 , 12:23   Checking if a menu is open
Reply With Quote #1

Hey everyone,

Does anyone know if there is anything to check if a player is in a menu? Whether it's amxmodmenu, a game menu, or any other menu from other plugins..

Is there a way to check if a menu is open and displayed to a player?
safetymoose is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-18-2017 , 12:59   Re: Checking if a menu is open
Reply With Quote #2

https://www.amxmodx.org/api/amxmodx/get_user_menu
https://www.amxmodx.org/api/newmenus/player_menu_info
__________________

Last edited by OciXCrom; 01-18-2017 at 13:00.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 13:26   Re: Checking if a menu is open
Reply With Quote #3

Make a global bool "g_MenuActive[33];" then after menu_display put "g_MenuActive[id] = true", don't forget to put "g_MenuActive[id] = false" on Ham_Spawn and after menu is closed (menu_destroy). This can be used only when menu comes from that plugin.

So if you want to check you'd do
PHP Code:
if(g_MenuActive[id]) {
// code

__________________

Last edited by edon1337; 01-18-2017 at 14:08.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-18-2017 , 13:28   Re: Checking if a menu is open
Reply With Quote #4

Quote:
Originally Posted by edon1337 View Post
Make a global bool "g_MenuActive[33];" then after menu_display put "g_MenuActive[id] = true", don't forget to put "g_MenuActive[id] = false" on Ham_Spawn.

So if you want to check you'd do
PHP Code:
if(g_MenuActive[id]) {
// code

That's not what he is asking for. What if the menu comes from other plugin?
Also resetting on spawn is wrong, you should reset as soon as the menu is closed.
__________________

Last edited by HamletEagle; 01-18-2017 at 13:28.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 14:06   Re: Checking if a menu is open
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
That's not what he is asking for. What if the menu comes from other plugin?
Also resetting on spawn is wrong, you should reset as soon as the menu is closed.
I was on about when the menu comes from that plugin, yeah it should be reset directly when menu gets closed but in Ham_Spawn too because what if a player doesn't close the menu? ;)
__________________

Last edited by edon1337; 01-18-2017 at 14:08.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-18-2017 , 14:13   Re: Checking if a menu is open
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
I was on about when the menu comes from that plugin, yeah it should be reset directly when menu gets closed but in Ham_Spawn too because what if a player doesn't close the menu? ;)
Then he is still viewing the menu so the bool should be true. Not sure to understand your point.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 16:56   Re: Checking if a menu is open
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
Then he is still viewing the menu so the bool should be true. Not sure to understand your point.
Ah yeah you're right.
__________________
edon1337 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-18-2017 , 17:41   Re: Checking if a menu is open
Reply With Quote #8

player_menu_info did the trick. I was trying get_user_menu and for some reason it wasn't working. It wasn't detecting the menus properly, not sure why.

Thank you OciXCrom.

The only thing that player_menu_info didnt detect was the menu from the radio commands. Any idea how to catch that?

Quote:
Originally Posted by edon1337 View Post
Make a global bool "g_MenuActive[33];" then after menu_display put "g_MenuActive[id] = true", don't forget to put "g_MenuActive[id] = false" on Ham_Spawn and after menu is closed (menu_destroy). This can be used only when menu comes from that plugin.

So if you want to check you'd do
PHP Code:
if(g_MenuActive[id]) {
// code

If i were to do that, i'd have to edit every single one of the plugins that use menus. I considered it, but not worth the effort
safetymoose is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-18-2017 , 19:31   Re: Checking if a menu is open
Reply With Quote #9

I'm pretty sure that's client side and can't be detected. What are you trying to do exactly?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-18-2017 , 19:55   Re: Checking if a menu is open
Reply With Quote #10

Quote:
Originally Posted by OciXCrom View Post
I'm pretty sure that's client side and can't be detected.
Alright, i guess i'm done then.

Quote:
Originally Posted by OciXCrom View Post
What are you trying to do exactly?
Nothing fancy, just trying to prevent hud messages from overlapping with menus. Thanks a lot tho.
safetymoose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode