Fantanic Posted April 15, 2014 Posted April 15, 2014 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 Jonas
Fantanic Posted April 15, 2014 Author Posted April 15, 2014 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
Fantanic Posted April 15, 2014 Author Posted April 15, 2014 (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 April 15, 2014 by Guest
h4x7o0r Posted April 15, 2014 Posted April 15, 2014 (edited) math.abs -- so fuel = math.abs(fuel) Edited April 15, 2014 by Guest
Fantanic Posted April 15, 2014 Author Posted April 15, 2014 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
GTX Posted April 15, 2014 Posted April 15, 2014 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))
Fantanic Posted April 15, 2014 Author Posted April 15, 2014 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)
Smart. Posted April 15, 2014 Posted April 15, 2014 You can make your own progress bar with dxDrawText & dxDrawRectangle
Fantanic Posted April 15, 2014 Author Posted April 15, 2014 So If fuel is 100 then Create the rectangel(ik other thing needed)
.:HyPeX:. Posted April 15, 2014 Posted April 15, 2014 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now