AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to check if menu is open ? (https://forums.alliedmods.net/showthread.php?t=317024)

LearninG 06-22-2019 04:38

how to check if menu is open ?
 
Hi,
I want to know what is best method to check if menu is still open for player example :
PHP Code:

public cancel_menu (id)
{
              if  ( 
// check here if the menu is not closed )                                          
              
{
                         
menu_destroy//what should I do here? )
                         
show_menu(//empty menu)
                   
return PLUGIN_HANDLED


I searched but didn't find anything good.
I know it's easy but I'm new to pawn.

Natsheh 06-22-2019 07:12

Re: how to check if menu is open ?
 
PHP Code:

if(player_menu_infoid, ..... ) == 1)
{
     
//Player has menu!



LearninG 06-22-2019 08:52

Re: how to check if menu is open ?
 
1more question , it is possible to use menu_destroy before show_menu (empty) if yes explain please:
Example:
PHP Code:

public cancel_menu (id)
{
                 
menu_destroymenu )
                 
show_menu(//empty menu)
          
return PLUGIN_HANDLED


I ask this because there is a set_task for public cancel_menu and I want after 20 seconds, menu gets destroyed and disappear from screen.
Thanks

CrazY. 06-22-2019 09:08

Re: how to check if menu is open ?
 
https://forums.alliedmods.net/showth...46364#EndNotes

Natsheh 06-22-2019 11:57

Re: how to check if menu is open ?
 
If the menu / menu items are contansts then destroying the menu and creating it each time Isnt efficient instead just create it one time and destroy it when you got no use for it (one time use per map)

Also you need a valid newmenu id to destroy otherwise it will throw an error.

LearninG 06-22-2019 12:49

Re: how to check if menu is open ?
 
thanks it solved.


All times are GMT -4. The time now is 17:26.

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