Originally Posted by
Discord
I mean, I want a set value/range of values to determine if I win or lose in a minigame for example.
It's for a website me and my friend are making, we need a game that upon clicking will bring another page telling you if you won or not based on odds previously coded for each opponent... the problem is coding the odds... :x
Anybody care to help? :3
If it's a simple true/false, totally random odds:
PHP Code:
function rollOdds($winPercent)
{
$randPercent = mt_rand(1, 100);
return $randPercent <= $winPercent;
}
if(rollOdds(50))
{
$winner = $PLAYERS[0];
}
else
{
$winner = $PLAYERS[1];
}
But I'd recommend something more like this: (you need an account to see links)