Raised This Month: $ Target: $400
 0% 

menu display and destroy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-25-2013 , 12:45   menu display and destroy
Reply With Quote #1

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.

Last edited by GhostMan; 04-25-2013 at 15:12.
GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 14:04   Re: menu display and destroy
Reply With Quote #2

Exactly.

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

- my plugins -
ConnorMcLeod is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-25-2013 , 14:54   Re: menu display and destroy
Reply With Quote #3

What do you mean by saying dynamic? What's the difference between static and dynamic menus?
GhostMan is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-25-2013 , 14:58   Re: menu display and destroy
Reply With Quote #4

Its a identical menu for any players and don't change in any case...
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-25-2013 , 15:09   Re: menu display and destroy
Reply With Quote #5

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

GhostMan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 15:18   Re: menu display and destroy
Reply With Quote #6

Code is correct, if you want to show again menu, don't destroy it.
You could add alive check in SomeMenu function though.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-25-2013 , 15:36   Re: menu display and destroy
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
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

Last edited by GhostMan; 04-25-2013 at 15:42.
GhostMan is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-25-2013 , 16:05   Re: menu display and destroy
Reply With Quote #8

You can add the is_user_alive check in both the menu handler and SomeFunction.
Backstabnoob is offline
Reply


Thread Tools
Display Modes

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 10:49.


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