/*================================================================================

	-----------------------------------
	-*- [ZP] Bullet Damage HUD -*-
	-----------------------------------

	Shows floating damage numbers when you damage an enemy.

================================================================================*/

#include <amxmodx>
#include <fakemeta>

#define PLUGIN_NAME		"[ZP] Bullet Damage HUD"
#define PLUGIN_VERSION	"1.0"
#define PLUGIN_AUTHOR	"Kimi Code"

#define MAX_MESSAGES	10

new cvar_enabled;
new g_sync_hud;

public plugin_init() {
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	cvar_enabled = register_cvar("zp_bullet_damage_hud", "1");

	register_event("Damage", "event_damage", "b", "2!=0");

	g_sync_hud = CreateHudSyncObj();
}

public event_damage(id) {
	if (!get_pcvar_num(cvar_enabled))
		return PLUGIN_CONTINUE;

	if (!is_user_alive(id))
		return PLUGIN_CONTINUE;

	new attacker = get_user_attacker(id);
	if (!is_user_alive(attacker) || attacker == id)
		return PLUGIN_CONTINUE;

	new damage = read_data(2);
	if (damage <= 0)
		return PLUGIN_CONTINUE;

	// Show damage to attacker
	set_hudmessage(0, 150, 255, -1.0, 0.6, 0, 0.1, 0.5, 0.0, 0.0, -1);
	ShowSyncHudMsg(attacker, g_sync_hud, "-%d", damage);

	return PLUGIN_CONTINUE;
}
