Slots

By ^Neptune on Apr 26, 2009

My first PHP script! Woo! I think this is finally the right language I've been searching for, it looks so much like mIRC and I love it!

You can see the script "in action" @ http://dark-purple.comuv.com/slots.php (yes I know I should have made a button form, but I CBA).

Go easy on me. D=

<?php
  $slotone = mt_rand(1,3);
  $slottwo = mt_rand(1,3);
  $slotthree = mt_rand(1,3);
  echo "Your numbers are: $slotone $slottwo $slotthree";
  echo "<br />";
  echo "<br />";
    if ($slotone == 1 && $slottwo == 1 && $slotthree == 1) {
      echo "Congratulations! You have won!";
    } 
    else if ($slotone == 2 && $slottwo == 2 && $slotthree == 2) {
      echo "Congratulations! You have won!";
    } 
   else if ($slotone == 3 && $slottwo == 3 && $slotthree == 3) {
      echo "Congratulations! You have won!";
    } 
    else { echo "You have lost - please try again!"; }
?>

Comments

Sign in to comment.
PATX   -  Aug 13, 2009

i prefer python...

 Respond  
Korvin   -  Aug 13, 2009

IMO php is A LOT more versatile than mIRC, it is a lot more useful and funner to script

 Respond  
Aucun50   -  Apr 28, 2009

Thanks but i don't have to time right now.

 Respond  
bone282   -  Apr 28, 2009

tbh php is far less confusing than mirc. and a bad ass if you compare mirc sockets against php's diverse get functions esp cURL <3. if you want Mr. Aucun50.. i can give you a lil irc php bot package to play about with editing n what not

 Respond  
Aucun50   -  Apr 27, 2009

Nice, i didn't think i would understand any of this but it's close to mirc scripting. As hawkee said only one if statement needed although i like the way you plan every step and possibility.

 Respond  
Hawkee   -  Apr 27, 2009

mt_rand — Generate a better random value,

http://us2.php.net/mt_rand

 Respond  
^Neptune   -  Apr 27, 2009

What is mt_rand may I ask...?

 Respond  
Hawkee   -  Apr 26, 2009

Keep it up, PHP is one of the best languages to learn IMO. Would have been better to do it like this though:

<?php
  $slotone = mt_rand(1,3);
  $slottwo = mt_rand(1,3);
  $slotthree = mt_rand(1,3);
  echo "Your numbers are: $slotone $slottwo $slotthree<br \><br \>";
  if ($slotone == $slottwo and $slottwo == $slotthree) {
      echo "Congratulations! You have won!";
  } 
  else { echo "You have lost - please try again!"; }
?>

mt_rand() is better than rand() and you really only need a single if-statement.

 Respond  
PATX   -  Apr 26, 2009

lol cool script. yeah there should be a button but you can use javascript for that even. yeah php is an ok lang. but it gets u into a scripting pattern which you r then stuck in :( but if it is what suits u its cool lol. anyway good script. i might put it up on my site even. keep up the good work!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.