#include <amxmodx>
#define PLUGIN "Health and ammo"
#define VERSION "1.0"
#define AUTHOR "Bui Duc Duy"
new g_iMsgStatusIcon, iwpn,iclip,iammo
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("Health", "event_health", "be") ;
register_event("CurWeapon", "event_CurWeapon", "ab")
g_iMsgStatusIcon = get_user_msgid("StatusIcon");
}
public event_health(id)
{
new iColor[3], iHealth = get_user_health(id);
set_hudmessage(255, 255, 255, 0.15, 0.8, 0, 6.0, 999.0, 0.0, 0.0, -1);
show_hudmessage(id, "%d", iHealth);
set_hudmessage(255, 255, 255, 0.15, 0.9, 0, 6.0, 999.0, 0.0, 0.0, -1);
show_hudmessage(id,"%d", get_user_armor(id));
switch (iHealth)
{
case 80 .. 100:
{
iColor = { 0, 255, 10 };
}
case 20 .. 79:
{
iColor = { 244, 164, 96 };
}
case 0 .. 19:
{
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()
}
public event_CurWeapon(id)
{
iwpn = get_user_weapon(id,iclip,iammo)
if(iwpn!=CSW_KNIFE)
{
set_hudmessage(225,225,225,0.5, 0.2, 0, 6.0, 999.0, 0.0, 0.0, -1);
show_hudmessage(id,"%d", iclip);
set_hudmessage(225,225,225,0.6, 0.2, 0, 6.0, 999.0, 0.0, 0.0, -1);
show_hudmessage(id, "/");
set_hudmessage(225,225,225,0.7, 0.2, 0, 6.0, 999.0, 0.0, 0.0, -1);
show_hudmessage(id,"%d", iammo);
}
return PLUGIN_CONTINUE
}