Casino script by Stewie!
I have updated this slightly, please inform me of any bugs.
Commands: > !slots, !balance, !add/!del chips amount
All comments are welcome.
[8:49pm] <~Stewie> !add chips 100
[8:49pm] <&ThunderBolt> This is the correct format: !add chips .
[8:49pm] <~Stewie> !add chips Stewie 100
[8:49pm] <&ThunderBolt> Stewie has added 100 chips to Stewie's fund! Total: 100
[8:49pm] <~Stewie> -
[8:49pm] <~Stewie> !del chips
[8:49pm] <&ThunderBolt> This is the correct format: !del chips .
[8:49pm] <~Stewie> !del chips Stewie 50
[8:49pm] <&ThunderBolt> Stewie has removed 50 chips from Stewie's fund! Total: 50
[8:49pm] <~Stewie> -
[8:49pm] <~Stewie> !slots
[8:49pm] <&ThunderBolt> Stewie, Please use the correct syntax: !slots .
[8:50pm] <~Stewie> !slots 1
[8:50pm] <&ThunderBolt> The winning slots were: ( % )( $ )( $ )
[8:50pm] <&ThunderBolt> Sorry, you lose 1 chip/s
[8:50pm] <&ThunderBolt> Stewie, your new balance is 49
[8:50pm] ThunderBolt Please Wait 10 seconds if you want to play again.
[8:50pm] ThunderBolt You can now play again!
[8:50pm] <~Stewie> -
[8:50pm] <~Stewie> !balance
[8:50pm] <&ThunderBolt> Stewie currently has 49 chips.
Comma alias was made by Fibre0ptics
;;;;;;;;;;;;;;;;;;;;;;;;;;
;Please changed the number to suit your prefrence
;auto credits a user once they have reached 0 chip/s
;The default is currently set at 100
alias -l autoCredit return 100
;;;;;;;;;;;;;;;;;;;;;;;;;;
on $*:TEXT:/^!(add|del) chips( |$)/Si:#:{
var %cmd = $regml(1)
if (!$4) || ($4 !isnum) {
msg $chan This is the correct format: $iif(%cmd == add,!add,!del) chips <nick> <amount of chips>.
return
}
var %chips = $calc($read(CasinoChips.txt, s, $3) $iif(%cmd == add,+,-) $4)
write -ds $+ $3 CasinoChips.txt
write CasinoChips.txt $3 %chips
msg $chan $read(CasinoChips.txt, s, $3)
if (%cmd == add) msg $chan $nick has added $comma($4) chips to $3 $+ 's fund! Total: $comma(%chips)
else {
msg $chan $nick has removed $comma($4) chips from $3 $+ 's fund! Total: $comma(%chips)
}
}
on $*:TEXT:/^!balance( |$)/Si:#:{
var %f = $iif(!$2,$nick,$2), %balance = $read(CasinoChips.txt, s, %f)
if (!$read(CasinoChips.txt, s, %f)) { msg $chan $nick $+ , %f currently has no chips. | return }
msg $chan %f currently has $comma(%balance) chips.
}
on $*:TEXT:/^!slots( |$)/Si:#:{
var %cbalance = $read(CasinoChips.txt, s, $nick)
if (%cbalance < $2) msg $chan $nick $+ , you only have %cbalance chips
elseif (!$read(CasinoChips.txt, s, $nick)) msg $chan $nick $+ , You do not have anymore Chips to bet with.
elseif ($2 == $null) || ($2 !isnum) msg $chan $nick $+ , Please use the correct syntax: !slots <bet here>.
elseif ($2 < 0) msg $chan $nick $+ , Please use a positive number to bet with.
else {
set %prand $rand(1,175)
set %srand1 $rand(1,5)
set %srand2 $rand(1,5)
set %srand3 $rand(1,5)
while (%srand1 == %srand2) {
set %srand2 $rand(1,5)
}
if (%prand < 5) {
set %srand1 3
set %srand2 3
set %srand3 3
}
elseif (%prand < 15) {
set %srand1 2
set %srand2 2
set %srand3 2
}
elseif (%prand < 30) {
set %srand1 1
set %srand2 1
set %srand3 1
}
if (%srand1 == 1) set %srand1 @
if (%srand1 == 2) set %srand1 %
if (%srand1 == 3) set %srand1 $
if (%srand1 == 4) set %srand1 &
if (%srand1 == 5) set %srand1 !
if (%srand2 == 1) set %srand2 @
if (%srand2 == 2) set %srand2 %
if (%srand2 == 3) set %srand2 $
if (%srand2 == 4) set %srand2 &
if (%srand2 == 5) set %srand2 !
if (%srand3 == 1) set %srand3 @
if (%srand3 == 2) set %srand3 %
if (%srand3 == 3) set %srand3 $
if (%srand3 == 4) set %srand3 &
if (%srand3 == 5) set %srand3 !
set %win1 $2
set %win2 $calc( $2 * 5 )
set %win3 $calc( $2 * 10 )
set %awins 0
msg $chan The winning slots were: ( %srand1 )( %srand2 )( %srand3 )
if (%srand1 == @) if (%srand2 == @) if (%srand3 == @) {
if (%srand1 == %srand2 && %srand2 == %srand3) {
if ($calc( %win1 * 2 ) > %awins) set %awins $calc( %win1 * 2 )
}
}
if (%srand1 == % || %srand2 == % || %srand3 == %) {
if (%srand1 == %srand2 && %srand2 == %srand3) {
if (%win2 > %awins) set %awins %win2
}
}
if (%srand1 == $ || %srand2 == $ || %srand3 == $) {
if (%srand1 == %srand2 && %srand2 == %srand3) {
if (%win3 > %awins) set %awins %win3
}
}
if (%awins == 0) {
msg # Sorry, you lose $comma($2) chip/s
write -ds $+ $nick CasinoChips.txt
set %outval $calc( %cbalance - $2 )
write CasinoChips.txt $nick %outval
}
else {
msg # Well done! You win $comma(%awins) chips!
write -ds $+ $nick CasinoChips.txt
set %outval $calc(( %cbalance - $2 ) + %awins ))
write CasinoChips.txt $nick %outval
}
msg # $nick $+ , your new balance is $comma($read(CasinoChips.txt, s, $nick))
if ($read(CasinoChips.txt, s, $nick) == 0) {
write -ds $+ $nick CasinoChips.txt
write CasinoChips.txt $nick $autoCredit
.notice $nick You reached 0 chips, and have been auto-credited with $autoCredit chip
}
notice $nick Please Wait 10 seconds if you want to play again.
ignore -cu10 $nick
$+(.timer,.,$nick,.slots) 1 10 notice $nick You can now play again!
}
}
;Comma alias made by Fibre0ptics
alias -l comma {
var %a, %b = $regsub($ticks,$1,/\G([+-]?\d+?)(?=(?:\d{3})++(?=\.\d++$|$))/g,\1 $+ $chr(44),%a)
return %a
}
IllogicTC wrote:
Nice start. I would like to see more added in the future, at least simplistic games. Maybe Blackjack? If you're not looking for tons of interaction with the bot before getting to the part where you win or lose, make it like "Streamlined Blackjack", where you and the dealer are given a number $rand(4,21) and whoever is higher wins. There's lots of gambling games to choose from. Good luck in your endeavours if you decide to expand this script. And i will see what i can do :)
Nice start. I would like to see more added in the future, at least simplistic games. Maybe Blackjack? If you're not looking for tons of interaction with the bot before getting to the part where you win or lose, make it like "Streamlined Blackjack", where you and the dealer are given a number $rand(4,21) and whoever is higher wins. There's lots of gambling games to choose from. Good luck in your endeavours if you decide to expand this script.
And yet he calls everybody a troll. I won't use regsubex because it's not much different from the while loop version you showed, consumes more bytes than my tokenize method, and not backward compatible to any version below 6.17. Besides regsubex and while loop, you got any novel idea in mind? I suppose not.
Just open ur script editor in mIRC (alt+r or tools->script editor) then file->new, paste the script click OK and it'll work :>