Raised This Month: $ Target: $400
 0% 

newmenus problem.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
luxor
Member
Join Date: Jan 2014
Old 08-20-2015 , 04:18   Re: newmenus problem.
Reply With Quote #3

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...
luxor is offline
 



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:42.


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