AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menus keep closing (https://forums.alliedmods.net/showthread.php?t=118320)

r4ndomz 02-09-2010 21:28

Menus keep closing
 
I made a plugin earlier with emps menu tutorial and when i press an option the menu closes. How should i fix it? I tried to my opinion alot of ways

fysiks 02-09-2010 21:46

Re: Menus keep closing
 
Quote:

Originally Posted by r4ndomz (Post 1084167)
I made a plugin earlier with emps menu tutorial and when i press an option the menu closes. How should i fix it? I tried to my opinion alot of ways

When you select an option it is supposed to close.

wrecked_ 02-09-2010 22:16

Re: Menus keep closing
 
Quote:

Originally Posted by r4ndomz (Post 1084167)
I made a plugin earlier with emps menu tutorial and when i press an option the menu closes. How should i fix it? I tried to my opinion alot of ways

Like fysiks said, it's supposed to close. If you want to be able to choose another item from the same menu prior to your first choice, in the case handler, just execute the things that you want to happen and then re-display the menu.

PHP Code:

#include <amxmodx>

new m_YourMenu;

new const 
VERSION[] = "0.0.1";

public 
plugin_init() {
    
register_plugin"Menu Example"VERSION"wrecked_" );
    
    
register_clcmd"say /menu""cmd_Menu" );
}

public 
cmd_Menuid )
{
    
m_YourMenu menu_create"Example Menu""cmd_MenuHandler" );
    
    
menu_additemm_YourMenu"Example #1""1");
    
menu_additemm_YourMenu"Example #2""2");
    
    
menu_setpropm_YourMenuMPROP_EXITMEXIT_ALL );
    
    
menu_displayidm_YourMenu);
    
    return 
PLUGIN_CONTINUE;
}

public 
cmd_MenuHandleridm_YourMenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroym_YourMenu );
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
sz_Name[64];
    new 
sz_Data[64];
    new 
access;
    new 
callback;
    
    
// All that good stuff
    
menu_item_getinfom_YourMenuitemaccesssz_Data5sz_Name63callback );
    
    new 
key str_to_numsz_Data );
    
    switch( 
key )
    {
        case 
1:
        {
            
// Your Stuff
            
            
menu_displayidm_YourMenu);
        }
        
        case 
2:
        {
            
// Your Stuff
            
            
menu_displayidm_YourMenu);
        }
        
        
// ...
    
}



r4ndomz 02-10-2010 15:36

Re: Menus keep closing
 
Yea but when i do that it takes me back to the main menu and the menu doesnt update either (like theres an if statement in the code and its value changed)

wrecked_ 02-10-2010 15:39

Re: Menus keep closing
 
Then make it display the menu that you want instead of the main menu example,
PHP Code:

menu_displayidsubmenu

and just change that value that you want in the original menu declaration function...

r4ndomz 02-10-2010 15:48

Re: Menus keep closing
 
Yes but i only have one menu with two pages. How would i make it display the menu page it was on?

wrecked_ 02-10-2010 15:50

Re: Menus keep closing
 
PHP Code:

menu_displayidmainmenu)
/*
    Parameters:
    1) Player Index
    2) Menu
    3) Page - 0 is the first, 1 is the second, etc.
*/ 


r4ndomz 02-10-2010 16:06

Re: Menus keep closing
 
Ok ty, but how do i update the menu? i dont really get what you said before. Can you explain a little bit more?

wrecked_ 02-10-2010 16:08

Re: Menus keep closing
 
Post your menu creation function.

ex: Where you did
PHP Code:

public cmd_MenuCreationid )
{
    new 
menu menu_create"Example Menu""cmd_MenuHandler" )

    
// ...



r4ndomz 02-10-2010 16:11

Re: Menus keep closing
 
PHP Code:

public AwsomeMenu(id)
{
    new 
noclip get_user_noclip(id)
    new 
godmode get_user_godmode(id)
    new 
footsteps get_user_footsteps(id)

    
#if SM_ADMIN == 1
        
if( !( get_user_flags(id) & ADMIN_FLAG ) )
        {
            return
        }
    
#endif
    
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        
// Didnt think it wouldnt give me errors
    
}
    else
    {
        
client_print(idprint_chat"You need to be in Spec to use this")
        return 
PLUGIN_CONTINUE
    
}

    new 
menu menu_create("\ySpec Menu by r4nDoMz""menu_handler");

    if(
noclip == 1)
    {
        
menu_additem(menu,"\wNoclip: \yON""1"0);
    }
    else
    {
        
menu_additem(menu,"\wNoclip: \yOFF""1"0);
    }

    if(
godmode == 1)
    {
        
menu_additem(menu,"\wGodmode: \yON""2"0);
    }
    else
    {
        
menu_additem(menu,"\wGodmode: \yOFF""2"0);
    }

    if(
footsteps == 1)
    {
        
menu_additem(menu,"\wSilent walk: \yON""3"0);
    }
    else
    {
        
menu_additem(menu,"\wSilent walk: \yOFF""3"0);
    }
    
menu_additem(menu,"\wRevive""4"0);
    
menu_additem(menu,"\wLow Gravity""5"0);
    
menu_additem(menu,"\wDefault Gravity""6"0);
    
menu_additem(menu,"\wNades...He/Flash/Smoke""7"0);
    
menu_additem(menu,"\wRoad Runner(Fast run)""8"0);
    
menu_additem(menu,"\wSpeed Boost""9"0);
    
menu_additem(menu,"\wThirdperson""10"0);
    
menu_additem(menu,"\wFirstperson""11"0);
    
menu_additem(menu,"\wSuperjump""12"0);


    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

    return 
PLUGIN_CONTINUE




All times are GMT -4. The time now is 07:23.

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