Coin Flip Snippet (Updated!)

By Stewie1k94 on Apr 08, 2011

A simple Coin Flip Snippet I have just gotten around to update.

Any way to use: !flip heads/tails

Updates: Flood Protection...

on *:TEXT:*:#:{
  if ($1 == !flip) && ($istok(heads tails,$2,32)) {
    if ($($+(%,fflood,$remove($chan,$chr(35))),5) == $null) {
      var %frand = $rand(1,2)
      msg # The coin landed on: $iif(%frand == 1,Heads,Tails)
      set -u20 $+(%,fflood,$remove($chan,$chr(35))) on
    }
    else { .notice $nick Command can only be used every 20 seconds! }
  }
}

Comments

Sign in to comment.
xbox_gamer1   -  Apr 29, 2011

lol

 Respond  
Stewie1k94   -  Apr 29, 2011

yay it worked

 Respond  
Stewie1k94   -  Apr 29, 2011
testing lol
 Respond  
Dani_l11   -  Apr 28, 2011

BB Tags,

put your code here

 Respond  
Stewie1k94   -  Apr 26, 2011

ive been wondering how u get the code box

 Respond  
xbox_gamer1   -  Apr 26, 2011

how you get that code box

 Respond  
Jethro   -  Apr 26, 2011

xbox_gamer1, use this one:

on !*:join:#:jp
on !*:part:#:jp 
alias -l jp {
  if $(,$+(%,jpon.,#)) {
    msg # $nick has $iif($event = join,joined,left) #
  }
}
on $*:text:/^!jp\so(n|ff)$/iS:#:{
  if !$nick(#,$nick,rv) && !%f {
    inc -u3 %f
    if $regml(1) == n {
      set $+(%,jpon.,#) $true
      .msg # xbox_gamer1's script is now switched on.
    }
    else {
      .msg # xbox_gamers1's join/part script is now switched off
      unset $+(%,jpon.,#)
    }
  }
}

It'll only respond to the channels where you have the command set for:

!jp on
!jp off

to turn the notice from a channel where you don't want the message shown.

 Respond  
xbox_gamer1   -  Apr 26, 2011

toclafane..... it's like starting to work in all channels now without beening turned on :/


xbox_gamer1
justin.tv

 Respond  
Stewie1k94   -  Apr 25, 2011

yw

 Respond  
xbox_gamer1   -  Apr 25, 2011

thanks :)

 Respond  
Stewie1k94   -  Apr 25, 2011

on :JOIN:#:{ if ($($+(%,jpon.,$chan),2) == 0) { halt } | { msg $chan $nick has join $chan } }
on
:PART:#:{ if ($($+(%,jpon.,$chan),2) == 0) { halt } | { msg $chan $nick has left $chan } }
on :TEXT:!jp:#: {
if ($nick($chan,$nick,@&~)) {
if ($2 == off) {
set $+(%,jpon.,$chan) 0
msg $chan xbox_gamers1's join/part script is now switched off
}
else if ($2 == on) {
set $+(%,jpon.,$chan) 1
msg $chan xbox_gamer1's script is now switched on
}
}
}

that ok?

 Respond  
Stewie1k94   -  Apr 25, 2011

ok

 Respond  
xbox_gamer1   -  Apr 25, 2011

like this

On :JOIN:#:{
.msg # $nick has join!
}
on :PART:#:{
.msg # $nick has left!
}

but with a on and off switch

 Respond  
Stewie1k94   -  Apr 25, 2011

ill see what i can do

 Respond  
Stewie1k94   -  Apr 25, 2011

so it joins the channel and leaves the channel but with a on off switch

 Respond  
xbox_gamer1   -  Apr 25, 2011

toclafane can you make and join/part script with an on and off switch like this one :)

 Respond  
Stewie1k94   -  Apr 25, 2011

thanks xbox_gamer1

 Respond  
Jethro   -  Apr 21, 2011

Well, I'd say just around the byte size (really not drastic) if you didn't use $chr(2) and $chr(3)

 Respond  
Dani_l11   -  Apr 21, 2011

Mine's shorter Jehtro_, but i used $chr(2) and $chr(3) instead of those blocks ;)

 Respond  
xbox_gamer1   -  Apr 20, 2011

nice Job toclafane1
:)

 Respond  
Jethro   -  Apr 09, 2011

Dani_l11,

//tokenize 32 4heads 4tails | msg # 3the coin landed on $(,$+($,$r(1,$0)))

!!!

 Respond  
Dani_l11   -  Apr 09, 2011
  msg # $+($chr(2),$chr(3),3,the) coin landed on $chr(3) $+ 4 $iif($r(0,1),$chr(2) $+ heads,tails) 

!

 Respond  
Jethro   -  Apr 08, 2011

There's no such identifier as $theme

You can do it as such:

on *:TEXT:!cf *:#:{
  if ($nick($chan,$nick,@&~)) && ($istok(on off,$2,32)) {
    set $+(%,con.,$chan) $iif($pos($2,on,1),0,1)
    msg $chan toclafane's coin flip is now switched $2
  }
}

Saves you about 78 bytes and the repetition.

 Respond  
Jethro   -  Apr 08, 2011
on *:TEXT:!flip:#:{
  if (%flood [ $+ [ $nick ] ]) { return }
  set -u3 %flood [ $+ [ $nick ] ] $true
  msg $chan 4 $nick 3flips a coin...
  set -l %flip $rand(1,2)
  msg # 3the coin landed on $iif(%flip == 1,4heads,4tails)
}
 Respond  
Stewie1k94   -  Apr 08, 2011

@bielie before i post the scripts i test them and they work so how do they barely work

 Respond  
Stewie1k94   -  Apr 08, 2011

but is my codes ok or are have they just failed don't foget im only learning

 Respond  
Jethro   -  Apr 08, 2011

Bielie, that's the way to get better by accepting and learning from people's suggestions. I have seen many people mislead others with redundant codes, and that's not an appropriate practice and will likely result in the redundancy being passed down...

set -eu3 %flood [ $+ [ $nick ] ] $true

Use the -l switch> set -l %flip $rand(1,2)to make it local instead of global.

You don't need the -e switch for the trigger control. Because upon existing, mIRC will get a timed variable unset.

 Respond  
Scakk   -  Apr 08, 2011

For this bit

set %flip $rand(1,2)

I would just use var as there is no need to set a global variable for this one.

var %flip $rand(1,2)
 Respond  
Stewie1k94   -  Apr 08, 2011

i have updated it and it does work i tested it

 Respond  
Stewie1k94   -  Apr 08, 2011

well i am trying

 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.