amxmodx icon indicating copy to clipboard operation
amxmodx copied to clipboard

native menu_create return 0

Open OsweRRR opened this issue 2 years ago • 2 comments

Hi all, native menu_create really return any value?

/* Plugin generated by AMXX-Studio */

#include <amxmodx>

new const car_used[] = "4runner"

new const cars[][] = {
	"lamborghini",
	"bugatti",
	"4runner",
	"dr650"
}

public plugin_init()
{
	register_clcmd("say t", "test")
}

public test(id)
{
	new menu = menu_create("\rCars \wChoose", "mh_cars")
	
	for(new i = 0; i < sizeof cars; i++)
	{
		menu_additem(menu, fmt("%s", cars[i]), .callback = menu_makecallback("callback_cars"))
	}
	
	menu_setprop(menu, MPROP_EXITNAME, "Exit")
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)
	
	RequestFrame("callback_check_value", menu)
}

public callback_check_value(value)
{
	server_print("%d", value)
}

public callback_cars(id, menu, item)
{
	new sCars[32], iRet = ITEM_IGNORE
	menu_item_getinfo(menu, item, _, _, _, sCars, charsmax(sCars))
	
	if(equal(sCars, car_used))
	{
		add(sCars, charsmax(sCars), " \y(used)")
		
		menu_item_setname(menu, item, sCars)
		
		iRet = ITEM_DISABLED
	}
	return iRet
}

public mh_cars(id, menu, item)
{
	if(item != MENU_MORE && item != MENU_BACK && item != MENU_EXIT && item != MENU_TIMEOUT)
	{
		client_print_color(0, print_team_default, "selected %s", cars[item])
	}
	menu_destroy(menu)
	return 1
}

The only thing that server_print prints is 0

** amxx 1.9 5241 metamod p37 last rehlds release mp original hlds **

OsweRRR avatar Jul 12 '22 02:07 OsweRRR

I seek to store the value returned by menu_create.. to check it later and destroy with menu_destroy

function my_function(menuIndex)
{
	if(menuIndex) // menu_exists( )
	{
		menu_destroy(menuIndex)
	}
}

There is no native like menu_exists, and menu_create returns nothing

OsweRRR avatar Jul 12 '22 02:07 OsweRRR

the first menu is always 0 create 2 menus and read there ids to see the difference Keep in mind that the second u close or choose smt from the meny it gets destroyed. so u have to create 2 menus in the test function

SmirnoffBG avatar Sep 17 '23 14:09 SmirnoffBG