SA-MP Forums Archive
Help with random numbers - 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: Help with random numbers (/showthread.php?tid=656496)



Help with random numbers - ,TomY' - 17.07.2018

Hi all. I would like to create system: it will be 5 variables, after my action system will add random number to all variables, but total amount will be 100 ( variable1 + variable2 + variable3 + variable4 + variable5 = 100 ). How to create it? I know, how to create variables, add random number, but how to keep total amount = 100?


Re: Help with random numbers - CodeStyle175 - 17.07.2018

PHP код:
new var[5];
for(new 
i4i++)var[i]=10+random(10);
var[
4]=100-var[3]-var[2]-var[1]-var[0]; 



Re: Help with random numbers - ,TomY' - 17.07.2018

Thanks man!!!