View Single Post
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-21-2014 , 04:55   Re: menu_item_getinfo function problem
Reply With Quote #10

The menu is build on the initialisation with the function menu_create.
Code:
public plugin_init()
{
(...)
	g_MainMenu = menu_create("CSDM Menu", "use_csdm_menu")
(...)
}

public use_csdm_menu(id, menu, item)
{
	if (item < 0)
		return PLUGIN_CONTINUE
	
	new command[48], paccess, call
	if (!menu_item_getinfo(g_MainMenu, item, paccess, command, 47, _, 0, call))
	{
		log_amx("Error: csdm_menu_item() failed (menu %d) (page %d) (item %d)", g_MainMenu, 0, item)
		return PLUGIN_HANDLED
	}
	if (paccess && !(get_user_flags(id) & paccess))
	{
		client_print(id, print_chat, "You do not have access to this menu option.")
		return PLUGIN_HANDLED
	}

	if (equali(command,"csdm_ctrl"))
	{
		csdm_ctrl(id, paccess, 0)
		return PLUGIN_HANDLED
	}
	else if (equali(command,"csdm_st_menu"))
	{
		csdm_st_menu(id, paccess, 0)
		return PLUGIN_HANDLED
	}
	else if (equali(command,"csdm_reload"))
	{
		csdm_reload(id, paccess, 0)
		return PLUGIN_HANDLED
	}

//	client_cmd(id, command)
	
	return PLUGIN_HANDLED
}
As You can see there can be only one function written to handle one menu. If in the same menu there are other items added from other plugins (with the function menu_additem), the function use_csdm_menu cannot predict what natives might be used overthere, to handle them (and do corresponding reaction on the user action). So this is why it was called client_cmd (commented out by me for tests here). Maybe there is a way to call also some unnamed function, depanding on what "command" comes with from other plugin.

In the main plugin there are some natives, like:
Code:
public plugin_natives()
{
	register_native("csdm_main_menu", "native_main_menu")
	register_native("csdm_settings_menu", "native_settings_menu")
	register_native("csdm_set_mainoption", "__csdm_allow_option")
	register_native("csdm_fwd_drop", "__csdm_fwd_drop")
	register_native("csdm_write_cfg", "native_write_cfg")
	register_library("csdm_main")
}

public native_main_menu(id, num)
{
	return g_MainMenu
}

public native_settings_menu(id, num)
{
	return g_SettingsMenu
}
What exactly should I write in the main plugin and what in other plugins to get them communicate correctly and use one menu called and handled from the main plugin?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.

Last edited by KWo; 05-21-2014 at 04:56.
KWo is offline