// [BTE Menu FUNCTION]
public cmd_wpn_menu_gui(id)
{
	new sCmd[3];
	read_argv(1,sCmd,3);
	new type = str_to_num(sCmd);
	read_argv(2,sCmd,3);
	new page = str_to_num(sCmd);
	
	new senddata[256]
	for(new i=0;i<9;i++)
	{
		if(i + page * 9<=g_wpn_menu_count[type])
			format(senddata,256,"%s%s#",senddata,c_model[g_wpn_menu[type][i + page * 9]])
		else
			format(senddata,256,"%s#",senddata)
	}
	MH_BuyMenu(id,type,page,(9 + page * 9<g_wpn_menu_count[type]),senddata);
	return PLUGIN_HANDLED;
}
public cmd_wpn_menu(id)
{
	if(!is_user_alive(id)) return PLUGIN_HANDLED
	if(bte_get_user_zombie(id)) return PLUGIN_HANDLED
	if(g_modruning == BTE_MOD_GD || g_modruning == BTE_MOD_DR || g_modruning == BTE_MOD_TD) return PLUGIN_HANDLED
	new title[64],item_name[8][256]
	format(title, charsmax(title), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_TITLE")
	format(item_name[1], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_PISTOL")
	format(item_name[2], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_SHOTGUN")
	format(item_name[3], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_SMG")
	format(item_name[4], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_RIFLE")
	//format(item_name[5], 255, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_REBUY",c_name[g_save_guns[id][1]],c_name[g_save_guns[id][2]],c_name[g_save_guns[id][3]],c_name[g_save_guns[id][4]])
	format(item_name[5], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_MG")
	format(item_name[6], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_EQUIP")
	format(item_name[7], 31, "%L",LANG_PLAYER,"BTE_WPN_MENU_BUY_MENU_KNIFE")
	// 手枪 霰弹枪 微型冲锋枪 自动步枪 轻机枪 主武器弹药 副武器弹药 装备 近身武器 结束
	
	new mHandleID = menu_create(title, "menu_wpn_handler")
	/*menu_additem(mHandleID, item_name[1], "R", 0)
	menu_additem(mHandleID, item_name[2], "P", 0)
	menu_additem(mHandleID, item_name[3], "K", 0)
	menu_additem(mHandleID, item_name[4], "H", 0)
	menu_additem(mHandleID, item_name[5], "Q", 0)*/
	for (new i = 1; i<=7; i++)
		menu_additem(mHandleID, item_name[i])
	
	
	menu_display(id, mHandleID, 0)
	return PLUGIN_HANDLED
}
public menu_wpn_handler(id, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	menu_destroy(menu)
	
	new title[64], fun_name[32]
	format(title, charsmax(title), "%L",LANG_PLAYER,"BTE_WPN_MENU_SELECT_MENU_TITLE")
	format(fun_name, charsmax(fun_name), "menu_mywpn_handler")
	
	new mHandleID = menu_create(title, fun_name)
	new item_name[128], idweapon[32]
	
	for (new i = 0; i<g_wpn_menu_count[item]; i++)
	{
		format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[g_wpn_menu[item][i]], c_cost[g_wpn_menu[item][i]])
		format(idweapon, charsmax(idweapon), "%i", g_wpn_menu[item][i])
		menu_additem(mHandleID, item_name, idweapon, 0)
	}
	menu_display(id, mHandleID, 0)
	/*if(equal(cmdbuy,"R"))
	{
	else if(equal(cmdbuy,"P"))
	{
	
		new mHandleID = menu_create(title, fun_name)
		if(g_mywpn_enable)
		{
			for (new i=0; i<MAX_MYWPN_PISTOLS; i++)
			{
				new idwpn
		
				idwpn = Stock_Get_Idwpn_FromSz(g_mywpn_p_cache[i])
		
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
			
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
		else
		{
			for(new i=0 ; i<=g_wpn_count[WPN_PISTOL] ;i++)
			{
				new idwpn
				idwpn = Stock_Get_Idwpn_FromSz(c_model[g_wpn_count_match[WPN_PISTOL][i]])
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
				if(! (SECONDARY_WEAPONS_BIT_SUM & (1<<c_wpnchange[idwpn])) ) continue
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
	
		menu_display(id, mHandleID, 0)
		
	}
	else if(equal(cmdbuy,"K"))
	{
		new title[64], fun_name[32]
		format(title, charsmax(title), "%L",LANG_PLAYER,"BTE_WPN_MENU_SELECT_MENU_K_TITLE")
		format(fun_name, charsmax(fun_name), "menu_mywpn_handler")
	
		new mHandleID = menu_create(title, fun_name)
		if(g_mywpn_enable)
		{
			for (new i=0; i<MAX_MYWPN_KNIFES; i++)
			{
				new idwpn
		
				idwpn = Stock_Get_Idwpn_FromSz(g_mywpn_k_cache[i])
		
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
			
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
		else
		{
			for(new i=0 ; i<=g_wpn_count[WPN_KNIFE] ;i++)
			{
				new idwpn
				idwpn = Stock_Get_Idwpn_FromSz(c_model[g_wpn_count_match[WPN_KNIFE][i]])
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
				if(c_wpnchange[idwpn] !=29 ) continue
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
	
		menu_display(id, mHandleID, 0)
	}
	else if(equal(cmdbuy,"H"))
	{
		new title[64], fun_name[32]
		format(title, charsmax(title), "%L",LANG_PLAYER,"BTE_WPN_MENU_SELECT_MENU_H_TITLE")
		format(fun_name, charsmax(fun_name), "menu_mywpn_handler")
	
		new mHandleID = menu_create(title, fun_name)
		if(g_mywpn_enable)
		{
			for (new i=0; i<MAX_MYWPN_HES; i++)
			{
				new idwpn
		
				idwpn = Stock_Get_Idwpn_FromSz(g_mywpn_h_cache[i])
		
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
			
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
		else
		{
			for(new i=0 ; i<=g_wpn_count[WPN_HE] ;i++)
			{
				new idwpn
				idwpn = Stock_Get_Idwpn_FromSz(c_model[g_wpn_count_match[WPN_HE][i]])
				if (!idwpn || !c_wpnchange[idwpn] || !c_buy[idwpn]) continue;
				if(c_buymod[idwpn] && !(c_buymod[idwpn] & (1<<g_modruning))) continue
				if (c_team[idwpn] && get_user_team(id)!=c_team[idwpn]) continue;
				if(c_wpnchange[idwpn]!=4) continue
				new wpn_cost = c_cost[idwpn]
				new item_name[128], idweapon[32]
				format(item_name, charsmax(item_name), "%L",LANG_PLAYER,"BTE_WPN_MENU_BUYSTYLE", c_name[idwpn], wpn_cost)
				format(idweapon, charsmax(idweapon), "%i", idwpn)
		
				menu_additem(mHandleID, item_name, idweapon, 0)
			}
		}
	
		menu_display(id, mHandleID, 0)
	}*/
	/*else if(equal(cmdbuy,"Q"))
	{
		if(g_save_guns[id][1]) Pub_Give_Wpn_Check(id,g_save_guns[id][1])
		if(g_save_guns[id][2]) Pub_Give_Wpn_Check(id,g_save_guns[id][2])
		if(g_save_guns[id][3]) Pub_Give_Wpn_Check(id,g_save_guns[id][3])
		if(g_save_guns[id][4]) Pub_Give_Wpn_Check(id,g_save_guns[id][4])
	}*/
	return PLUGIN_HANDLED
}
public menu_mywpn_handler(id, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	new idwpn[32], name[32], access
	menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)

	new idweapon = str_to_num(idwpn)
	
	Pub_Give_Wpn_Check(id, idweapon)
	
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
*/
