SA-MP Forums Archive
Causing negative numbers - Inflation system - 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: Causing negative numbers - Inflation system (/showthread.php?tid=636198)



Causing negative numbers - Inflation system - Dokins - 22.06.2017

pawn Код:
InfPrice(oldprice)
{
    if(TotalServerMoney < 7000000) return oldprice;
    new newprice, money, Float: money2, Float: money3;
    money = TotalServerMoney - ServerStartMoney;
    money2 = money * 100;
    money3 = money2 / ServerStartMoney;
    new Float: calc = money3 / 100;
    new Float: calc2 = calc * oldprice;
    newprice = oldprice + floatround(calc2);
    return newprice;
}
Essentially, when it's called it causes negative numbers, essentially giving people money.

IT ONLY DOES THIS WHEN THE TOTALSERVERMONEY > 290,000,000

The server total money = $305,88,913

Will be wiping this but I need to know the cause?

Код:
[13:15:41] Money = 22000000
[13:15:41] Money2 = -822493868
[13:15:41] Money3 = -1013603335
[13:15:41] calc = -1069577676
[13:15:41] calc2 = -1005214727
[13:15:41] newprice = -399



Re: Causing negative numbers - Inflation system - Dokins - 22.06.2017

RESOLVED - Caused by integer > int maximum.