Jump to content

Progress bar in circle


Emilio_M

Recommended Posts

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted
Well, yea. You just added unnecessary condition ('if'). In both cases it draws same thing.

images?q=tbn:ANd9GcRxAx-OR_CFM0iJBgwzRFy-ESICTXCQWQ1WfQN5AQOmhLtErNjXf_3jsBk

if you no know the mta has health 100% and 200%, and that you no added, look in line ( getPedStat ) :lol::lol:

Posted
added, all resolutions, and added getPedStat to health in 200%
  
local screenW,screenH = guiGetScreenSize() 
local resW, resH = 1280, 720 
local x, y =  (screenW/resW), (screenH/resH) 
local maxAngle = 180 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local stat = getPedStat ( getLocalPlayer(), 24 ) 
        local hp = getElementHealth ( localPlayer ) * ( maxAngle / 100 ) 
if stat < 1000 then 
        dxDrawCircle ( ( x - 50 ) / 2, ( y - 50 ) / 2, 50, 5, 1, 0, hp, tocolor ( 255, 0, 0, 255 ), false ) 
else 
        dxDrawCircle ( ( x - 50 ) / 2, ( y - 50 ) / 2, 50, 5, 1, 0, hp, tocolor ( 255, 0, 0, 255 ), false ) 
end 
    end) 

Do you even check what you post? don't you see that both dxDrawCircle have the same arguments? and that "stat" is not being used anywhere but in that useless "if" statement?

Posted
Do you even check what you post? don't you see that both dxDrawCircle have the same arguments? and that "stat" is not being used anywhere but in that useless "if" statement?

he just use his calculations, I forever using this. and always I had success

local stat = getPedStat (  getLocalPlayer(), 24 ) 
if stat < 1000 then 
dx.... 
else 
dx.... 
end 
  

Posted
Do you even check what you post? don't you see that both dxDrawCircle have the same arguments? and that "stat" is not being used anywhere but in that useless "if" statement?

he just use his calculations, I forever using this. and always I had success

local stat = getPedStat (  getLocalPlayer(), 24 ) 
if stat < 1000 then 
dx.... 
else 
dx.... 
end 
  

So, your solution is to make a useless check, to draw the same thing no matter what "stat" is returning?

You really should avoid posting if you don't know how to help, since you're only confusing the person who asked for help.

Posted
Not to mention, your "all resolutions" logic is not correct.

EDIT: Wow...

how would your calculation for this? I want to learn to do :D

Posted
local hpMin = 176 
local hpMax = 135 
local hpRate = hpMin-hpMax 
local hp = hpMin-((getElementHealth(getLocalPlayer())*hpRate)/100) 
dxDrawCircle( 220,796,113, 16,1,134,226,tocolor(0,0,0,255)) -- black bar background 
dxDrawCircle( 220,796,110, 15,1,hp,hpMin,tocolor(255,0,0,255)) -- red bar ( HP ) 

Posted

Have you tried to use WhoAmI's code?

local screenX, screenY = guiGetScreenSize ( ); 
local maxAngle = 180; 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local hp = getElementHealth ( localPlayer ) * ( maxAngle / 100 ); 
        dxDrawCircle ( ( screenX - 50 ) / 2, ( screenY - 50 ) / 2, 50, 5, 1, 0, hp, tocolor ( 255, 0, 0, 255 ), false ); 
    end 
); 

If you want it to be a full circle, change this variable:

local maxAngle = 180; 

to 360 instead of 180.

Posted
local hpMin = 225 
local hpMax = 135 
local hpRate = ( ( hpMin - hpMax ) / 100 ) 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local hp = ( hpMin - ( getElementHealth ( localPlayer ) * hpRate ) ) 
        dxDrawCircle ( 220, 796, 113, 16, 1, 134, 226, tocolor ( 0, 0, 0, 255 ) ) -- black bar background 
        dxDrawCircle ( 220, 796, 112, 12, 1, hp, hpMin, tocolor ( 255, 0, 0, 255 ) ) -- red bar ( HP ) 
    end 
) 

Is that what you want?

Posted

Yes, I did change something.

This line:

local hpMin = 176 

I changed it to:

local hpMin = 225 

I tested it and it fills the whole bar when my health is 100%.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...