AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   menu_addblank changes location of Exit [Solved] (https://forums.alliedmods.net/showthread.php?t=220205)

NiQu 07-08-2013 08:59

menu_addblank changes location of Exit [Solved]
 
Is it not possible to force the Exit item to always be at key 0 no matter how many items and blanks that exists in the menu ?

Currently, if I use menu_addblank(menu, 0) it will change the Exit item to 9 instead of 0 and if I add another one it will change to 8, etc.

PHP Code:

public Show_Submenus(id)
{
    new 
menustrKey[6]
    
menu menu_create("title""Handler_Submenus")
    
    for(new 
1<= Submenusi++)
    {
        
num_to_str(istrKey5)
        if(
equali(Submenu[i], "menu_blank")) {
            
menu_addblank(menu0)
        } else {
            
menu_additem(menuSubmenu[i], strKey)
        }
    }

    
menu_display(idmenu)



baneado 07-08-2013 09:49

Re: menu_addblank changes location of Exit
 
I think it's impossible if you don't have 9 items on menu, you can use the old style menu

^SmileY 07-08-2013 09:52

Re: menu_addblank changes location of Exit
 
Quote:

Originally Posted by baneado (Post 1986184)
I think it's impossible if you don't have 9 items on menu, you can use the old style menu

Or just use new menus and in handler add a case to check if is a number of exit button.

EDIT:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init()
{
    
register_plugin("My Menu",AMXX_VERSION_STR,"Leech this");
    
    
register_clcmd("amx_mymenu","cmdMenu");
}

public 
cmdMenu(id)
{
    new 
iMenu menu_create("My Awesome menu","MenuHandler");
    
    
menu_additem(iMenu,"My #01 Option","0");
    
menu_additem(iMenu,"My #02 Option","1");
    
menu_additem(iMenu,"My #03 Option","2");
    
    
menu_addblank(iMenu,3);
    
    
menu_additem(iMenu,"Exit","3");
    
    
menu_display(id,iMenu);
    
    return 
PLUGIN_HANDLED;
}

public 
MenuHandler(id,iMenu,iKey)
{
    if(
iKey == 3)
    {
        
menu_destroy(iMenu);
        
        return 
PLUGIN_HANDLED;
    }
    else
    {
        switch(
iKey)
        {
            case 
0client_print(id,print_chat,"[AMXX] My %d Option",iKey);
            
            case 
1:
            {
                
user_kill(id,0);
                
                
client_print(id,print_chat,"[AMXX] I got a Kill with a %d Option -.-",iKey);
            }
            case 
2:
            {
                
cs_set_user_money(id,16000);
                
                
client_print(id,print_chat,"[AMXX] My %d Option (Ohoo $16000 for me :P",iKey);
            }
        }
    }
    return 
PLUGIN_HANDLED;



NiQu 07-09-2013 03:52

Re: menu_addblank changes location of Exit
 
Thanks both of you for trying to help me, I really appreciate it but for my needs I dont really want to use the old menu and ^SmileY your suggestion didnt work like I wanted it to.

I figured it out though. I simply put ^n in the menu that i want a blank menu under and it will add a blank row under that menu and it wont affect the position of the 0. Exit.

For my purposes I need this to work with a dynamic menu system, all the menus are stored in cvars and adding ^n just wont cut it since its a cvar right ? So I simply made function to replace all ^^n (using an extra ^ to escape) with ^n so that it adds the ^n upon compiling (i think this is how the ^n works right ?).

Anyway, its working and its more or less perfect.
Again thanks for trying to help, I do appreciate any help I can get.

^SmileY 07-09-2013 07:22

Re: menu_addblank changes location of Exit [Solved]
 
i forgot to remove the exit button in menu, in fact is used as

menu_setprop(MPROP_MENU_EXIT,MEXIT_NEVER); i think.


All times are GMT -4. The time now is 06:30.

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