Jump to content
EGGTCL dot us

roulette.tcl 1.0.0

   (0 reviews)

About This File

Roulette Game Script

 

###Custom made Russian Roulette Script
#this is the first script I written myself so ther's probably couple of things I could have done different
#and I'm open for suggestions. If you got any ideas for me please contact me at dopeydwerg@hotmail.com


#list lucky comments
set pull {
    "quickly pulls the trigger..."
    "shakes as he slowly raises the gun to pull the trigger...."
    "calmly smiles as he pulls the trigger...."
    "puts the gun in his mouth...."
    "places the gun between his eyes,and starts to prey..."
    "Slowly raises the gun and put it against his temple...."
}

set lucky_msg {
    "...klik......Oops..did i forget to load this gun"
    ".....klik....Your luck wont last long hahaha"
    ".klik........Next turn u got a date with a bullet hahaha"
    ".klik....... wtf you lucky punk"
    "......klik....Your lucky that bullet didnt work...gamebot reloaded a fresh bullet"
    "....klik.....Bet you wish you were this lucky at the lottery"
    "....klik......Spin or shoot I don't care, if you win I'll just shoot you myself"
    ".....klik.....So you think your good.....I  dare you to play me next"
    "....klik......If i had a head like yours i'd been playing this game untill i lost"
    ".....klik......How can someone so ugly be so lucky"
}

#set vars
set player1 ""
set player2 "" 
set curplayer ""
set notcurplayer ""
set timeout_timer 0
set started 0
set turns 0
set bullit [rand 5]
#file you want scores to be written
set scorefile "roulette.txt"
set kill_count 0
set last_warn "" 

#binds
bind pub - .spin spin:gun
bind pub - .shoot shoot:gun
bind pub - .play challenge:player
bind pub - .reply reply:player
bind pub - .accept accept
bind pub - .chicken chicken
bind pub - .score show_player_score
bind pub - .scores showall


proc accept {nick host handle chan arg} {
    global rrstarttimer
            if {[utimerexists started]!=""} {killutimer $rrstarttimer}
    reply:player $nick $host $handle $chan "accept" 
}

proc chicken {nick host handle chan arg} {
    reply:player $nick $host $handle $chan "chicken" 
}

#proc to get somebody ro play with you
proc challenge:player {nick host handle chan arg} {
    global botnick player1 player2 started timeout_timer kill_count last_warn notcurplayer
    global rrstarttimer rrchannel
        if {$player1 != ""} {
            puthelp "PRIVMSG $chan :Sorry $player1 allready challenged $player2"
            return 0
        }
        if {![onchan $arg $chan]} {
            if {$nick == $last_warn} {
                puthelp "PRIVMSG $chan :now you're starting to annoy me so I have to shoot you."
                kill $nick $chan
                return 0
            }
            puthelp "PRIVMSG $chan :Sorry but I can't find $arg in this channel.You shure you got the name right?"
            puthelp "PRIVMSG $chan :And if you do it again I'm gonna shoot you."
            set last_warn $nick
            return 0
        }        
        if {$arg == ""} {
            puthelp "PRIVMSG $chan :Type .challenge <nick> to start the game"
            return 0
        }
        if {$started == 1} {
            puthelp "PRIVMSG $chan :Game allready running"
            return 0
        }
        if {$arg == $botnick} {
            puthelp "PRIVMSG $chan :Challenge accepted"
            puthelp "PRIVMSG $chan :RRRRRRRRRrrrrrrrr....."
            kill $nick $chan
            return 0
        }            
        set player1 $nick
        set player2 $arg
        set rrchannel $chan
        set timeout_timer 1
        utimer 20 [list timeout $chan ]
        set rrstarttimer [utimer 50 started]
        putquick "NOTICE $player2 :$nick challenges you to play Roulette with him."
        putquick "NOTICE $player1 :Challenge send to $player2"
        putquick "NOTICE $player2 :type .accept to play .chicken to chicken out"
        return 0
}

proc reply:player {nick host handle chan arg} {
    global botnick player1 player2 turns started curplayer timeout_timer notcurplayer
    global rrstarttimer rrchan
        if {$player1 == ""} {
            puthelp "NOTICE $nick :Sorry nobody challenged you yet"
            puthelp "NOTICE $nick :To Chalenge Somebody type .play <nick>"
            return 0
        }
        if {$nick != $player2} {
            puthelp "NOTICE $nick :That's not your call. $player2 was challenged by $player1"
            return 0
        }
        if {$arg == ""} {
            puthelp "NOTICE $nick :Type .accept to play or .chicken to decline"
            return 0
        }
        if {$started == 1} {
            puthelp "PRIVMSG $chan :Game allready running"
            return 0
        }         
        if {$arg == "chicken"} {
            puthelp "PRIVMSG $chan :$nick Chickened out. $player2 is a little pussycat."
            set player1 ""
            set player2 "" 
            return 0
        }
        if {$arg == "accept"} {
            set curplayer $player1
            set notcurplayer $player2
            set rrchan $chan
            putserv "notice $player1 :$nick accepted your challenge."
            putserv "notice $player1 :$curplayer goes first. .shoot shoots gun, .spin spins gun first"
            putserv "notice $player2 :$curplayer goes first. .shoot shoots gun, .spin spins gun first"
            incr_stats $curplayer "" "" "" "" ""
            incr_stats $notcurplayer "" "" "" "" ""
            set started 1
            set timeout_timer 0
            return 0
        }
}

proc spin:gun {nick host handle chan arg} {
    global botnick player1 player2 turns started bullit curplayer
    if {$nick != $curplayer} {
        puthelp "PRIVMSG $chan :Hey no cheating it's not your turn."
        return 0
    }
    if {$started == 0} {
        puthelp "PRIVMSG $chan :Game not running. Type .paly <nick> to play"
        return 0
    }
    set bullit [rand 5]
    puthelp "PRIVMSG $chan :$curplayer spins gun.....RRRRRRRRRrrrrrrrrre..."
    incr_stats $curplayer "" "" "" "+ 1" ""
    shoot:gun $nick $host $handle $chan $started
    return 0
}

proc shoot:gun {nick host handle chan arg} {
    global botnick player1 player2 turns curplayer started bullit lucky_msg pull notcurplayer playerstat
    if {$started == 0} {
        puthelp "PRIVMSG $chan :Game not running. Type .play <nick> To play"
        return 0
    }
    if {$nick != $curplayer} {
        puthelp "PRIVMSG $chan :Hey no cheating it's not your turn."
        return 0
    }
    set checknr1 [rand [llength $pull]]
    set temp_pull $pull
    set temp_pull [lindex $temp_pull $checknr1]
    puthelp "PRIVMSG $chan :$nick $temp_pull"
    incr_stats $curplayer "" "" "+ 1" "" ""
    #check if bullit is on position 0 if it is then your dead
    if {$bullit != 0} {
        #if not then set bullit - 1 like in a real fun
        set bullit [expr $bullit - 1]
        #increase turns taken for stats
        set turns [expr $turns + 1]
        #insert random msg
            set checknr [rand [llength $lucky_msg]]
            set temp_lol $lucky_msg
            set temp_lol [lindex $temp_lol $checknr]
            puthelp "PRIVMSG $chan :$temp_lol"
         #switch playsers so nobody can before there turn
        if {$curplayer == $player1} {
            set curplayer $player2
            set notcurplayer $player1
            } else {
                set curplayer $player1
                set notcurplayer $player2
                }
                puthelp "notice $curplayer :your turn Type .shoot or .spin"
                puthelp "notice $notcurplayer :$curplayer's Turn" 
        return 0
    #if bullit was on position 0 kick loser from chan and reset all used variables
    } else {
        incr_stats $curplayer "" "+ 1" "" "" "+ 1"
        incr_stats $notcurplayer "+ 1" "" "" "" "+ 1"
        show_score $notcurplayer
        putlog "$playerstat"
        puthelp "KICK $chan $curplayer :\002 \00304 BANG Your Dead!! Winner $playerstat"
        puthelp "PRIVMSG $chan :\002 \00312 Type .play <nick> to play, .scores for scorelist .score <nick> for score of nick"
        set player1 ""
        set player2 ""
        set curplayer ""
        set bullit [rand 5]
        set started 0
        return 0
    }
}

proc kill {nick chan} {
    global botnick
    set bullit [rand 5]
    for {set x 1} {$x < $bullit} {incr x} {
        puthelp "PRIVMSG $chan :klik..."
    }
    puthelp "PRIVMSG $chan :...BANG!!! You loose! "
    puthelp "KICK $chan $nick : Yep I'm still the king"
    return 0
}

proc timeout { chan } {
    global botnick player1 player2 turns curplayer started bullit lucky_msg pull timeout_timer
    if {$timeout_timer == 1} {
        puthelp "PRIVMSG $chan : $player2 is probably to chicken to play"
        set player1 ""
        set player2 ""
        set curplayer ""
        set bullit [rand 5]
        set timeout_timer 0
        set started 0
        return 0
    }
}

proc get_scores {} {
 global botnick scorefile rrscoresbyname rrscorestotal rrscores rrranksbyname rrranksbynum
 if {[file exists $scorefile]&&[file size $scorefile]>2} {
  set _sfile [open $scorefile r]
  set rrscores [lsort -dict -decreasing [split [gets $_sfile] " "]]
  close $_sfile
  set rrscorestotal [llength $rrscores]
 } else {
  set rrscores ""
  set rrscorestotal 0
 }
    if {[info exists rrscoresbyname]} {unset rrscoresbyname}
        if {[info exists rrranksbyname]} {unset rrranksbyname}
            if {[info exists rrranksbynum]} {unset rrranksbynum}       
 set i 0
 while {$i<[llength $rrscores]} {
  set _item [lindex $rrscores $i]
            set _nick [lindex [split $_item ,] 5]
            set _win [lindex [split $_item ,] 0]
            set _lost [lindex [split $_item ,] 1]
            set _shots [lindex [split $_item ,] 2]
            set _spins [lindex [split $_item ,] 3]
            set _played [lindex [split $_item ,] 4]
  set rrscoresbyname($_nick) $_win
  set rrranksbyname($_nick) [expr $i+1],$_win
  set rrranksbynum([expr $i+1]) $_nick,$_win
  incr i
 }
 return
}
proc incr_stats {who win loss shots spins played} {
    global botnick scorefile rrscoresbyname rrscorestotal rrscores rrranksbyname rrranksbynum
    set who [lindex [split $who "|"] 0]
    set who [lindex [split $who "_"] 0]
    get_scores
    if {$rrscorestotal>0} {
        set i 0
        if {[lsearch $rrscores "*,*,*,*,*,$who"]==-1} {
            append _newscores "0,0,0,0,0,$who "
        }
        while {$i<[expr [llength $rrscores] - 1]} {
            set _item [lindex $rrscores $i]
            set _nick [lindex [split $_item ,] 5]
            set _win [lindex [split $_item ,] 0]
            set _lost [lindex [split $_item ,] 1]
            set _shots [lindex [split $_item ,] 2]
            set _spins [lindex [split $_item ,] 3]
            set _played [lindex [split $_item ,] 4]
            if {[strlwr $who]==[strlwr $_nick]} {
                append _newscores "[expr $_win $win],[expr $_lost $loss],[expr $_shots $shots],[expr $_spins $spins],[expr $_played $played],$_nick "
            } else {
                append _newscores "$_win,$_lost,$_shots,$_spins,$_played,$_nick "
            }
            incr i
        }
    } else {
        append _newscores "0,0,0,0,0,$who "
    }
    set _sfile [open $scorefile w]
    puts $_sfile "$_newscores"  
    close $_sfile
    return 0
}

proc show_score {text} {
    global rrscoresbyname rrscores playerstat
    get_scores
    set idx [lsearch -glob $rrscores "*,*,*,*,*,$text"]
    putlog "[lindex $rrscores $idx]"
    set _item [lindex $rrscores $idx]
    set _nick [lindex [split $_item ,] 5]
    set _win [lindex [split $_item ,] 0]
    set _lost [lindex [split $_item ,] 1]
    set _shots [lindex [split $_item ,] 2]
    set _played [lindex [split $_item ,] 4]
    set playerstat "$_nick \00307played $_played games, \00309won $_win, \00304lost $_lost, \00313took $_shots shots"
    return 
}

proc showall {nick uhost handle chan arg} {
    global botnick scorefile rrscoresbyname rrscorestotal rrscores rrranksbyname rrranksbynum
    get_scores
    set totallength 16
    if {$rrscorestotal>0} {
        putquick "PRIVMSG $nick :\00304*****************Roulette Scores**********************"
        putquick "PRIVMSG $nick :\00304**| NickName        | Total |  Won  | Lost | Shots \00304|**"
        putquick "PRIVMSG $nick :\00304**|-----------------|-------|-------|------|-------|**"
        set i 0
        while {$i<[expr [llength $rrscores] - 1]} {
            set checked 0
            set _item [lindex $rrscores $i]
            set _nick [lindex [split $_item ,] 5]
            set _win [lindex [split $_item ,] 0]
            if {$_win < 10} {
                set _win "   $_win   "
                } elseif {$_win < 100} {
                    set _win "   $_win  "
                    }
            set _lost [lindex [split $_item ,] 1]
            if {$_lost < 10} {
                set _lost "   $_lost  "
                } elseif {$_lost < 100} {
                    set _lost "  $_lost  "
                    }
            set _shots [lindex [split $_item ,] 2]
            if {$_shots < 10} {
                set _shots "   $_shots   "
                } elseif {$_shots < 100} {
                    set _shots "   $_shots  "
                    }
            set _played [lindex [split $_item ,] 4]
            if {$_played < 10} {
                set _played "   $_played   "
                } elseif {$_played < 100} {
                    set _played "   $_played  "
                    }
            set checknick [split $_nick ""]
            set who [lindex [split $nick "|"] 0]
            set who [lindex [split $who "_"] 0]
            if {[string tolower $who] == [string tolower $_nick]} {set checked 1}
            set long [llength $checknick]
            set spaces ""
            for {set i2 $long} {$i2 < $totallength} {incr i2} {
                append spaces " "
            }
            if {$checked == 1} {
                putquick "PRIVMSG $nick :\00304**| \00312$_nick$spaces\00304|\00312$_played\00304|\00312$_win\00304|\00312$_lost\00304|\00312$_shots\00304|**"
            } else {
                putquick "PRIVMSG $nick :\00304**| \00310$_nick$spaces\00304|\00310$_played\00304|\00310$_win\00304|\00310$_lost\00304|\00310$_shots\00304|**"
            }
            incr i
        }
        putquick "PRIVMSG $nick :\00304********************End off list**********************"
    }
    return 0
}


proc show_player_score {nick host handle chan arg} {
    global rrscoresbyname rrscores playerstat
     if {$arg == ""} { set arg $nick } else { set arg [lindex [split $arg " "] 0] }
     show_score $arg
     puthelp "PRIVMSG $chan : $playerstat"
     return 1     
}

proc started {} {
    putlog "starttimer ended"
}


proc tggamemsg {what} {global rrchannel;putquick "PRIVMSG $rrchannel :[tgbold]$what"}
putlog "\00304Modern Roulette Made By Dopeydwerg Loaded"

 

  • Like 2

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
×
×
  • Create New...