I'm having trouble with GANI scripts used in player attributes to show an HP bar. It works for the first display, but then doesn't always update.
This is the code (serverside):
PHP Code:
this.attr[3] = "era_hpbar.gani," @ (this.health / this.initialHealth);
and this is the GANI script:
PHP Code:
SCRIPT
function onCreated() {
showBar(params[0]);
}
function onPlayerEnters() {
onCreated();
}
function showBar(percent) {
with (findimg(200)) {
image = "erai_hpbar.png";
x = this.x + 0.25;
y = this.y - 1.5;
layer = 1;
attachtoowner = true;
}
changeImgPart(200, 0, 0, 41, 11);
with (findimg(201)) {
image = "erai_hpbar.png";
x = this.x + 0.25;
y = this.y - 1.5;
layer = 2;
attachtoowner = true;
}
changeImgPart(201, 0, 12, max(1, 41 * percent), 11);
}
SCRIPTEND
The bar will always show correctly if I try to display it when the bar isn't already showing, but if it is already showing, it won't update.