Depending on how your damage is handled you could just do something like this with showani and scheduleevent.
PHP Code:
//#CLIENTSIDE
function onDamage(amount) {
showani(100, player.x, player.y, 0, "your_damage_gani", hp_ratio);
this.scheduleevent(2, "HideDamage", "");
}
function onHideDamage() {
hideimg(100);
}
You'll be able to use params[0]/hp_ratio to determine how much of the bar you'll need to show.