Raised This Month: $ Target: $400
 0% 

menu_addblank changes location of Exit [Solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NiQu
Veteran Member
Join Date: Nov 2009
Old 07-08-2013 , 08:59   menu_addblank changes location of Exit [Solved]
Reply With Quote #1

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)

__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]

Last edited by NiQu; 07-09-2013 at 03:53.
NiQu is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-08-2013 , 09:49   Re: menu_addblank changes location of Exit
Reply With Quote #2

I think it's impossible if you don't have 9 items on menu, you can use the old style menu
baneado is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-08-2013 , 09:52   Re: menu_addblank changes location of Exit
Reply With Quote #3

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

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-08-2013 at 10:01.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
NiQu
Veteran Member
Join Date: Nov 2009
Old 07-09-2013 , 03:52   Re: menu_addblank changes location of Exit
Reply With Quote #4

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.
__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]
NiQu is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-09-2013 , 07:22   Re: menu_addblank changes location of Exit [Solved]
Reply With Quote #5

i forgot to remove the exit button in menu, in fact is used as

menu_setprop(MPROP_MENU_EXIT,MEXIT_NEVER); i think.
__________________
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
Reply



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 06:30.


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