Jump to content

[HELP] speedometer / fuel state


opnaiC

Recommended Posts

Hello,

I am making a speedometer and need some help. So I finished the speedometer for the car speed and its working without any bugs. But now I need to make one for the fuel. I am using this to get the fuel state.

getElementData(getPedOccupiedVehicle ( localPlayer ), "fuel" ) or 0 

I have a config where I can change the full fuel tank for diffrent cars. Example: Infernus = 500 and Cheetah = 300. But I dont know how to calculate the rotation of the needle on the speedometer for the car tank fuel state. The rotation should be every time 180. But the problem is that the car fuel is different from model to model. So how can I calculate the rotation for all cars by different fuel tank ? I hope you can help me with that.

dxDrawImage(screenX-575, screenY-320, 300,300,"img/fuel_speed.png",fuel-100,0.0,0.0,tocolor(255,255,255,255),false)-- how to calculate the fuel needle rotation? 

Link to comment

I just got into the same problem some times ago, I used this and it helped me a lot:

http://stackoverflow.com/questions/9291 ... ning-ratio

NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin

NewValue is gonna be your value, OldValue is gonna be your 300 for Cheetah, 500 for Infernus (depends on the car), NewMax is gonna be as much as your rectangle's length is, NewMin is gonna be 0.

Good luck

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