How to check a random number
#7

lets assume i got my number set to 100:
pawn Code:
Player[i][Number]=100;
..so check will be 100 aswell:
pawn Code:
new check = Player[i][Number];
..taking the random out of (this variable set to) 100, is like
pawn Code:
new check = random(100);
...which returns a number ranging up from 0 to the maximim (100) minus 1.
0 upto 99 ARE 100 numbers, basically the "hit chance" is 1% when the playervariable is set to 100 and a random from 0-99 is taken. to achieve that, you can do this:
pawn Code:
new check = random(Player[i][Number]);
if(check == 0)
or, much simpler, in 1 line (checking for 0 with a max 100 = 1% chance) as before:
pawn Code:
if(random(Player[i][Number] == 0)
..also have a look @ https://sampwiki.blast.hk/wiki/Random
Reply


Messages In This Thread
How to check a random number - by Euan Hughes - 21.07.2012, 22:42
Re: How to check a random number - by Euan Hughes - 22.07.2012, 00:32
Re: How to check a random number - by Euan Hughes - 22.07.2012, 11:06
Re: How to check a random number - by Euan Hughes - 22.07.2012, 11:43
Re: How to check a random number - by [MM]RoXoR[FS] - 22.07.2012, 11:45
Re: How to check a random number - by Euan Hughes - 22.07.2012, 11:48
Re: How to check a random number - by Babul - 22.07.2012, 11:52
Re: How to check a random number - by Euan Hughes - 22.07.2012, 11:56
Re: How to check a random number - by Euan Hughes - 22.07.2012, 15:41
Re: How to check a random number - by Babul - 23.07.2012, 08:44

Forum Jump:


Users browsing this thread: 5 Guest(s)