jock Posted March 4, 2010 Posted March 4, 2010 <?php include_once ('globals.php'); if ($ir['tickets']<1) die ("you are out of tickets. [url='casino.php']<font color=red>Click here to buy more</font>[/url]"); if ($_GET ['action'] == luckyroller) { } $roll = rand(1,6); $rol = rand (1,6); $rol3 = rand (1,6); $r1 = $roll; $r2 = $rol; $r3 = $rol3; $sum =$r1 + $r2 +$r3; $db->query("UPDATE users SET tickets=tickets-5 WHERE userid=$userid"); print <<< HERE <align='center'> <table BORDER=2 CELLPADDING=2 CELLSPACING=2> <tr> <td> any combinations of 6 = 2 vouchers </td> <tr> <td> any combinations of 12 = 3 vouchers </td> </tr> <tr> <td> score 18 = 6 vouchers + $2500 </tr> </td> </table> Your total roll is</p> $r1 + $r2 + $r3 = $sum</p> </p> <image src='die/die$roll.jpg' alt ='die:$roll' /> <image src ='die/die$rol.jpg' alt = 'die:$rol' /> <image src ='die/die$rol3.jpg' alt = 'die:$rol' /> [url="rollem1.php"]<font color='red'>click to roll again</font>[/url] you have {$ir['tickets']} tickets</p> vouchers won {$ir['vouchers']}</p> <align='center'> <table BORDER=2 CELLPADDING=2 CELLSPACING=2> <tr> <td> exchange </td> <tr> <td> exchange </td> </tr> <tr> <td> exchange </tr> </td> </table> HERE; if ($sum == 6) { print "<h1>Winner !! </h1> take these 2 vouchers</p>"; $db->query("UPDATE users SET vouchers=vouchers+2 where userid=$userid"); } if ($sum == 12) { print'<h1>Winner </h1> take these 3 vouchers</p>'; $db->query("UPDATE users SET vouchers=vouchers+3 where userid=$userid"); } if ($sum == 18) { print '<h1>evens win </h1> take these 6 vouchers and $2500</p>'; $db->query( "UPDATE users SET vouchers=vouchers+6,money=money+2500 where userid=$userid"); } $h->endpage(); ?> still learn so go easy right the idea is you roll 3 die and have to score a set number to win and you get dollar /vouchers if you win the dollar you win goes to game money but what i im trying to do is say once you collect say x amount of vouchers. you can exchange them for either crystals or exp by click a link some thing like exchange x vouchers for 5 crystals --<exchange> exchange x vouchers for x donator days---< exchange > all help welcome as this is just for learning purpose so even code tips are welcome Quote
Zero-Affect Posted March 6, 2010 Posted March 6, 2010 if ($ir['tickets']<1) die ("you are out of tickets. [url='casino.php']<font color=red>Click here to buy more</font>[/url]"); the use of { and } is normally a good idea if ($_GET ['action'] == luckyroller) { } This is confusing what was your intention? $roll = rand(1,6); $rol = rand (1,6); $rol3 = rand (1,6); $r1 = $roll; $r2 = $rol; $r3 = $rol3; $sum =$r1 + $r2 +$r3; you could do something like $r1 = rand(1,6); $r2 = rand (1,6); $r3 = rand (1,6); $sum =$r1 + $r2 +$r3; this was just a quick look though Quote
AlabamaHit Posted March 7, 2010 Posted March 7, 2010 This what you trying to do? Completely untested, and made quickly. So if there is problems you know why. <?php include_once('globals.php'); if(isset($_POST['roll'])) { // //Get the random numbers for 3 die. // $die1 = mt_rand(1,6); $die2 = mt_rand(1,6); $die3 = mt_rand(1,6); $total = $die1 + $die2 + $die3; // //Display the roll. // printf('<image src="die/die'.$die1.'.jpg" alt="die:'.$die1.'" />'); printf('<image src="die/die'.$die2.'.jpg" alt="die:'.$die2.'" />'); printf('<image src="die/die'.$die3.'.jpg" alt="die:'.$die3.'" />'); printf(' Your total is '.$die1.' + '.$die2.' + '.$die3.' = '.$total.'.</p>'); // //This is where they win their tickets/money // if($total == 6) { $update_1 = sprintf("UPDATE users SET vouchers = vouchers + 2 WHERE userid = %u",abs(@intval($ir['userid']))); $db->query($update_1); printf('<h1>Winner!!</h1> Take these 2 vouchers</p>'); } else if($total == 12) { $update_1 = sprintf("UPDATE users SET vouchers = vouchers + 3 WHERE userid = %u",abs(@intval($ir['userid']))); $db->query($update_1); printf('<h1>Winner!!</h1> Take these 3 vouchers</p>'); } else if($total == 18) { $update_1 = sprintf("UPDATE users SET vouchers = vouchers + 6, money = money + 2500 WHERE userid = %u",abs(@intval($ir['userid']))); $db->query($update_1); printf('<h1>Winner!!</h1> Take these 6 vouchers and $2,500</p>'); } else { printf('Sorry you didn\'t win anything.'); } // //Print more and roll again. Also take their tickets for the roll // $update_2 = sprintf("UPDATE users SET tickets = tickets - 5 WHERE userid = %u",abs(@intval($ir['userid']))); $db->query($update_2); printf(' You have %u tickets.</p>',number_format($ir['tickets'])); printf(' You have %u vouchers.</p>',number_format($ir['vouchers'])); printf('[url="rollem1.php"]<font color="red"><Click to roll again</font>[/url]'); } else { // //No ticket no roll // if($ir['tickets'] == 0) { printf('Sorry, you are out of tickets. '); printf('[url="casino.php"]<font color="red">Click here to buy more</font>[/url]'); $h->endpage(); exit; } // //Table for showing what they win??? // printf(' You have %u tickets.</p>',number_format($ir['tickets'])); printf(' You have %u vouchers.</p>',number_format($ir['vouchers'])); printf('<center><table BORDER=2 CELLPADDING=2 CELLSPACING=2>'); printf('<tr>'); printf('<td>Any combinations of 6 = 2 vouchers.</td>'); printf('</tr><tr>'); printf('<td>Any combinations of 12 = 3 vouchers.</td>'); printf('</tr><tr>'); printf('<td>Score 18 = 6 vouchers + $2500.</td>'); printf('</tr><tr>'); printf('<form action="rollem1.php" method="post">'); printf('<input name="roll" type="submit" value="Roll" />'); printf('</form>'); printf('</table>'); } $h->endpage(); ?> Quote
Zero-Affect Posted March 8, 2010 Posted March 8, 2010 Excuse me AB but can i ask why you use mt_rand? I assumed it basically just gave a higher upper rand number. Quote
AlabamaHit Posted March 8, 2010 Posted March 8, 2010 I use it because it gives me more random numbers than rand() does. Quote
Zero-Affect Posted March 9, 2010 Posted March 9, 2010 Yeah i use it for the same reason but when you have defined the lower and upper variables then why would you need mt_rand? $die1 = mt_rand(1,6); $die2 = mt_rand(1,6); $die3 = mt_rand(1,6); Seems a little illogical Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.