alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
494 stars 197 forks source link

Feature Request: ML Keys for static menus & items titles #590

Closed wopox1337 closed 6 years ago

wopox1337 commented 6 years ago

Help us help you

Environment

Description

I have a suggestion for creating static menus. We may use the 3rd argument of an native menu_create. And when we use .ml = true - menu should use title names as ML Keys. Simple code example below.

Problematic Code (or Steps to Reproduce)

  #include <amxmodx>

new g_hMenu;
new g_hMenuCB;

public plugin_init()
{
    register_plugin("Static menu ML tests", "0.0.1", "wopox1337");
    register_dictionary("static_menu_test.txt");

    Build_StaticMenu();

    register_clcmd("radio1", "CMD_MenuTest");
    // register_clcmd("say /MenuTest", "CMD_MenuTest");
}

Build_StaticMenu()
{
    g_hMenu = menu_create("MENU_NAME", "MenuHandler_1", .ml = true); // ml parameter not used now.
    g_hMenuCB = menu_makecallback("MenuCallback");

/*
 * This is way how i want to create items & menus. And ML at this moment don't works.
 */
    menu_additem(g_hMenu, "ITEM_0", .callback = g_hMenuCB);
    menu_additem(g_hMenu, "ITEM_1", .callback = g_hMenuCB);
    menu_additem(g_hMenu, "ITEM_2", .callback = g_hMenuCB);
    menu_additem(g_hMenu, "ITEM_3", .callback = g_hMenuCB);
    menu_additem(g_hMenu, "ITEM_4", .callback = g_hMenuCB);
}

public MenuCallback(id, menu, item)
{
    new name[32], _dummy[1];
    menu_item_getinfo(menu, item, _dummy[0], _dummy, charsmax(_dummy), name, charsmax(name), _dummy[0]);

/** This is wrong way to dinamicly set item name cuz name
 * will be re-setted each time & ML Key willn't found.
 */
//    menu_item_setname(menu, item, fmt("%l", name));
}

public MenuHandler_1(id, menu, item)
{
    // server_print("-> MenuHandler_1(%i, %i, %i)", id, menu, item);
}

public CMD_MenuTest(id)
{
    menu_display(id, g_hMenu);
    return PLUGIN_HANDLED;
}

Logs

Not needed now.

Arkshine commented 6 years ago

Looks like they planned at some point to add a way to translate items with this ml param. Should be okay to implement that.