ZM - HELP! Fix zombie life bar
-
help!! The script should show a video bar above the zombies, supposedly there are no errors, but when starting the game I get that message
Error:

code:
#include maps/mp/_utility;
#include common_scripts/utility;
#include maps/mp/gametypes_zm/_hud_util;
#include maps/mp/gametypes_zm/_hud_message;
#include maps/mp/zombies/_zm_utility;init()
{
level thread onPlayerConnect();
}onPlayerConnect()
{
for(;;)
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;;)
{
self waittill("spawned_player");
level thread zombieHud();
}
}// ==============================================================
// Interfaz gráfica de la barra de vida
zombieHud()
{
for(i = 0; i < level.zombies.size; i++)
{
// Obtiene el Zombie actual
zombie = level.zombies[i];// Obtiene la posición y la vida del Zombie zombieOrigin = zombie.origin; zombieHealth = zombie.health; // Calcula la posición de la barra de vida encima del Zombie barPosition = zombieOrigin; barPosition[2] += 30; // Ajusta la altura de la barra de vida // Dibuja la barra de vida drawBar(zombieHealth, barPosition); } wait 0.05;}
// Función para dibujar la barra de vida
drawBar(health, position)
{
barWidth = 50; // Ancho de la barra de vida
barHeight = 5; // Alto de la barra de vida// Calcula el porcentaje de vida actual healthPercentage = health / 100; // Calcula la longitud de la barra de vida basado en el porcentaje barLength = barWidth * healthPercentage; // Dibuja la barra de vida en la posición dada HudElem = newClientHudElem(self); // Crea un elemento de interfaz gráfica para el cliente HudElem.alignX = "left"; HudElem.alignY = "top"; HudElem.x = position[0] - (barWidth / 2); // Ajusta la posición horizontal de la barra de vida HudElem.y = position[1] - (barHeight / 2); // Ajusta la posición vertical de la barra de vida HudElem.horzAlign = "left"; HudElem.vertAlign = "top"; HudElem.barWidth = barLength; HudElem.barHeight = barHeight; HudElem.color = (healthPercentage > 0.5) ? (1, 1, 1) : (1, 0, 0); // Color de la barra de vida HudElem.alpha = 1;}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login