Hi, I have a problem with this zombie health bar. At a certain point, the game kicks the player out, and the error shown on screen is "Overflow". From what I understand, the game has a limit on the recreation of hud elements (strings). This is due to a game engine function that manages configstrings, which are strings used by the game to identify resources. These are stored in a cache, and when that limit is reached, this type of error appears.
I know exactly what the workaround is for now — using .label and setValue. But is there any way to fix this while still using setText?
// Calculate health percentage
max_health = entity.maxhealth;
health = entity.health;
percent = health / max_health;
// If the health bar already exists, update it
if (isDefined(self.hud_zombie_health) && isDefined(self.hud_zombie_health_text))
{
// If the zombie is dead, show an empty bar
if (isDefined(isDead) && isDead)
{
self.hud_zombie_health updatebar(0);
if (self.langLEN == 0)
self.hud_zombie_health_text setText("Esta Muerto!");
else
self.hud_zombie_health_text setText("He's dead!");
}
else
{
// Ensure the bar uses the selected color
// Default to white if no color is defined
if (!isDefined(self.colorcito))
self.colorcito = (1, 1, 1);
// Only update the color if it's different
if (isDefined(self.hud_zombie_health.bar) && self.hud_zombie_health.bar.color != self.colorcito)
self.hud_zombie_health.bar.color = self.colorcito;
// Update the health bar to the current percentage
self.hud_zombie_health updatebar(percent);
// Show name and health info if enabled
if (self.zombieNAME)
{
self.hud_zombie_health_text setText(name_zombie + " ^7[^3" + int(health) + "^7/^2" + int(max_health) + "^7]");
}
else
{
// Show only the health values
self.hud_zombie_health_text setText("^7[^3" + int(health) + "^7/^2" + int(max_health) + "^7]");
}
}
}
else
{
// Create health bar and text if they do not exist
self.hud_zombie_health = self createprimaryprogressbar();
self.hud_zombie_health_text = self createprimaryprogressbartext();
// Position the bar and text (original position, do not modify)
self.hud_zombie_health setpoint("LEFT", "LEFT", 0, 120);
self.hud_zombie_health_text setpoint("LEFT", "LEFT", 0, 134);
// Ensure the color is defined, default to white
if (!isDefined(self.colorcito))
self.colorcito = (1, 1, 1);
// Configure visual properties of the bar
self.hud_zombie_health.bar.color = self.colorcito;
self.hud_zombie_health.hidewheninmenu = false;
self.hud_zombie_health_text.hidewheninmenu = false;
self.hud_zombie_health.alpha = self.shaderON;
// Set bar and text size
self.hud_zombie_health.width = self.sizeW;
self.hud_zombie_health.height = self.sizeH;
self.hud_zombie_health_text.fontScale = self.sizeN;
// Handle dead zombie case
if (isDefined(isDead) && isDead)
{
self.hud_zombie_health updatebar(0);
if (self.langLEN == 0)
self.hud_zombie_health_text setText("Esta Muerto!");
else
self.hud_zombie_health_text setText("He's dead!");
}
else
{
// Update the bar with current health percentage
self.hud_zombie_health updatebar(percent);
// Display name and health or just health
if (self.zombieNAME)
self.hud_zombie_health_text setText(name_zombie + " ^7[^3" + int(health) + "^7/^2" + int(max_health) + "^7]");
else
self.hud_zombie_health_text setText("^7[^3" + int(health) + "^7/^2" + int(max_health) + "^7]");
}
}
// If the zombie is alive and at full health, fade and remove the bar after a delay
if (isDefined(isDead) && !isDead && health == max_health)
{
self.hud_zombie_health fadeovertime(1.5);
self.hud_zombie_health_text fadeovertime(1.5);
self.hud_zombie_health.alpha = 0;
self.hud_zombie_health_text.alpha = 0;
wait 1.5;
// Destroy the health bar and text HUD elements
if (isDefined(self.hud_zombie_health))
{
self.hud_zombie_health destroy();
self.hud_zombie_health = undefined;
}
if (isDefined(self.hud_zombie_health_text))
{
self.hud_zombie_health_text destroy();
self.hud_zombie_health_text = undefined;
}
}