Ok, im sorta working on some ghetto text game... and i cant figure out a simple way to do a chance to do something.
ie:
30% chance to yada yada.
what i did was make a table with entries numbered 1-100 and i just make a random number and
function random_chance($percent) {
$some_num = rand(1, 100);
$result = mysql_query("select * from chance order by RAND()");
for ($i=1; $i<=$percent; $i++) {
$chance = mysql_fetch_row($result);
if ($chance[0] == $some_num) return true;
}
return false;
}
is there a built in function that does the same thing? anyone?