View Single Post
  #8  
Old 05-05-2011, 12:56 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,891
fadillzzz is an unknown quantity at this point
Default

Quote:
Originally Posted by Solistia View Post
Just in case others would like there to be a match 2 secondary prize (and just change the rewards to match your taste)
Code:
    if($slot1 == 1 && $slot2 == 1 && $slot3 == 1){
    $reward = 30;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 2){
    $reward = 30;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 3){
    $reward = 30;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 1 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 1 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 2 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 1){
    $reward = 10;
    }elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 2){
    $reward = 10;
    }elseif($slot1 == 1 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }elseif($slot1 == 2 && $slot2 == 3 && $slot3 == 3){
    $reward = 10;
    }else{
    $reward = 1;
    }
It's the long way I'm sure, but I'm no coder |D;;
Instead of writing super long if statements like a longcat, I suggest you take advantage of array.
This is just a small example:
PHP Code:
$slot = array(1=>mt_rand(1,3), 2=>mt_rand(1,3), 3=>mt_rand(1,3));

$match count(array_unique($slot));

if (
$match === 3)
{
    
// No match. 
}
elseif (
$match === 2)
{
    
// 2 Slots match each other.
}
elseif (
$match === 1)
{
    
// All slots match each other. (i.e. jackpot! :D)

Reply With Quote