Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
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 529 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
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

    • Login

    • Don't have an account? Register

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