SA-MP Forums Archive
Any way on how to do 5x1, 5x2, 5x3 with 1 line? - 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: Any way on how to do 5x1, 5x2, 5x3 with 1 line? (/showthread.php?tid=584306)



Any way on how to do 5x1, 5x2, 5x3 with 1 line? - PizzaPuntjes - 03.08.2015

I am making something and I want to do that someone gets more bullets at 5, 10, 15, 20 etc..

So instead of case 5,10,15. Is there any line I could replace this with?


Re: Any way on how to do 5x1, 5x2, 5x3 with 1 line? - Vince - 03.08.2015

Modulus operator (%). Gives you the remainder of the division, e.g.:

pawn Код:
25 / 5 is 5 and the remainder is 0 -->> ((5 * 5) + 0) = 25
23 / 5 is 4 and the remainder is 3 -->> ((4 * 5) + 3) = 23
Ergo, if the remainder is 0 then you know that the value is a multiple of the divisor.