Blas
|
on *:text:!gamble*:#: {
if (%floodgamble) || ($($+(%,floodgamble.,$nick),2)) { return }
set -u5 %floodgamble On
set -u2400 %floodgamble. $+ $nick On
if ($2 isnum 1-50) {
var %randgamble = $rand(1,100)
if (%randgamble <= 70) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - $2)
msg $chan $nick rolls a %randgamble and loses! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks.
}
elseif (%randgamble >= 96) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + ($2 * 3))
msg $chan $nick rolls a %randgamble and wins triple their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
else {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + ($2 * 2))
msg $chan $nick rolls a %randgamble and wins double their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
}
elseif ($2 isnum) msg $chan You can only gamble in the range of 1 - 50 SN1PEbucks.
else msg $chan To gamble SN1PEbucks, use the form !gamble <amount (1-50)>
} I'm not sure how the script was executing both IF statements, as I don't see how %randgamble can be both "less/equal to 70" AND "more/equal to 96." But the issue should be fixed if you use "elseif" instead of another "if" statement. The above code should work. As for the whispering cooldowns, I've found two ways to do this with my Twitch scripts. Either use a timer, so that when the cooldown ends, your bot will also whisper the user letting them know that their cooldown is over. You may not want to whisper the user when the CD is over, so the more likely solution is to just use a variable or hash table item that counts down. The code below should work, I added a section to set a cooldown variable, as well as whisper the user if they try to use the command while they are on CD. As for getting whispers to work in mIRC, if you already have the JSONForMirc script, I highly suggest you also check out SReject's mTwitch scripts. Just load the mTwitch.Core.mrc and mTwitch.GroupChat.mrc scripts, and boom, whispers will work on your mIRC bot. on *:text:!gamble*:#: {
if (%floodgamble) { return }
set -u5 %floodgamble On
if ($($+(%,gamble_CD.,$nick),2)) MSG $nick $nick $+ , please wait for your cooldown to expire in $duration(%gamble_CD. [ $+ [ $nick ] ]) before using !gamble again.
elseif ($2 isnum 1-50) {
var %randgamble = $rand(1,100)
if (%randgamble <= 70) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - $2)
msg $chan $nick rolls a %randgamble and loses! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks.
}
elseif (%randgamble >= 96) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + ($2 * 3))
msg $chan $nick rolls a %randgamble and wins triple their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
else {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + ($2 * 2))
msg $chan $nick rolls a %randgamble and wins double their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
SET -ze %gamble_CD. $+ $nick 2400
}
elseif ($2 isnum) msg $chan You can only gamble in the range of 1 - 50 SN1PEbucks.
else msg $chan To gamble SN1PEbucks, use the form !gamble <amount (1-50)>
} EDIT: I should have mentioned something that I found out the hard way myself. I've learned that it's a good idea to use $floor or $round on the number that the user uses to gamble. The reason being that a user can "exploit" the points system, by using a number with decimal places and screwing things up. $floor will remove any decimal places. The code below should work. on *:text:!gamble*:#: {
if (%floodgamble) { return }
set -u5 %floodgamble On
if ($($+(%,gamble_CD.,$nick),2)) MSG $nick $nick $+ , please wait for your cooldown to expire in $duration(%gamble_CD. [ $+ [ $nick ] ]) before using !gamble again.
elseif ($2 isnum 1-50) {
var %wager = $floor($2)
var %randgamble = $rand(1,100)
if (%randgamble <= 70) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - %wager)
msg $chan $nick rolls a %randgamble and loses! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks.
}
elseif (%randgamble >= 96) {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + (%wager * 3))
msg $chan $nick rolls a %randgamble and wins triple their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
else {
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) + (%wager * 2))
msg $chan $nick rolls a %randgamble and wins double their bet! $nick now has $readini(Points.ini,$+(#,.,$nick),Points) SN1PEbucks!
}
SET -ze %gamble_CD. $+ $nick 2400
}
elseif ($2 isnum) msg $chan You can only gamble in the range of 1 - 50 SN1PEbucks.
else msg $chan To gamble SN1PEbucks, use the form !gamble <amount (1-50)>
}
Last edited by Blas; 14/01/16 07:12 AM.
|