Miles Per Gallon
#1

Right guys, i'm stumped. After nearly a day searching the internet on how MPG works, i'm resorted to asking here.

Basically i'm revamping my fuel system and am adding in mpg & fuel capacity for each vehicle, so far I've got the mileage system working, but how would I go about getting the MPG from the mileage?

What would the formula be?
Reply
#2

Going to have to bump this, need help on the matter.
Reply
#3

i think you would do something like:
pawn Код:
randomtimer()
{
    for(new a = 0; a < sizeof(Yourfuelarray); a++)
    {
              Yourfuelarray[carid] = drivenmiles * milespergallon
    }
}
and then just link the function with a timer
Reply
#4

Ah right. You'll have to excuse me cause i'm a newbie when it comes to complex maths.

So basically the above code will give me the miles per gallon of say a Sultan? I would just times the mileage of the car with the miles per gallon that's in my array?
Reply
#5

yah you first have to set like an array for the milespergalon if this should be something else for every car

like:
pawn Код:
new milespergalon[212][] = {
"4", "4.5" and so on }
and fetch the MPG with a stock like:
pawn Код:
public GetMPGFromID(vid)
{
        return milespergalon[i + 400];
}
or you just fetch it in the calculation
pawn Код:
randomtimer()
{
    for(new a = 0; a < sizeof(Yourfuelarray); a++)
    {
              new model = GetVehicleID(carid)
              Yourfuelarray[carid] = yourcarenum[carid][drivenmiles] * milespergallon[model]
    }
}
Reply
#6

i should notice that this is madeup as i'm writing the quick replys so it could be that it dosen't work
Reply
#7

Quote:
Originally Posted by BigBrainAFK
Посмотреть сообщение
pawn Код:
return milespergalon[i + 400];
Yeah, that should be subtraction because it will exceed the bounds.

---

You basically want to get the distance, don't you? The distance is equal with mileage x fuel.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Yeah, that should be subtraction because it will exceed the bounds.

---

You basically want to get the distance, don't you? The distance is equal with mileage x fuel.
oh ya thanks for the tip and i just wrote the fuel that was used over a distance sorry for that but reading is not my best so: I'm sorry ;(
Reply
#9

Oh, right. Well just added a temp string to see what the MPG actually was, says it's 3529 but the set MPG for the vehicle I was in was 38.

Need to figure out to make it do the MPG that is in the array now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)