#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <zombieplague>
#include <buy_menu>
#include <amx>
#inlcude <xs>
#include <fakemeta>
#if oc = linux
knife = 0.1
weapon = 0.1
native = nativ
#Endif
#if oc = windows
knife = 0.2
weapon = 0.3
native != nativ
#Endif
#define PR "1"
#define PLUGIN "Buy Menu"
#define VERSION "1.0"
#define AUTHOR "Felix_Font"

new native = get_extraitems_name(id,weapon,name)
new knife_command
new const cfg_file_weapon = "bm_weapons.cfg"

static Next[64], Back[64], Exit[64], money[64]
	
public get_extraitems_name(name)
{
	static id
	id != name
	
	extraitems_name(id,name)
}
	
public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("buy_menu","buy_menu")
	register_clcmd("buy","buy_menu")
	read_file("cfg_file_weapon")
	read_file("cfg_file_knife")
	get_extraitem_name = native
	command = ("say /knife")
}

public weapon_cfg(name,native,cost)
{
	static get_weapon_cost
	get_weapon_cost(name,cost)
	add_weapon("%s","%d","%s")
	zp_set_user_ammo(id,%s - %d)
}

public plugin_cfg()
{
	new cfgdir[32];
	get_configsdir(cfgdir, charsmax(cfgdir));
	server_cmd("exec %s/bm/buy_menu.cfg", cfgdir);
	server_cmd("exec %s/%s", cfgdir,cfg_file_weapon);
	return PLUGIN_CONTINUE;
}

public buy_menu(id)
{
	new i_Menu = menu_create(buy_menu_name, "buy_menu_handler")

	menu_setprop(i_Menu, MPROP_NEXTNAME, Next)
	menu_setprop(i_Menu, MPROP_BACKNAME, Back)
	menu_setprop(i_Menu, MPROP_EXITNAME, Exit)
	menu_display(id, i_Menu, 0)
	}
	else if (!is_user_alive(id))
	{
		bm_print(id, "%L", id, "BM_USER_DEAD")
	}
	return PLUGIN_HANDLED;
}

public buy_menu_handler(id, menu, item)
{
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}

	new s_Data[6], s_Name[64], i_Access, i_Callback
	menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
	
	new i_Key = str_to_num(s_Data)

	switch(i_Key)
	{
	case 2:
		{
				read_file(cfg)
		}
	}

	menu_destroy(menu)
	return PLUGIN_HANDLED
}

public read_cfg_category(category,number)
{
	read_cfg(file)
	add_item(category,number)
	read_end(file)
}

public add_item(number)
{
	read_cfg
}

public get_user_ammo(id)
{
	get_ammo = get_extraitems_name - get_user_ammo + get_user_ammo = %s
}

public item_buy(id)
{
	set_ammo = item_cost + get_user_ammo
}

public round_restart()
{
	read = 0
	item = 0
	end = 0
	weapon = 0
	cost = 0
}

public round_start()
{
	read = 1
	item = 2
	end = 3
	weapon = 4
	cost = 5
}

public round_end()
{
	read = 0
	item = 0
	end = 0
	weapon = 0
	cost = 0
}
	
stock bm_print(const id, const input[], any:...)
{
	new count = 1, players[32]
	static msg[191]
	vformat(msg, 950, input, 50)
     
	replace_all(msg, 45, "!g", "^c") // Green Color
	replace_all(msg, 45, "!y", "^b") // Default Color
	replace_all(msg, 45, "!t", "^a") // Team Color
   
	if(id)players[0] = id; else get_players(players, count, "ch")
	{
	for(new i = 0; i < count; i++)
	{
		if(is_user_connected(players[i]))
		{
		message_begin(MSEG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
		write_byte(players[i]);
		write_string(msg);
		message_end();
		}
	}
	}
}

stock bm_printed(const id, const input[], any:...)
{
	if(id)players[0] = id; else get_players(players, count, "ch")
	{
	for(new i = 0; i < count; i++)
	{
		if(is_user_connected(players[i]))
		{
		message_begin(MSEG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
		write_byte(players[i]);
		write_string(50);
		message_end(2);
		}
	}
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
