AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] menu_item_getinfo before selection. (https://forums.alliedmods.net/showthread.php?t=274930)

CodingIsHard 11-18-2015 05:23

[HELP] menu_item_getinfo before selection.
 
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?

klippy 11-18-2015 06:01

Re: [HELP] menu_item_getinfo before selection.
 
How are you exactly creating a menu? Please show us your current code.

OciXCrom 11-18-2015 06:31

Re: [HELP] menu_item_getinfo before selection.
 
PHP Code:

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


klippy 11-18-2015 13:55

Re: [HELP] menu_item_getinfo before selection.
 
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);



fysiks 11-18-2015 20:49

Re: [HELP] menu_item_getinfo before selection.
 
Since you are using "newmenus.inc", this should be done using a callback.


All times are GMT -4. The time now is 18:14.

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