AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   menu display and destroy (https://forums.alliedmods.net/showthread.php?t=214323)

GhostMan 04-25-2013 12:45

menu display and destroy
 
1.
PHP Code:

    if(item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    


This means if i choose exit button in menu (mostly its buttom 0 in keyboard) so all data about this menu is deleted?

2. Second question in this post.

ConnorMcLeod 04-25-2013 14:04

Re: menu display and destroy
 
Exactly.

If your menu is not dynamic, create it in plugin_init and do never use destroy.

GhostMan 04-25-2013 14:54

Re: menu display and destroy
 
What do you mean by saying dynamic? What's the difference between static and dynamic menus?

^SmileY 04-25-2013 14:58

Re: menu display and destroy
 
Its a identical menu for any players and don't change in any case...

GhostMan 04-25-2013 15:09

Re: menu display and destroy
 
So if it's separated by the teams (Ts see one options and CTs others) so it's dynamical?

One more common question.
Is it correct way to display same menu again after players choise (want to make multiple choises from menu)

PHP Code:

public SomeMenu(id)
{
    new 
menu menu_create("\yNAME OF MENU""menu_handler")
    
    
menu_additem(menu"\wOption 1""1"0)
    
    
menu_additem(menu"\wOption 2""2"0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT || !is_user_alive(id))
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
Data[7], Name[64]
    new 
AccessCallback
    menu_item_getinfo
(menuitemAccessData,5Name63Callback)
    
    new 
Key str_to_num(Data)
    
    switch (
Key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Hello !")
            
menu_display(idmenu0)
        }
        
        case 
2:
        {
            
client_print(idprint_chat"Hello !!")
            
menu_display(idmenu0)
        }
        
    return 
PLUGIN_HANDLED



ConnorMcLeod 04-25-2013 15:18

Re: menu display and destroy
 
Code is correct, if you want to show again menu, don't destroy it.
You could add alive check in SomeMenu function though.

GhostMan 04-25-2013 15:36

Re: menu display and destroy
 
Quote:

Originally Posted by ConnorMcLeod (Post 1939897)
You could add alive check in SomeMenu function though.

But if player types /menu and he dies when menu still open, then if i would be useing something like give_item in menu_handler i should get some errors becouse of "wrong player index" or something..

Anyways i make both alive check in SomeMenu and menu_handler just to be sure :D

Backstabnoob 04-25-2013 16:05

Re: menu display and destroy
 
You can add the is_user_alive check in both the menu handler and SomeFunction.


All times are GMT -4. The time now is 10:49.

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