Raised This Month: $ Target: $400
 0% 

Menu remaking


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 08-12-2013 , 07:13   Menu remaking
Reply With Quote #1

I have code with two menus, could anyone help to do everything in one menu?

PHP Code:
#include <amxmodx>

#define Max 4

new SelUnlocked[Max]
new 
SelSelected[33]

new 
PlayerPts[33]

new const 
Selections[Max][] = { "First""Second""Third""Fourth" }
new const 
SelCosts[Max] = { 10030050500 }

public 
plugin_init()
{
    
register_clcmd("say /menu""Main_plMenu")
    
register_clcmd("say /menu2""Main_plMenu2")

    
register_clcmd("say /pts""GivePts")
}

public 
GivePts(id)
{
    
PlayerPts[id] += 100
}

public 
Main_plMenu(id)
{
    new 
Menu menu_create("\rSelections to unlock:""plMenu")

    for (new 
0Maxi++)
    {
        new 
Items[512], TempID[32]

        if (
PlayerPts[id] >= SelCosts[i])
        {
            
formatex(Itemscharsmax(Items), "\y%s \d[\w%d Pts\d]"Selections[i], SelCosts[i])

            
num_to_str(iTempIDcharsmax(TempID))

            
menu_additem(MenuItemsTempID0)
        }
        else
        {
            
formatex(Itemscharsmax(Items), "\d%s [\r*LOCKED* Need %i Pts\d]"Selections[i], SelCosts[i])
            
menu_additem(MenuItems"999"0menu_makecallback("Callback_Menu"))
        }
    }
    
menu_setprop(MenuMPROP_EXITMEXIT_ALL)
    
menu_display(idMenu0)
}

public 
plMenu(idMenuItem)
{
    if (
Item == MENU_EXIT
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}

    new 
Data[6], iName[64]
    new 
AccessCallback
    menu_item_getinfo
(MenuItemAccessData5iName63Callback)

    new 
Key str_to_num(Data)

    
PlayerPts[id] -= SelCosts[Key]

    
SelUnlocked[Key] = true

    PrintColor
(id"You unlocked %s Selection!"Selections[Key])

    return 
PLUGIN_HANDLED
}

public 
Main_plMenu2(id)
{
    new 
Menu menu_create("\rSelections to switch:""plMenu2")

    for (new 
0Maxi++)
    {
        new 
Items[512], TempID[32]

        if (
SelUnlocked[i])
        {
            if (
SelSelected[id] == i)
            {
                
formatex(Itemscharsmax(Items), "\d%s [\rSelected\d]"Selections[i])
                
menu_additem(MenuItems"999"0menu_makecallback("Callback_Menu"))
            }
            else
            {
                
formatex(Itemscharsmax(Items), "\y%s"Selections[i])

                
num_to_str(iTempIDcharsmax(TempID))

                
menu_additem(MenuItemsTempID0)
            }
        }
        else
        {
            
formatex(Itemscharsmax(Items), "\d%s [\r*LOCKED* Need %i Pts\d]"Selections[i], SelCosts[i])
            
menu_additem(MenuItems"999"0menu_makecallback("Callback_Menu"))
        }

    }
    
menu_setprop(MenuMPROP_EXITMEXIT_ALL)
    
menu_display(idMenu0)
}

public 
plMenu2(idMenu Item)
{
    if (
Item == MENU_EXIT
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}

    new 
Data[6], iName[64]
    new 
AccessCallback
    menu_item_getinfo
(MenuItemAccessData5iName63Callback)

    new 
Key str_to_num(Data)

    
SelSelected[id] = Key

    PrintColor
(id"You Selected %s Selection!"Selections[Key])

    
menu_destroy(Menu)
    return 
PLUGIN_HANDLED
}

public 
Callback_Menu(idMenuItem)
{
    return 
ITEM_DISABLED

~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 14:18   Re: Menu remaking
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=154538

I don't understand what you want. Explain how the menu should work exactly.
__________________
Black Rose is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 08-13-2013 , 14:35   Re: Menu remaking
Reply With Quote #3

You see two menu, I need to join theses menu to one
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 17:58   Re: Menu remaking
Reply With Quote #4

Before my answer I just want to show people how a GOOD explanation looks like.
Quote:
Originally Posted by ~Ice*shOt
--------------------------------------------------
Here is main menu.
--------------------------------------------------
// All theses disabled
1. First [ Need 200 $ ]
2. Second [ Need 600 $ ]
3. Third [ Need 800 $ ]
4. Fourth [ Need 300 $ ]
--------------------------------------------------
For example I have 200 $ and press #1.
--------------------------------------------------
// #1 enabled, others disabled
1. First
2. Second [ Need 600 $ ]
3. Third [ Need 800 $ ]
4. Fourth [ Need 300 $ ]
--------------------------------------------------
Again press #1.
--------------------------------------------------
// All theses disabled
1. First [ Selected ]
2. Second [ Need 600 $ ]
3. Third [ Need 800 $ ]
4. Fourth [ Need 300 $ ]
--------------------------------------------------
Now I have collected 300 $ and press #4
--------------------------------------------------
// #4 enabled, others disabled
1. First [ Selected ]
2. Second [ Need 600 $ ]
3. Third [ Need 800 $ ]
4. Fourth
--------------------------------------------------
Again press #4
--------------------------------------------------
// #1 enabled, others disabled
1. First
2. Second [ Need 600 $ ]
3. Third [ Need 800 $ ]
4. Fourth [ Selected ]
//////////////
All this I've in two menus.. one needed
Here's my result:


This code won't allow you to chose "nothing" as soon as you chose something. Is that something you need?
And here is the code:
Code:
#include <amxmodx> #define MENUITEM_DISABLED   (1<<26) enum enumSelections {     name[32],     cost } new const g_Selections[][enumSelections] = {     { "First" , 100 },     { "Second" , 300 },     { "Third" , 50 },     { "Fourth" , 500 } }; new bool:g_Unlocked[33][sizeof g_Selections]; new g_Selected[33]; new g_Points[33]; public plugin_init() {     register_plugin("Dual Action Menu", "1.0", "[ --{-@ ]");     register_clcmd("menu", "cmd_menu");     register_clcmd("say /pts", "GivePts"); } public client_connect(id) {     g_Points[id] = 0;     g_Selected[id] = -1; } public GivePts(id) {     g_Points[id] += 100; } public cmd_menu(id) {     new menu = menu_create("\rHello pirate!", "menu_handler")     for ( new i = 0; i < sizeof g_Selections ; i++ ) {         new menuitem[64], menuitem_disable = 0;                 if ( g_Selected[id] == i ) {             formatex(menuitem, charsmax(menuitem), "\d%s   [SELECTED]", g_Selections[i][name])             menuitem_disable = MENUITEM_DISABLED;         }         else if ( g_Unlocked[id][i] )             formatex(menuitem, charsmax(menuitem), "\y%s", g_Selections[i][name])         else if ( g_Points[id] < g_Selections[i][cost] ) {             formatex(menuitem, charsmax(menuitem), "\d%s   \d[\r%d Pts\d]", g_Selections[i][name], g_Selections[i][cost])             menuitem_disable = MENUITEM_DISABLED;         }         else             formatex(menuitem, charsmax(menuitem), "\y%s   \d[\w%d Pts\d]", g_Selections[i][name], g_Selections[i][cost])                 menu_additem(menu, menuitem, "", menuitem_disable);     }         menu_display(id, menu, 0) } public menu_handler(id, menu, item) {     if ( item == MENU_EXIT ) {         menu_destroy(menu)         return PLUGIN_HANDLED     }         if ( g_Unlocked[id][item] ) {             g_Selected[id] = item;         client_print(id, print_chat, "You have selected %s", g_Selections[item][name]);                 return PLUGIN_CONTINUE     }         g_Points[id] -= g_Selections[item][cost];     g_Unlocked[id][item] = true;         client_print(id, print_chat, "You have unlocked %s", g_Selections[item][name]);         return PLUGIN_HANDLED }
Attached Thumbnails
Click image for larger version

Name:	pirate_menu.jpg
Views:	311
Size:	16.0 KB
ID:	124244  
__________________

Last edited by Black Rose; 08-13-2013 at 18:02.
Black Rose is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 08-14-2013 , 04:25   Re: Menu remaking
Reply With Quote #5

OMG Man, you're awesome. Thanks a lot! It's exactly what i need.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
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 15:55.


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