Raised This Month: $ Target: $400
 0% 

[Help] Menu Problems


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
kDiosn
Member
Join Date: Sep 2010
Old 05-07-2011 , 05:36   [Help] Menu Problems
Reply With Quote #1

hello modders!
i'm not know how to explain what i'm trying to do, but i will do my best.

OT: i want it so when i open the menu (weaponmenu) i will show
1. awp
2. deagle
3. fiveseven
4. he grenade
5. smokegrenade
6. heatseeking he

when i press 1/2/3 it will open the submenus for awp,deagle and fiveseven. and when i press 4/5/6 i will buy a lvl. (he,smoke, heatseek)
but now to my problem, the menu is showed like it is suppossed to do, but when i press 1 i buy first lvl of hegrenade, and when i press 2 i buy first lvl of smokegrenade :S i hope you understood what i meant.

Regards, kDiosn
Code:
enum _:g_iGrenCount
{
    HE_GRENADE,
    SMOKEGRENADE,
    Heatseek_HE,
}
public WeaponMenu(iPlayer, menu, item)
{
         //Menu Title
    new title[170]; formatex(title, sizeof(title) - 1, "\w- \y[MoneyMod] \wWeapon Shop -^n^n    \wYou Got: \y%i Euro's", g_iMoney[iPlayer]);
    //Create the menu
    new menu = menu_create(title, "WeaponMenu_Handle");
    new iNumber[5], iCost, szOption[80], Amount, Level, Level2;
    
    
    menu_additem(menu, "\wAwp Menu", "1", 0);
        menu_additem(menu, "\wDeagle Menu", "2", 0);
        menu_additem(menu, "\wFiveseven Menu", "3", 0);
    
    //Browse through all menu items
    for( new iGren = 0; iGren < g_iGrenCount; iGren++ )
    {
        //Bunch of variables
        num_to_str(iGren, iNumber, 4);
        Level = g_iGrenLevel[iPlayer][iGren];
        Level2 = g_iGrenLevel[iPlayer][iGren] + 1;
        iCost = g_iFirstGCost[iGren] * (1 << (Level2 - 1));
        Amount = g_iGrenMaxVal[iGren] * g_iGrenLevel[iPlayer][iGren] / g_iGrenMaxLevel[iGren];
        
        //If the player already have maxlevel
        if( g_iGrenLevel[iPlayer][iGren] >= g_iGrenMaxLevel[iGren] )
        {
            if( g_iGrenClass[iGren] == 2 )
            {
                formatex(szOption, 79, "");
            }
            else
            {
                formatex(szOption, 79, "\y%s: \wLevel %i \r(\d%i%s\r)", g_iGren[iGren], Level, Amount, g_iGrenShort[iGren]);
            }
        }
        //If the player cant afford the item
        else if( g_iMoney[iPlayer] < iCost )
        {
            if( g_iGrenClass[iGren] == 2 )
            {
                formatex(szOption, 79, "");
            }
            else
            {
                formatex(szOption, 79, "\d%s: \wLevel %i \r(\d%i%s\r) \y%i$", g_iGren[iGren], Level, Amount, g_iGrenShort[iGren], iCost);
            }
        }
        //If the player has not maxed out the item
        else if( g_iGrenLevel[iPlayer][iGren] < g_iGrenMaxLevel[iGren] )
        {
            if( g_iGrenClass[iGren] == 2 )
            {
                formatex(szOption, 79, "");
            }
            else
            {
                formatex(szOption, 79, "\r%s: \wLevel %i \r(\d%i%s\r) \y%i$", g_iGren[iGren], Level, Amount, g_iGrenShort[iGren], iCost);
            }
        }
        
        //Add all the menu items
        if( g_iGrenClass[iGren] == 2 )
        {
            menu_addblank(menu, 0);
        }
        else
        {
            menu_additem(menu, szOption, iNumber);
        }
        
    
        
    }
    
    //Display the menu
    menu_display(iPlayer, menu, 0);
}

public WeaponMenu_Handle(iPlayer, menu, item)
{
    //Get the menu data
    if( item == MENU_EXIT )
    {
        menu_destroy(menu);
        WeaponMenu(iPlayer, menu, item);
        return PLUGIN_HANDLED;
    }

    //Bunc of variables
    new data[6], iName[64];
    new num[6];
    new access, callback;
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
    
    new key = str_to_num(num);
    switch(key)
    {
        
        case 1:
        {
            AwpMenu(iPlayer);
        }
        case 2:
        {
            DglMenu(iPlayer);
        }
        case 3:
        {
            FsMenu(iPlayer);
        }
    }
    
    new iGren = str_to_num( data ), iCost, Level;
    Level = g_iGrenLevel[iPlayer][iGren] + 1;
    iCost = g_iFirstGCost[iGren] * (1 << (Level - 1));
    
    //If player has maxed out the item
    if( g_iGrenLevel[iPlayer][iGren] == g_iGrenMaxLevel[iGren] )
    {
        Print(iPlayer, "^x03You have the max level of %s!", g_iGren[iGren]);
    }
    //If the player cant afford the item
    else if( g_iMoney[iPlayer] < iCost )
    {
        Print(iPlayer, "^x03You dont have enough Money to buy %s Level: %i", g_iGren[iGren], Level);
    }
    //Take money, Print and give level
    else
    {
        //Take money
        g_iMoney[iPlayer] -= iCost;
        
        //Give a level
        g_iGrenLevel[iPlayer][iGren] += 1;
        
        //Print out to the player that he/she bought an item with corresponding level
        Print(iPlayer, "^x03You bought %s Level: %i", g_iGren[iGren], Level);
    }
    
    
    menu_display(iPlayer, menu, 0);
    return PLUGIN_HANDLED;
}
kDiosn is offline
 


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 04:24.


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