Assistance with calculations, not sure why not working. - 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: Assistance with calculations, not sure why not working. (
/showthread.php?tid=565322)
Assistance with calculations, not sure why not working. -
Dokins - 26.02.2015
pawn Код:
InfPrice(oldprice)
{
printf("oldmoney %d", oldprice);
if(TotalServerMoney < 7000000) return oldprice;
new newprice, money, calc;
printf("oldmoney %d", oldprice);
money = (TotalServerMoney - ServerStartMoney) / ServerStartMoney; //7,000,000
printf("ServerStartTotal %d",ServerStartMoney);
printf("TotalServerMoneyl %d",TotalServerMoney);
InflatPercentage = money * 100;
calc = oldprice * InflatPercentage;
newprice = oldprice + calc;
printf("newmoney %d", newprice);
return newprice;
}
pawn Код:
new Float: InflatPercentage;
The printf's show the correct inputs (oldprice, totalserver, serverstart) but won't calculate them properly, could anyone advise why?
Thanks.
Re: Assistance with calculations, not sure why not working. -
Vince - 26.02.2015
Integer divided by integer yields an integer.
Re: Assistance with calculations, not sure why not working. -
Dokins - 26.02.2015
So I need to use a float to calculate?