Jump to content

Progressbar with %


Recommended Posts

Hello ,

Im trying to make a fuel system ,

So my main question is :

is it possible to get for example 100% on a progressbar(https://wiki.multitheftauto.com/wiki/GuiCreateProgressBar)

And if the fuel is for example 99 then it goes to 99% (i need to use getElementData(vehicle,"fuel") elementdata of fuel = fuel)?

or something like this ;

local fuel = 100

function fuelonbar()
if fuel < 50 then

Thanks in advance


Link to comment

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,


Edited by Guest
Link to comment

You should know whats the maxium value of fuel.


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.

Link to comment

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