CODE  
; Roulette Based on the bwf©_j production. 
; modified to run with Pete®tje's ST5.0 
; additions by FireHorse 
; add this line to ST5.0 to have spin every 20 questions 
; look for this section \/ 
; 
;;:::::::::::::::::::   setup new question 
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
;alias -l st_question { 
;  if ( 20 // $_(qnumber)) { BallToss }    << add this line 

menu menubar {
  -
  $Roulette.name $+ Roulette: 
  .Set Channel: if ($chan) %pokerchan = %pokerchan $chan 
  .Remove Channel: if ($chan) %pokerchan = $remove(%pokerchan,$chan) 
} 

alias tell { 
  .ctcpreply $1 TIME $2- 
} 
on *:TEXT:*!Roustop*:#:{ 
  if ($nick isop #) {
    set %Rou.running 0
    msg %pokerchan S Tahoma;0 The Roulette Table is closed no further bets are possible, this is the final spin 
  }
  else msg %pokerchan S eTahoma;0 Please ask a host to stop Roulette $nick 
}

on *:TEXT:*!Roulette*:#:{ 
  if ($nick isop #) RouStart
  else msg %pokerchan S eTahoma;0 Please ask a host to start Roulette $nick 
} 
alias RouStart {
  set %Rou.running 1
  msg %Pokerchan S Tahoma;0 You have 1 min to place your bet on the Roulette Table 
  .timerRouSpam1 1 30 RouDelay 
}
alias roulette {
  msg %Pokerchan S Tahoma;0 You have 1 min to place your bet on the Roulette Table 
  .timerRouSpam1 1 30 RouDelay 
} 

alias RouDelay { 
  msg %Pokerchan S Tahoma;0 You have 30 secs left to place your bet on the Roulette Table 
  .timerRouSpam2 1 30 BallToss 
} 

on *:TEXT:*!commsRou*:#:{ 
  tell $nick !Rou < bet > < amount > (amount can be 1 to 500)
  tell $nick bets = 1 to 36,  odd or even, red or black,  first(1 to 12) or second(13 to 24) or third(25 to 36), top(1 to 18) or bottom(19 to  36), left(1,4,7 etc.) or mid(2,5,8 etc.) or right(3,6,9 etc.),  double0 and zero > <bet> 
  tell $nick You can only bet on one of the above at one time. 
} 

alias -l rouplayers {
  var %i = 1
  while ($getrouplayer(%i) != $null) { inc %i }
  return $calc(%i - 1)
}
alias -l playernum {
  var %i = 1
  while ($getrouplayer(%i) != $null) {
    if ($1 == $getrouplayer(%i)) { return %i }
    inc %i
  }
}
alias -l isrouplayer { if ($playernum($1)) return $true }
alias -l getrouplayer { return $rouvar(player, $1) }
alias -l rouvar { return $readini(st50\Roulete.ini, $1, $2) }
alias -l rouset { writeini st50\Roulete.ini $1 $2 $3- }
alias -l roudel { remini st50\Roulete.ini $1- }

on *:TEXT:*!Rou*:#:{ 
  if (%Rou.running = 0) { msg %pokerchan S eTahoma;0 The Roulette table is closed, please ask a host to reopen it  | halt }
  if ($isrouplayer($nick)) { tell $nick Sorry $nick only one bet per spin | return }
  if (!$2) { tell $nick !Rou <type of bet> <bet> | halt } 
  if (!$3) { tell $nick !Rou <type of bet> <bet> | halt } 
  ;if ($3 > %frenzyscore ($nick)) { tell $nick You do not have that many points $nick | halt } 
  if ($3 > 500) { tell $nick The betting limit on this game is 500 please try again | halt } 
  if ($3 <= 0) { tell $nick You have to bet at least 1 $nick | halt } 
  if ($2 >= 1) && ($2 <= 36) { 
    msg %pokerchan S \rTahoma;0 $nick You have bet $3 on number $2 
    rouset Bet $nick $2
    rouset player $calc($rouplayers + 1) $nick
    rouset Bid $nick $3
    addpoint $nick - $+ $3 
    tell $nick your balance is now $stx_points($nick) 
    halt
  } 
  if ($2 isalnum ) && ($2 != odd) && ($2 != even) && ($2 != red) && ($2 != black) && ($2 != first) && ($2 != second) && ($2 != third) && ($2 !=  left) && ($2 != mid) && ($2 != right) && ($2 != zero) && ($2 != double0) && ($2 != top) && ($2 != bottom) { tell $nick Invalid bet $nick  please try again | halt } 
  if ($2 == odd) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick odd } 
  if ($2 == even) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick even } 
  if ($2 == red) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick r } 
  if ($2 == black) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick b } 
  if ($2 == first) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on numbers 1-12 at the roulette table  | rouset Bet $nick first } 
  if ($2 == second) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on numbers 13-24 at the roulette table  | rouset Bet $nick second } 
  if ($2 == third) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on numbers 25-36 at the roulette table  | rouset Bet $nick third } 
  if ($2 == top) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on numbers 1-18 at the roulette table  | rouset Bet $nick top } 
  if ($2 == bottom) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on numbers 19-36 at the roulette table  | rouset Bet $nick bottom } 
  if ($2 == left) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick left } 
  if ($2 == mid) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick mid } 
  if ($2 == right) { /msg %pokerchan S \rTahoma;0 $nick bets $3 points on $2 at the roulette table  | rouset Bet $nick right } 
  if ($2 == double0) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on 00 at the roulette table :O:O  | rouset Bet $nick 38 } 
  if ($2 == zero) { /msg %pokerchan S \rTahoma;0 $nick bets $3 on 0 at the roulette table  | rouset Bet $nick 37 } 
  if ($rouvar(Bet, $nick) == $null) { tell $nick Invalid bet $nick  please try again | halt }
  rouset player $calc($rouplayers + 1) $nick
  rouset Bid $nick $3
  addpoint $nick - $+ $3 
  tell $nick your balance is now $stx_points($nick) 
} 

alias BallToss { 
  set %ball $rand(0,37) 
  if (%ball == 0) { set %rball 37 | set %edov 0 | set %rebl 0 | set %112 0 | set %212 0 | set %312 0 | set %top 0 | set %bottom 0 | set %roul  0 | set %roum 0 | set %rour 0 } 
  if (%ball == 1) { set %rball 38 | set %edov 0 | set %rebl 0 | set %112 0 | set %212 0 | set %312 0 | set %top 0 | set %bottom 0 | set %roul  0 | set %roum 0 | set %rour 0 } 
  if (%ball == 2) { set %rball 1 | set %edov 1 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 3) { set %rball 2 | set %edov 0 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 4) { set %rball 3 | set %edov 1 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 5) { set %rball 4 | set %edov 0 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 6) { set %rball 5 | set %edov 1 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 7) { set %rball 6 | set %edov 0 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 8) { set %rball 7 | set %edov 1 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 9) { set %rball 8 | set %edov 0 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 10) { set %rball 9 | set %edov 1 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 11) { set %rball 10 | set %edov 0 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 12) { set %rball 11 | set %edov 1 | set %rebl Black | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 13) { set %rball 12 | set %edov 0 | set %rebl Red | set %112 1 | set %212 0 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 14) { set %rball 13 | set %edov 1 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 15) { set %rball 14 | set %edov 0 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 16) { set %rball 15 | set %edov 1 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 17) { set %rball 16 | set %edov 0 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 18) { set %rball 17 | set %edov 1 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 19) { set %rball 18 | set %edov 0 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 1 | set %bottom 0 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 20) { set %rball 19 | set %edov 1 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 21) { set %rball 20 | set %edov 0 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 22) { set %rball 21 | set %edov 1 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 23) { set %rball 22 | set %edov 0 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 24) { set %rball 23 | set %edov 1 | set %rebl Red | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 25) { set %rball 24 | set %edov 0 | set %rebl Black | set %112 0 | set %212 1 | set %312 0 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 26) { set %rball 25 | set %edov 1 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 27) { set %rball 26 | set %edov 0 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 28) { set %rball 27 | set %edov 1 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 29) { set %rball 28 | set %edov 0 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 30) { set %rball 29 | set %edov 1 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 31) { set %rball 30 | set %edov 0 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 32) { set %rball 31 | set %edov 1 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 33) { set %rball 32 | set %edov 0 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 34) { set %rball 33 | set %edov 1 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 35) { set %rball 34 | set %edov 0 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 1 | set %roum 0 | set %rour 0 } 
  if (%ball == 36) { set %rball 35 | set %edov 1 | set %rebl Black | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 1 | set %rour 0 } 
  if (%ball == 37) { set %rball 36 | set %edov 0 | set %rebl Red | set %112 0 | set %212 0 | set %312 1 | set %top 0 | set %bottom 1 | set  %roul 0 | set %roum 0 | set %rour 1 } 
  if (%ball == 0) { msg %pokerchan S pTahoma;0 :O The Roulette wheel has been spun and the ball lands on...0 :O  } 
  if (%ball == 1) { msg %pokerchan S pTahoma;0 :O The Roulette wheel has been spun and the ball lands on...00 :O  } 
  if (%ball >= 2) { msg %pokerchan S pTahoma;0 (*) The Roulette wheel has been spun and the ball lands on... %rebl %rball  } 
  var %x 1 
  while ($getrouplayer(%x) != $null) { 
    set %Name $getrouplayer(%x) 
    if ($rouvar(Bet, %Name) == odd) && (%edov == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2)
      tell %Name Well done %Name You win $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name) 
    } 
    if ($rouvar(Bet, %Name) == even) && (%edov == 0) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2 )  
      tell %Name Well done %Name You win $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == r) && (%rebl == Red) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2 ) 
      tell %Name Well done %Name You win $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == b) && (%rebl == Black) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == first) && (%112 == 1) { 
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name) 
    } 
    if ($rouvar(Bet, %Name) == second) && (%212 == 1) { 
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name) 
    } 
    if ($rouvar(Bet, %Name) == third) && (%312 == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == top) && (%top == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == bottom) && (%bottom == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 2 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 2) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == left) && (%roul == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 ) 
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == mid) && (%roum == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name) 
    } 
    if ($rouvar(Bet, %Name) == right) && (%rour == 1) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 3 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 3) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == 38) && (%rball == 38) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 71 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 71) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == 37) && (%rball == 37) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 36 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 36) your balance is now $stx_points(%Name)
    } 
    if ($rouvar(Bet, %Name) == %rball) {
      stx_addpoints %Name $calc($rouvar(Bid, %Name) * 36 )
      tell %Name Well done %Name You win  $calc($rouvar(Bid, %Name) * 36) your balance is now $stx_points(%Name) 
    }
    roudel player %x
    roudel bet %Name
    roudel bid %Name
    inc %x
  } 
  if ( %Rou.running = 0 ) { msg %pokerchan S Tahoma;0 The Roulette Table is now closed  | halt }

  ; IF You are using the trivia to run the roulette disable the 2 lines below or change lines to adjust times

  ;msg %pokerchan S Tahoma;0 Next Roulette Spin in 2 mins  
  ; .timerrespin 1 60 roulette
}  
;;;; other aliases
alias AddPoint { 
  var %Score $readini(FrenzyScores.ini, $1, score) 
  inc %Score $2 
  writeini FrenzyScores.ini $1 score %Score 
} 
