Chance game

By Cados on Mar 04, 2010

A chance game. Very fun but the bot or person must be op'd.

[7:00:03pm] Cados: !chance
[7:00:04pm] @Weasand: So you want to take a chance on something? Let's do it.
[7:00:04pm] @Weasand: Congrats, you won a voice!
[7:00:04pm] @Weasand(~Dark@Damaged.beyond.repair) sets mode: +v Cados
[7:00:06pm] +Cados: !chance
[7:00:06pm] @Weasand: So you want to take a chance on something? Let's do it.
[7:00:07pm] @Weasand: Congrats, you won a ban!
[7:00:07pm]
@Weasand(~Dark@Damaged.beyond.repair) sets mode: +b !@Fighting.For.Nothing
[7:00:07pm] This !*@Fighting.For.Nothing ban affects: +Cados

on *:TEXT:!chance:#:{
  msg # So you want to take a chance on something? Let's do it.
  set %chance $rand(1,9)
  if (%chance == 1) { msg # Congrats, you won a voice! | mode $chan +v $nick }
  elseif (%chance == 2) { msg # Congrats, you won a kick! | kick $chan $nick Better luck next time. }
  elseif (%chance == 3) { msg # Congrats, you won a halfop! | .timer 1 2 mode $chan +h $nick }
  elseif (%chance == 4) { msg # Congrats, you won a ban! | .timer 1 2 mode $chan +b $address($nick,2) }
  elseif (%chance == 5) { msg # Congrats, you won a ball! | .timer 1 2 describe # gives $nick a red ball. }
  elseif (%chance == 6) { msg # Congrats, you won a rabid dog! | .timer 1 2 describe # gives $nick a rabid dog that mauls them to death. | .timer 1 3 kick $chan $nick You died. }
  elseif (%chance == 7) { msg # Congrats, you won an Xbox 360! | .timer 1 2 describe # gives $nick an Xbox360 with Call of Duty: Modern Warfare 2! }
  elseif (%chance == 8) { msg # Congrats, you won a memo! | .timer 1 2 ms send $nick Congradulations. }
  elseif (%chance == 9) { msg # Congrats, you won a website! | .timer 1 2 .notice $nick http://wolverines.ning.com/ }
}

Comments

Sign in to comment.
Dusk   -  Feb 10, 2011

Jethro_ thank you man!!!

 Respond  
Jethro   -  Feb 10, 2011

Dusk, this version will do what you wish for:

on @*:text:$($iif(!chance = $strip($1),$1)):#:{
  if !$(,$+(%,f,$site)) { 
    set -z $+(%,f,$site) 300 
    .msg # So you want to take a chance on something? Let's do it.
    var %chance = $r(1,9), %msg = .msg # Congrats, you won
    goto %chance
    :1 | %msg a voice | mode # +v $nick | halt
    :2 | %msg a kick | kick # $nick Better luck next time. | halt
    :3 | %msg a halfop | mode # +h $nick | halt
    :4 | %msg a ban | mode # +b $wildsite | halt
    :5 | %msg a ball | .describe # gives $nick a red ball. | halt
    :6 | %msg a rabid dog! | .describe # gives $nick a rabid dog that mauls them to death. | kick $chan $nick You died. | halt
    :7 | %msg an Xbox 360! | .describe # gives $nick an Xbox360 with Call of Duty: Modern Warfare 2! | halt
    :8 | %msg a memo! | ms send $nick Congradulations. | halt
    :9 | %msg a website! | .msg # $nick http://wolverines.ning.com/ | halt
  }
  else { notice $nick you need to wait 5 minutes before using the command: $1 }
}
 Respond  
Dusk   -  Feb 10, 2011

how do you set a time to the snipet i mean so people dont go flooding the channel with this game, they would have to wait like 5 minutes

 Respond  
raccoon   -  Mar 09, 2010

$1- == [ $me ]
$repace($1-,$chr(36),$chr(36) $+ !)
== [ $!me ]
.timer 1 1 msg $me [ $!me ]
[11:30] Timer 1 1 time(s) 1s delay msg Raccoon` $me
== $me being evaluated.

 Respond  
Korvin   -  Mar 08, 2010

why not alias safe return $replace($1,$,$!) or something like that

 Respond  
raccoon   -  Mar 08, 2010

Those aliases failed to prevent my exploit, using; .timer 1 1 msg $me $safe($1-)

The above line... using $1- from a user event (like on text) within /timer, will cause any user supplied identifier within $1- to be evaluated. That would be bad.

 Respond  
Jethro   -  Mar 08, 2010

raccoon, there are two safe aliases you can use to guard against the exploit. Although they're not perfect, they should yield a decent protection:

alias safe return $!decode( $encode($1,m) ,m)
alias safe bset -t &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1))
 Respond  
raccoon   -  Mar 08, 2010

People here love putting user input (text) through /timers, which has a nice habit of evaluating unfriendly malware.

 Respond  
sunslayer   -  Mar 05, 2010

Then again, someone could hack the site and pipe harmful commands to your unsuspecting client. :p mIRC doesnt evaluate anything it reads unless you tell it to. and the chance of that happening are very slim.

 Respond  
raccoon   -  Mar 05, 2010

Then again, someone could hack the site and pipe harmful commands to your unsuspecting client. :p

 Respond  
Korvin   -  Mar 05, 2010

then again, that will slow everything down..

 Respond  
Jethro   -  Mar 05, 2010

At the end of the day, I'd very much prefer the use of sockets to fetch randomized messages from a web site that correlates chance game, instead of storing a text file on my hard drive.

 Respond  
raccoon   -  Mar 05, 2010

Btw, the greatest advantage to this approach of using $read to randomly select a line, is if you should decide to remove lines, like line 3's "mode +h", you don't have to re-number all the lines below it. Just delete the line you don't want.

To quickly create a new chance.txt file in your mIRC directory for $read(chance.txt) to work, type the following in mIRC:

/run notepad chance.txt
 Respond  
Korvin   -  Mar 05, 2010

Lawl.

 Respond  
GuitarMasterx7   -  Mar 05, 2010

wow i feel stupid
lmao
thought wha he was referring to was only ops can use cmd ^^

srry Raccoon =]

 Respond  
sunslayer   -  Mar 05, 2010

@GuitarMasterx7 you would need op in order to set +h

 Respond  
Cados   -  Mar 05, 2010

Thanks I'll try it in the snippet.

 Respond  
GuitarMasterx7   -  Mar 05, 2010

PS. I added the @ prefix to the TEXT event, so it only triggers if you are opped.
das not very smart seeing how one of the options is

msg # Congrats, you won a voice! | mode # +v $nick
msg # Congrats, you won a halfop! | mode # +h $nick

an Cados
all you do is type //run $mircdir into ur chat box
an right click the folder that pops up, New > then New text document
copy paste Raccoons
stuff an paste into ur new txt doc
save document as chance.txt

$read(chance.txt)

will read a random command in the txt file an perform it

 Respond  
Cados   -  Mar 05, 2010

I see what you're saying but the part where you want me to make it write it in a file is beyond my knowledge :) Still learning how to use $gettok.

 Respond  
raccoon   -  Mar 05, 2010

This process of random selection can be better left to $read(chance.txt) which will select a random line from the file. You can put just the text portions of the /msg in this file, or an entire command or set of piped (|) commands on each line.

This also allows for easier future editing of a text file rather than modifying the contents of a script.

PS. I added the @ prefix to the TEXT event, so it only triggers if you are opped.

On @*:TEXT:!chance:#:{
  if (%FLOOD.CHANCE) return
  inc -z %FLOOD.CHANCE 5
  msg # So you want to take a chance on something? Let's do it.
  $read(chance.txt)
}

chance.txt

msg # Congrats, you won a voice! | mode # +v $nick
msg # Congrats, you won a kick! | kick # $nick Better luck next time.
msg # Congrats, you won a halfop! | mode # +h $nick
msg # Congrats, you won a ban! | mode # +b $address($nick,2)
msg # Congrats, you won a ball! | describe # gives $nick a red ball.
msg # Congrats, you won a rabid dog! | describe # gives $nick a rabid dog that mauls them to death. | kick # $nick You died.
msg # Congrats, you won an Xbox 360! | describe # gives $nick an Xbox360 with Call of Duty: Modern Warfare 2!
msg # Congrats, you won a memo! | ms send $nick Congradulations.
msg # Congrats, you won a website! | notice $nick http://wolverines.ning.com/
 Respond  
SnoooP   -  Mar 05, 2010

Jethro I think when Guitarmaster said use a timer flood, I think he meant add flood protection so the script can only be triggered after a certain amount of time. which was to only allow the script to trigger once every 5 seconds... And I think Cados misinterpreted and added a /timer instead of flood protection.. :)

 Respond  
Korvin   -  Mar 04, 2010

maybe its just because i started with gotos

 Respond  
sunslayer   -  Mar 04, 2010

I don't really like gotos lol no one does, lol

 Respond  
Korvin   -  Mar 04, 2010

I don't really like gotos lol

 Respond  
Jethro   -  Mar 04, 2010

/goto is pretty fast compared to if-then-else, and it's not confusing if you know how it works.

 Respond  
Cados   -  Mar 04, 2010

/goto Seems more confusing to people that just want to use it and they won't know what to do.

 Respond  
Jethro   -  Mar 04, 2010

Actually you don't need the if and elseif statements if you use the /goto:

on @*:text:$($strip(!chance)):#: {
  if (!%f) { set -z %f 5 | var %chance = $r(1,9), %msg = msg # Congrats, you won $&
      | msg # So you want to take a chance on something? Let's do it. | goto %chance
    :1 | %msg a voice | mode # +v $nick | halt
    :2 | %msg a kick | kick # $nick Better luck next time. | halt
    :3 | %msg a halfop | mode # +h $nick | halt
    :4 | %msg a ban | mode # +b $wildsite | halt
    :5 | %msg a ball | .describe # gives $nick a red ball. | halt
    :6 | %msg a rabid dog! | .describe # gives $nick a rabid dog that mauls them to death. | kick $chan $nick You died. | halt
    :7 | %msg an Xbox 360! | .describe # gives $nick an Xbox360 with Call of Duty: Modern Warfare 2! | halt
    :8 | %msg a memo! | ms send $nick Congradulations. | halt
    :9 | %msg a website! | .msg # $nick http://wolverines.ning.com/ | halt
  } 
}

A trigger control is added so users can only use the !chance command every 5 secs to prevent spam.
P.S. I don't see the need for timers.

 Respond  
Korvin   -  Mar 04, 2010

Congradulations and @guitarmasterx7, elseifs will speed up the scripts

 Respond  
Cados   -  Mar 04, 2010

Note taken. I'll edit it a little.

 Respond  
GuitarMasterx7   -  Mar 04, 2010

dun think u need all da elseif statements
and id recommend using a timer flood
scripts like this are an easy target for spam =]

 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.