Raised This Month: $ Target: $400
 0% 

[HELP] menu_item_getinfo before selection.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 11-18-2015 , 05:23   [HELP] menu_item_getinfo before selection.
Reply With Quote #1

What i'm trying to achieve:

new g_ItemID[33];
g_ItemID[id] = 5;

Before I open the menu with items in it, the code checks integer from g_ItemID[id] and will add \d in front of the menu entry with the integer in it's "info" argument.

PHP Code:
menu_additem(item"doneld duck""1"0);
menu_additem(item"dank kush""2"0);
menu_additem(item"spongebob""3"0);
menu_additem(item"default entry""4"0);
menu_additem(item"\dBat""5"0); // <-- Selected 
How could I achieve this?

Last edited by CodingIsHard; 11-18-2015 at 05:26.
CodingIsHard is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-18-2015 , 06:01   Re: [HELP] menu_item_getinfo before selection.
Reply With Quote #2

How are you exactly creating a menu? Please show us your current code.
klippy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-18-2015 , 06:31   Re: [HELP] menu_item_getinfo before selection.
Reply With Quote #3

PHP Code:
new szItem[64]
formatex(szItemcharsmax(szItem), "%sBat"g_ItemID == "\d" "")
menu_additem(itemszItem"5"0

Last edited by OciXCrom; 11-18-2015 at 06:31.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-18-2015 , 13:55   Re: [HELP] menu_item_getinfo before selection.
Reply With Quote #4

I would probably go with something like this (untested):
PHP Code:
new const MENU_OPTIONS[][] =
{
    
"Option 69",
    
"Option 420",
    
"Option 1337",
    
"So many options, wow"
};

// Set everything to -1 so there's no gray option by default. Is this the desired behaviour?
new g_ItemID[33] = {-1, ...};

displayMenu(id)
{
    new 
menu menu_create("Best menu ever""AwesomeMenuHandler");
    new 
buffer[64];
    
    for(new 
0sizeof(MENU_OPTIONS); i++)
    {
        
formatex(buffercharsmax(buffer), "\%c%s", (g_ItemID == 'd' 'w'), MENU_OPTIONS[i]);
        
menu_additem(menubuffer);
    }
    
    
menu_display(idmenu);

klippy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-18-2015 , 20:49   Re: [HELP] menu_item_getinfo before selection.
Reply With Quote #5

Since you are using "newmenus.inc", this should be done using a callback.
__________________
fysiks is offline
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 18:14.


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