Author Topic: Health bar help  (Read 1588 times)

0 Members and 1 Guest are viewing this topic.

Offline DankNessProvides

  • Newbie
  • *
  • Posts: 26
  • Karma: -3
Health bar help
« on: April 25, 2016, 03:57:46 PM »
What I am doing is making my own star wars HUD but I want to have the health bar so it changes size when it is at higher health than 100 so it would use the job health and would change size when they are at 110 health but their starting health was 175. I don't know what to do to make it adjust with the health when they are higher than 100 health.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Health bar help
« Reply #1 on: April 25, 2016, 05:34:40 PM »
Without knowing what you're currently doing to display the health it's going to be pretty hard for us to help you.

I can only suggest using Entity:GetMaxHealth somewhere in your math to set the width of the health bar.

If you could post a snippet of code pertinent to drawing your health bar then I would be able to assist you more.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline DankNessProvides

  • Newbie
  • *
  • Posts: 26
  • Karma: -3
Re: Health bar help
« Reply #2 on: April 26, 2016, 08:21:46 AM »
Code: [Select]
-- Health Bar
draw.RoundedBox(2, ScrW() - ScrW() + 30, ScrH() - 70, 380, 40, Color(0,0,0,175))
draw.RoundedBox(2, ScrW() - ScrW() + 32, ScrH() - 68, (376) * DrawHealth / 100, 36, Color(255,45,45,100))
draw.SimpleText(EchoHealth, "DermaLarge", ScrW() - ScrW() + 210, ScrH() - 65, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)

Sorry did this late at night trying to fix some other issues forgot to add the snippet of code.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Health bar help
« Reply #3 on: April 26, 2016, 03:11:22 PM »
You have what seems to be a variable ('DrawHealth') that isn't defined in that snippet. Can you show us the declaration for that variable as well?
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.