Jump to content

Progressbar with %


Fantanic

Recommended Posts

Posted

Erhm thats not what i meant , i mean like it says "90%" if its 90 on fuel for example , and with my knowledge guiProgressBarSetProgress doesnt do that?

Sorry if im wrong and or bad explained

Thanks in advanced ,

Jonas

Posted (edited)

Hm i madethis ;

local fuel = getElementData(vehicle,fuel) 
dxDrawText("fuel:"..fuel.." %", 599, 499, 617, 543, tocolor(254, 254, 254, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false); 

but now i see for example 90.850%

any way to fix it?

Thanks in advance,

Jonas

Edited by Guest
Posted
 math.abs  

local fuel = math.abs(fuel) 
        dxDrawText("fuel"..fuel.." %", 599, 499, 617, 543, tocolor(254, 254, 254, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false); 
  

didnt worked

Posted
local fuel = math.floor(getElementData(vehicle, "fuel")) 

This?

Edit: Oh, you want to get progress from progress bar? If so:

  
local fuel = math.floor(guiProgressBarGetProgress(progressbar)) 
  

Posted

Thanks well my main idea was to get a progress bar but i guess its hard to get it for example if its 100% of fuel then its full if its 75 its for 3/4 full etc (main question too)

Posted

You should know whats the maxium value of fuel.

Note:

local ValueToGet = 100 
local fuel = getElementData(element, "fuel") 
local maximum = 100 
local progress = (fuel / maximum ) * ValueToGet 

It'll give a value within 0-100 (specified to which is biggest by ValueToGet) if you correctly set maximum.

PD: Dont use caps ("If"), check syntax always.

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...