Failed Calculation.. -_-
#1

Hey.
I have a simple problem with my maths.

So, i want to "convert" my vehicle-tank.
(example: 30 liter = 100%)
but i get a little problem.
i dont know how, because i have'nt gone to school since May because i'm ill.

I know how to get "1%" of my vehicle-tank but i dont know how to make it dynamic.

can u give me tips or something like that??

this is currently my script:
pawn Код:
stock GetConvertedTank(vehicleid)
{
    new btank = 30;
    new tempTank;
    tempTank = floatround(bTank / 100);
    return 1;
}
Thx...

PS: btank is only a variable for little time until i have my calculation.
PSІ: Sorry for my english... I'm tired ... ^^
Reply
#2

I didnt get what you are trying to do..

If you want to find x% of y Litre (where x and y are variable you can use this code
pawn Код:
stock GetConvertedTank(Float:percent , Float:litre)
{
    new Float:temp = (litre/100)*percent;
    return _:temp;
}

//========USAGE : Suppose you want to calculate
// 5 % of 150

new p = GetConvertedTank(5,150);

//Result = 7.5
Reply
#3

No, i want to return the % (1-100) from x litre.
Reply
#4

You mean you want to return percentage of fuel left in a specific vehicle

OR

You want to send max fuel and current fuel and get percentage left?
Reply
#5

the first.
Reply
#6

Total fuel: 30 Liters
Amount left: 20 liters
Percentage left: (20/30)*100

Calculating amount of liters in tank: 30*(percentage/100)
Reply
#7

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
Total fuel: 30 Liters
Amount left: 20 liters
Percentage left: (20/30)*100

Calculating amount of liters in tank: 30*(percentage/100)
sorry, I can not do anything with this. :/
Reply
#8

Well, what seems to be the problem with it then?

If your tank is 30 liters and you know the amount left in your tank is 20 liters then you can calculate the percentage of fuel left like this: percentageLeft = amountLeft/maxAmount * 100
Reply
#9

thx. =)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)