#include <amxmodx>
#include <cstrike>
#include <fakemeta_util>
#include <zombieplague>

new const item_name[] = "Health"
new g_fire, g_itemid_buyhp, zm_amout_hp

new const heal_effect[] = "tox_cso/zomb_heal.wav"
 
public plugin_precache()
{
	g_fire = precache_model("sprites/tx/zombiheal.spr")
	precache_sound(heal_effect)
}

public plugin_init() 
{
	register_plugin("[CSO:Buy HP]", "1.0", "BJIa BJIA")
	zm_amout_hp = register_cvar("zp_buyhp_zombie", "1000")
	g_itemid_buyhp = zp_register_extra_item(item_name, 0, ZP_TEAM_ZOMBIE)
}

public zp_extra_item_selected(id, itemid)
{
	if(itemid == g_itemid_buyhp)
	{
		fm_set_user_health(id, get_user_health(id) + get_pcvar_num(zm_amout_hp))
		new text[100]
		format(text,99,"^x04[CSO ZM] ^x01Вы купили 1000 ХП!");
		message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id) 
		write_byte(id) 
		write_string(text) 
		message_end()
		emit_sound(id, CHAN_ITEM, heal_effect, 0.6, ATTN_NORM, 0, PITCH_NORM)

		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), {0, 0, 0}, id)
		write_short(1<<12)
		write_short(1<<12)
		write_short(0x0000)
		write_byte(0)
		write_byte(250)
		write_byte(0)
		write_byte(50)
		message_end()

		fire(id)
	}

	return PLUGIN_CONTINUE
} 

public fire(victim)
{
	new origin[3]
	get_user_origin(victim, origin)

	fire_zombie(origin)
}

fire_zombie(origin[3])
{
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_SPRITE)
	write_coord(origin[0])
	write_coord(origin[1])
	write_coord(origin[2]+=30)
	write_short(g_fire)
	write_byte(8)
	write_byte(255)
	message_end()
}