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

Solved Opening a menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadow728988
Member
Join Date: Sep 2017
Old 08-08-2019 , 08:55   Opening a menu
Reply With Quote #1

How can i make it so that only one admin at a time is able to access the menu from a plugin.
For eg.
Code:
public checkformenu(id)
{
   if(menuopen==true)
     {
        client_print(id, "An admin is already using the menu")
      }
   else
        openmenu(id)
}
thank you for your help.

Last edited by shadow728988; 08-09-2019 at 01:09.
shadow728988 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-08-2019 , 09:00   Re: Opening a menu
Reply With Quote #2

Post in Suggestion/Requests section if you don't know how to script.
PHP Code:
new bool:g_bMenuOpen;

public 
Menuid )
{
    if( 
g_bMenuOpen )
    {
        
client_printidprint_chat"Menu is already being used by another admin" );
        return 
PLUGIN_HANDLED;
    }
    
    
g_bMenuOpen true;
    
    new 
iMenu menu_create"Menu Title""MenuHandler" );
    
    
menu_additemiMenu"Item1" );
    
menu_additemiMenu"Item2" );
    
menu_additemiMenu"Item3" );
    
    
menu_displayidiMenu);
}

public 
MenuHandleridiMenuiItem )
{
    
g_bMenuOpen false;

    
// code

__________________
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-08-2019 , 10:27   Re: Opening a menu
Reply With Quote #3

This false due to menu override.

Check in a loop if a player has that menu opened.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-08-2019 , 11:00   Re: Opening a menu
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
This false due to menu override.

Check in a loop if a player has that menu opened.
What do you mean by 'menu override', he didn't mention creating multiple menus
__________________
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-08-2019 , 11:50   Re: Opening a menu
Reply With Quote #5

Menu override means opening a new menu while the old menu is being displayed which result in not calling the handler of the old menu that were displayed.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-08-2019 at 11:52.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-08-2019 , 12:16   Re: Opening a menu
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
Menu override means opening a new menu while the old menu is being displayed which result in not calling the handler of the old menu that were displayed.
So how does looping through all players help in any way?
__________________
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-08-2019 , 12:49   Re: Opening a menu
Reply With Quote #7

To check if a player has the menu opened.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Mistrick
Senior Member
Join Date: Aug 2012
Location: Russia
Old 08-08-2019 , 14:49   Re: Opening a menu
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
Menu override means opening a new menu while the old menu is being displayed which result in not calling the handler of the old menu that were displayed.
You are wrong. AMXX closes menu when someone want to show another menu.
https://github.com/alliedmodders/amx...modx.cpp#L1306
https://github.com/alliedmodders/amx...modx.cpp#L1316
https://github.com/alliedmodders/amx...menus.cpp#L862
Mistrick is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-08-2019 , 16:07   Re: Opening a menu
Reply With Quote #9

Seems like it was an old bug not sure if it was fixed in v182

https://forums.alliedmods.net/showthread.php?p=407839


Still it will be much better to use player_menu_info to check if the user has the menu displayed since it covers most cases.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-08-2019 at 16:17.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 12:14.


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