My Coin Toss

By supergeo on Jul 03, 2005

Well, I decided to add in my coin toss. This is meant to be used on a bot.
Type !toss.
It randomly chooses what you have to match to win, and randomly chooses what you get. If they match, it says you won. If not, it says you lost.

on *:TEXT:*!toss*:#:{
  set %z $rand(1,2)
  if (%z == 1)  { set %pi Heads }
  else { set %pi Tails }
  set %wow $rand(1,2) 
  if (%wow == 1) { set %outcome Heads }
  else { set %outcome Tails }
  if (%outcome == %pi) { msg $chan $nick needs %pi to win. $me flips the coin. It lands on %outcome . $nick wins! }
  else { msg $chan $nick needs %pi to win. $me flips the coin. It lands on %outcome . $nick loses. }
}

;Commented Version

;Activates when !toss is used in a room.
;It will work with colored nick names and text :)
on *:TEXT:*!toss*:#:{
 ;Sets z to a 1 or a 2
  set %z $rand(1,2)
 ;If z is a 1, it sets %pi to heads.
  if (%z == 1)  { set %pi Heads }
 ;If z is a 2, it sets %pi to tails
  else { set %pi Tails }
 ;Sets %wow to a 1 or a 2
  set %wow $rand(1,2) 
 ;If wow is a 1, sets %outcome to Heads
  if (%wow == 1) { set %outcome Heads }
 ;If wow is a 2, sets %outcome to Tails
  else { set %outcome Tails }
 /* Checks to see if %pi is the same as %outcome eg. Heads and Heads
      If so, it messages the channel what the person needed to win, and 
      what they got, and says they won.  */
  if (%outcome == %pi) { msg $chan $nick needs %pi to win. $me flips the coin. It lands on %outcome . $nick wins! }
 /* If they don't match, eg. Heads and Tails, it shows what they needed 
     to win and what they recieved, and messages the channel that they lost.
 */
  else { msg $chan $nick needs %pi to win. $me flips the coin. It lands on %outcome . $nick loses. }
}

Comments

Sign in to comment.
Zachery   -  Sep 26, 2005

add this snippet to the game tag =/

 Respond  
supergeo   -  Jul 06, 2005

Also, Darth\'s code is good. It\'s also smaller and cleaner. But this still does the same thing ;)

 Respond  
supergeo   -  Jul 06, 2005

Also, Darth\'s code is good. It\'s also smaller and cleaner. But this still does the same thing ;)

 Respond  
supergeo   -  Jul 06, 2005

Or you can just leave it the way it is and have 2 extra characters ;)

 Respond  
xDaeMoN   -  Jul 05, 2005

Strip the colors then. There is an option in mIRC where you could strip the colors for incoming messages. My suggestion stays. See Darth\'s code.

 Respond  
supergeo   -  Jul 05, 2005

Lose the wildcards?

I made this on a server where the users are given nickname and text colors, and the wildcards are needed for it to function properly if the person has colors.

 Respond  
aeros   -  Jul 04, 2005

hm..

 Respond  
DarthReven   -  Jul 04, 2005

on *:text:!toss:#: { msg $chan $iif($r(1,2) == $r(1,2),Congratulations $nick you needed $iif($v1 == 1,Heads,Tails) and you got it,Sorry $nick you needed $iif($v2 == 1,Heads,Tails) but you got $iif($v1 == 1,Tails,Heads)) } no variables

 Respond  
xDaeMoN   -  Jul 04, 2005

I agree. Your code could be shorten to 3 lines or less. Also fix your trigger command.

With this \"on :TEXT:!toss*:#:{\", !toss can be triggered anytime they say it in a sentence. Lose the wildcards.

On your commented version, you have an incorrect usage of the comments.

/
This is a Comment
/

 Respond  
DarthReven   -  Jul 03, 2005

Variables aren\'t needed

 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.