SA-MP Forums Archive
Failed Calculation.. -_- - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Failed Calculation.. -_- (/showthread.php?tid=380667)



Failed Calculation.. -_- - 'Pawno. - 26.09.2012

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


Re: Failed Calculation.. -_- - [MM]RoXoR[FS] - 26.09.2012

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



AW: Failed Calculation.. -_- - 'Pawno. - 26.09.2012

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


Re: Failed Calculation.. -_- - [MM]RoXoR[FS] - 26.09.2012

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?


AW: Failed Calculation.. -_- - 'Pawno. - 26.09.2012

the first.


Re: Failed Calculation.. -_- - mamorunl - 26.09.2012

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

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


AW: Re: Failed Calculation.. -_- - 'Pawno. - 26.09.2012

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


Re: Failed Calculation.. -_- - mamorunl - 26.09.2012

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


AW: Failed Calculation.. -_- - 'Pawno. - 26.09.2012

thx. =)