Code: Select all
# listen to all theo commands in channels
bind pub - theo pub:theo
# limit the chans to listen in by filling them in here ( more chans goes this way {#chan1 #chan2}
set enabledchans {#attack}
# procedure to check if chan where command is used is listed chan
proc isenabledchan { channel } {
global enabledchans
# compare each chan in $enabledchans with current chan and return 1 (true) if chan is listed
foreach enablechan $enabledchans {
if { $channel == $enablechan } {
return 1
}
}
return 0
}
# main procedure to handle the theo commands
proc pub:theo { nick uhost handle channel arg } {
# check if command should work in this chan
set chan [string tolower $channel]
if { ![isenabledchan $chan] } {
return 1
}
# check if valid command (calc)
if { [llength $arg] == 0 } {
putserv "PRIVMSG $channel :Unable to perform request, give command."
} else {
# get command and compare it to "calc"
set command [lindex $arg 0]
set command [string tolower $command]
if { [string compare $command calc] == 0 } {
# check if valid number of arguments
if { [llength $arg] < 2 } {
putserv "PRIVMSG $channel :Please check the help function if you don't know how to use this command."
# command syntax is ok, process request
} else {
set gold_start [lindex $arg 1]
set gold_hours [lindex $arg 2]
set gold_temp [expr $gold_start / 1.01]
set gold_new [expr $gold_temp * $gold_hours]
set gold_make [expr $gold_start + $gold_new]
putserv "PRIVMSG $channel :After $gold_hours hour(s) in the bank, $gold_start gold will be $gold_make gold."
}
}
}
}
Code: Select all
# command syntax is ok, process request
} else {
set gold_start [lindex $arg 1]
set gold_hours [lindex $arg 2]
set gold_new [expr [expr $gold_start * 0.01] * $gold_hours]
set gold_make [expr $gold_start + $gold_new]
putserv "PRIVMSG $channel :After $gold_hours hour(s) in the bank, $gold_start gold will be $gold_make gold."
}
}
Code: Select all
# command syntax is ok, process request
} else {
set gold_start [lindex $arg 1]
set gold_hours [lindex $arg 2]
set check 1
set gold_make "$gold_start"
while {$check != [expr $gold_hours + 1]} {
set gold_new [expr $gold_make * 0.01]
set gold_make [expr $gold_make + $gold_new]
set check [incr check]
}
putserv "PRIVMSG $channel :After $gold_hours hour(s) in the bank, $gold_start gold will be $gold_make gold."
}
}
Code: Select all
putserv "PRIVMSG $channel :After $gold_hours hour(s) in the bank, $gold_start gold will be [expr int($gold_make)] gold."
Code: Select all
proc integer {integer} {
if {[expr $integer - int($integer)] < 0.5} {
return [expr int($integer)]
} else {
return [expr int($integer) + 1]
}
}
Code: Select all
putserv "PRIVMSG $channel :After $gold_hours hour(s) in the bank, $gold_start gold will be [integer $gold_make] gold."