Over 100 posts
Registered: 02/15/09
Posts: 111
Loc: Ohio
|
Here is a quick little snipit that I use in a few scripts to simulate a slotmachine with the nicknames from a channel. The best way to use it is to assign the return value to a variable, ie var %slot.return = $slots(#channel) It will return 1 if two match, 2 if all 3 match and 0 if no match. I'll put a brief example of one way to use it at the bottom. By the way, the nickname will display n.ickname, so it doesn't trigger anyones watchlist.
;Syntax $slots(#channel) -*- /slots #channel
alias slots {
var %slots.chan = $1,%slotmatch,%slotmatch1
var %slot1 = $rand(1,$nick(%slots.chan,0)), %slot2 = $rand(1,$nick(%slots.chan,0)), %slot3 = $rand(1,$nick(%slots.chan,0))
var %scolor1 = $+ %slot1 $+ , $+ $calc(%slot1 + 1), %scolor2 = $+ %slot2 $+ , $+ $calc(%slot2 + 1), %scolor3 = $+ %slot3 $+ , $+ $calc(%slot3 + 1)
var %slots.chan = $1,%slotmatch,%slotmatch1,%output1,%output2,%output3
if (%slot1 > 12) { %scolor1 = $+ $right(%slot1,1) $+ , $+ $calc($right(%slot1,1) + 1) }
if (%slot2 > 12) { %scolor2 = $+ $right(%slot2,1) $+ , $+ $calc($right(%slot2,1) + 1) }
if (%slot3 > 12) { %scolor3 = $+ $right(%slot3,1) $+ , $+ $calc($right(%slot3,1) + 1) }
if (%slot1 == %slot2) && (%slot1 == %slot3) { %slotmatch1 = $nick(%slots.chan,%slot1) }
if (%slot1 == %slot2) || (%slot1 == %slot3) || (%slot2 == %slot3) { %slotmatch = $nick(%slots.chan,$ifmatch) }
%output1 = $left($nick(%slots.chan,%slot1),1) $+ . $+ $right($nick(%slots.chan,%slot1), $calc($len($nick(%slots.chan,%slot1)) -1))
%output2 = $left($nick(%slots.chan,%slot2),1) $+ . $+ $right($nick(%slots.chan,%slot2), $calc($len($nick(%slots.chan,%slot2)) -1))
%output3 = $left($nick(%slots.chan,%slot3),1) $+ . $+ $right($nick(%slots.chan,%slot3), $calc($len($nick(%slots.chan,%slot3)) -1))
msg %slots.chan $+ %scolor1 $+ %output1 %scolor2 $+ %output2 %scolor3 $+ %output3
if (%slotmatch1) { return 2 }
if (%slotmatch) { return 1 }
else { return 0 }
}
Here is a simple example of how to start making a game with this.
On !*:Text:!slots:#: {
var %slots.winner = $slots($chan)
if (%slots.winner == 2) { .msg $chan Jackpot $nick just won a million dollars }
if (%slots.winner == 1) { .msg $chan Winner $nick -*- 500 dollars }
if (%slots.winner == 0) { .msg $chan You Lose!!! ;(((( }
}
alias slots {
var %slots.chan = $1,%slotmatch,%slotmatch1
var %slot1 = $rand(1,$nick(%slots.chan,0)), %slot2 = $rand(1,$nick(%slots.chan,0)), %slot3 = $rand(1,$nick(%slots.chan,0))
var %scolor1 = $+ %slot1 $+ , $+ $calc(%slot1 + 1), %scolor2 = $+ %slot2 $+ , $+ $calc(%slot2 + 1), %scolor3 = $+ %slot3 $+ , $+ $calc(%slot3 + 1)
var %slots.chan = $1,%slotmatch,%slotmatch1,%output1,%output2,%output3
if (%slot1 > 12) { %scolor1 = $+ $right(%slot1,1) $+ , $+ $calc($right(%slot1,1) + 1) }
if (%slot2 > 12) { %scolor2 = $+ $right(%slot2,1) $+ , $+ $calc($right(%slot2,1) + 1) }
if (%slot3 > 12) { %scolor3 = $+ $right(%slot3,1) $+ , $+ $calc($right(%slot3,1) + 1) }
if (%slot1 == %slot2) && (%slot1 == %slot3) { %slotmatch1 = $nick(%slots.chan,%slot1) }
if (%slot1 == %slot2) || (%slot1 == %slot3) || (%slot2 == %slot3) { %slotmatch = $nick(%slots.chan,$ifmatch) }
%output1 = $left($nick(%slots.chan,%slot1),1) $+ . $+ $right($nick(%slots.chan,%slot1), $calc($len($nick(%slots.chan,%slot1)) -1))
%output2 = $left($nick(%slots.chan,%slot2),1) $+ . $+ $right($nick(%slots.chan,%slot2), $calc($len($nick(%slots.chan,%slot2)) -1))
%output3 = $left($nick(%slots.chan,%slot3),1) $+ . $+ $right($nick(%slots.chan,%slot3), $calc($len($nick(%slots.chan,%slot3)) -1))
msg %slots.chan $+ %scolor1 $+ %output1 %scolor2 $+ %output2 %scolor3 $+ %output3
if (%slotmatch1) { return 2 }
if (%slotmatch) { return 1 }
else { return 0 }
}
_________________________
If you already know everything, You can never learn anything :P
|