AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking if a menu is open (https://forums.alliedmods.net/showthread.php?t=292938)

safetymoose 01-18-2017 12:23

Checking if a menu is open
 
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?

OciXCrom 01-18-2017 12:59

Re: Checking if a menu is open
 
https://www.amxmodx.org/api/amxmodx/get_user_menu
https://www.amxmodx.org/api/newmenus/player_menu_info

edon1337 01-18-2017 13:26

Re: Checking if a menu is open
 
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



HamletEagle 01-18-2017 13:28

Re: Checking if a menu is open
 
Quote:

Originally Posted by edon1337 (Post 2487769)
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.

edon1337 01-18-2017 14:06

Re: Checking if a menu is open
 
Quote:

Originally Posted by HamletEagle (Post 2487771)
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? ;)

HamletEagle 01-18-2017 14:13

Re: Checking if a menu is open
 
Quote:

Originally Posted by edon1337 (Post 2487781)
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.

edon1337 01-18-2017 16:56

Re: Checking if a menu is open
 
Quote:

Originally Posted by HamletEagle (Post 2487782)
Then he is still viewing the menu so the bool should be true. Not sure to understand your point.

Ah yeah you're right. :)

safetymoose 01-18-2017 17:41

Re: Checking if a menu is open
 
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 (Post 2487769)
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 :D

OciXCrom 01-18-2017 19:31

Re: Checking if a menu is open
 
I'm pretty sure that's client side and can't be detected. What are you trying to do exactly?

safetymoose 01-18-2017 19:55

Re: Checking if a menu is open
 
Quote:

Originally Posted by OciXCrom (Post 2487875)
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 (Post 2487875)
What are you trying to do exactly?

Nothing fancy, just trying to prevent hud messages from overlapping with menus. Thanks a lot tho.


All times are GMT -4. The time now is 20:58.

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