My plugin.
Code:
public RaceMenu_Handler(id, menu, item) // there is a hander to another menu... but here is created the problematic menu.
{
if ( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], name[MAX_NAME_LENGTH];
new _acces, item_callback;
menu_item_getinfo(menu, item, _acces, data, charsmax(data), name, charsmax(name), item_callback);
new userid = str_to_num(data);
new player = find_player("k", userid);
if ( player )
{
new name[MAX_NAME_LENGTH];
get_user_name(player, name, charsmax(name));
new Text[121];
formatex(Text, charsmax(Text), "%s challenged you to a race :", name);
new Menu = menu_create(Text, "Answers_SubMenu"); // there is the Menu.
formatex(Text, charsmax(Text), "Accept the challenge." );
menu_additem(Menu, Text, "1", 0);
formatex(Text, charsmax(Text), "No thanks." );
menu_additem(Menu, Text, "2", 0);
menu_setprop(Menu, MPROP_EXIT , MEXIT_ALL);
menu_display(player, Menu, 0);
new index[10];
num_to_str(player, index, charsmax(index));
isnotAfk[player] = false;
set_task(15.0, "Refuse", Menu, index, charsmax(index));
return PLUGIN_HANDLED;
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public Refuse(index[], Menu)
{
new id = str_to_num(index);
if ( !isnotAfk[id] ) // this is for knowing if menu was closed.
{
menu_destroy(Menu); // there menu is destroyed
}
}
but another plugin is sending show_menu( 0, 0, "^n", 1 ); from time to time (i deleted the source and i feel too lazy to recreate it).
now i looked after player_menu_info() and it should solve my problem... but anyway how can i know if this is my menu, not another menu.. because maybe i don't want to close any menu, just my menu.
ps: yea.. this can work too
Code:
....
new auxMenu;
player_menu_info(id, _, auxMenu);
if (myMenu == auxMenu)
{
menu_destroy(auxMenu)
}
...
but this look like a hard way.. a menu_exists can be more usefull, like that :
Code:
...
if (menu_exists(myMenu)) // 1 : 0
{
menu_destroy(myMenu)
}
...
thats my opinion...