22.07.2012, 11:52
lets assume i got my number set to 100:
..so check will be 100 aswell:
..taking the random out of (this variable set to) 100, is like
...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:
or, much simpler, in 1 line (checking for 0 with a max 100 = 1% chance) as before:
..also have a look @ https://sampwiki.blast.hk/wiki/Random
pawn Code:
Player[i][Number]=100;
pawn Code:
new check = Player[i][Number];
pawn Code:
new check = random(100);
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)
pawn Code:
if(random(Player[i][Number] == 0)