#include <amxmodx>
#define PLUGIN "Health"
#define VERSION "1.0"
#define AUTHOR "Bui Duc Duy + Ryokin"
new g_iHudHealth, g_iHudArmor, g_iMsgStatusIcon;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("Health", "event_health", "be") ;
g_iHudHealth = CreateHudSyncObj();
g_iHudArmor = CreateHudSyncObj();
g_iMsgStatusIcon = get_user_msgid("StatusIcon");
}
public event_health(id)
{
new iColor[3], iHealth = get_user_health(id);
set_hudmessage(255, 255, 255, 0.1, 0.9, 0, 6.0, 999.0, 0.0, 0.0, -1);
ShowSyncHudMsg(id, g_iHudHealth, "%d", iHealth);
set_hudmessage(255, 255, 255, 0.1, 1.0, 0, 6.0, 999.0, 0.0, 0.0, -1);
ShowSyncHudMsg(id, g_iHudArmor, "%d", get_user_armor(id));
if(iHealth >= 80)
{
iColor = { 0, 0, 255 };
}
else if(iHealth >= 20)
{
iColor = { 244, 96, 164 };
}
else
{
iColor = { 255, 0, 0 };
}
message_begin(MSG_ONE, g_iMsgStatusIcon, {0,0,0}, id)
write_byte(1) // status: 0: off; 1: on; 2:flash
write_string("MY_HEALTH")
write_byte(iColor[0]) // do
write_byte(iColor[1]) // xanh la
write_byte(iColor[2]) // xanh lam
message_end()
}