Simple SAMP Math Symbols Question - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Simple SAMP Math Symbols Question (
/showthread.php?tid=245548)
Simple SAMP Math Symbols Question -
SkizzoTrick - 31.03.2011
pawn Код:
if(PlayerInfo[i][pSavings] >= 50000)
{
new savings = ((5/10)/100)*(PlayerInfo[i][pSavings]);
PlayerInfo[i][pSavings] += savings;
format(string,sizeof(string),"Your savings grew with 0.5 percent,total: %d",PlayerInfo[i][pSavings]);
SendClientMessage(i,COLOR_GREY,string);
}
How to do that calcules cuz it doesn't work
.
I need this fast.I need the Savings account to raise every payday with 0.5%
Re: Simple SAMP Math Symbols Question -
Calgon - 31.03.2011
PlayerInfo[i][pSavings]*100/5
will calculate 5% of 'pSavings,' if my math is right.
EDIT: Close enough, I suck at maths.
Re: Simple SAMP Math Symbols Question -
Mauzen - 31.03.2011
tag savings as a float or use floatround, and force the compiler to treat the calculation as a float. 5/10=0.5 = 0 as a float, and 0*x=0.
new savings = floatround(0.05*(PlayerInfo[i][pSavings]));
@Calg00ne: Yours will just multiply the value with 20
It would be the other way round: (PlayerInfo[i][pSavings]/100)*5
Re: Simple SAMP Math Symbols Question -
SkizzoTrick - 31.03.2011
Thanks all xD
It worked
Re: Simple SAMP Math Symbols Question -
-Rebel Son- - 01.04.2011
Quote:
Originally Posted by ******
Or just rearrange:
Код:
a = PlayerInfo[i][pSavings]
b = ((5 / 10) / 100) * a
- In integer maths 5 / 10 = 0...
- Remove unneeded brackets:
b = 5 / 10 / 100 * a
- Move operators about because they all have the same precedence:
b = 5 * a / 10 / 100
- Group operators:
b = 5 * a / (10 * 100)
- Result:
b = 5 * a / 1000
Despite the fact that's the same equation in theory, it can give a different result in integer maths because you're doing the multiplication last.
|
****** beat me to it.
Jk...
I had the same thought as calg00ne. :S