Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. ZM - HELP! Fix zombie life bar

ZM - HELP! Fix zombie life bar

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
1 Posts 1 Posters 734 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _DABI_undefined Offline
    _DABI_undefined Offline
    _DABI_
    wrote on last edited by
    #1

    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:
    9632afdd-b3d7-4483-850c-b0680ce652a3-imagen.png

    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;
    

    }

    1 Reply Last reply
    0

    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
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Unread 0
    • Recent
    • Tags
    • Popular
    • Users
    • Groups