Our Scripts Vault contains many game scripts that you can use to create your own game!
$totalReward = 30;$rewardClaims = array(9,3,2);$claimTotal = array_sum($rewardClaims); // 14$ratio = $totalReward / $claimTotal; // 2.14$rewards = $rewardClaims;foreach($rewards as $key => $reward) $rewards[$key] = round($reward * $ratio, 0);$rewards[ mt_rand(0, count($rewards)-1) ] += max($totalReward - array_sum($rewards), 0);
To make it more friendly then to weakest player
$rewardClaims = array(sqrt(9),sqrt(3),sqrt(2));
I'd go through and give everyone 1 coin first to make sure that everyone gets something then use your formula. you could even do it a few times until caps are reached and just remove that player from the pool.Also if you limit the gap between powerful player and weak player then why would the powerful player help? better for him to solo and get all the loot.