Code: Select all
bind pub - !attack attack
bind pub - !defense defend
bind pub - !spy spy
proc attack { nick uhost handle chan text } {
set user [lindex $text 0]
set strength [lindex $text 1]
### MAKES SURE THAT BOTH USERNAME AND STRENGTH GET FILLED
if { [string equal $strength ""] } {
putserv "PRIVMSG $chan :syntax: !attack \$username \$strength-to-attack-with"
return 0
}
if { ![regexp -all -nocase -- {[0-9]} $strength] } {
### MAKES SURE THAT STRENGTH IS NUMERIC CHARS ONLY
putserv "PRIVMSG $chan :please supply numerical characters only"
return 0
}
### CALCULATION OF STRENGTH * 2 BELOW
set newstrength [expr $strength * 2]
### OUTPUT TO CHANNEL WHAT HAS HAPPENED BELOW
putserv "PRIVMSG $chan :$nick attacks $user with $newstrength hitpoints"
}
proc defend { nick uhost handle chan text } {
#### CODE HERE
}
proc spy { nick uhost handle chan text } {
#### CODE HERE
}
Code: Select all
set strength [lindex [split $text] 1]
if {![regexp -- {^[[:digit:]]+$} $strength} {
...
that wok with me vry fine, but i have on poblem.raider2k wrote:since i dont know what defense and spy exactly are going to do, heres the half-done code containing fully working attack code.
if i got something wrong please tell me about it and i will try to fix it asap
not tested, but should work thoughCode: Select all
bind pub - !attack attack bind pub - !defense defend bind pub - !spy spy proc attack { nick uhost handle chan text } { set user [lindex $text 0] set strength [lindex $text 1] ### MAKES SURE THAT BOTH USERNAME AND STRENGTH GET FILLED if { [string equal $strength ""] } { putserv "PRIVMSG $chan :syntax: !attack \$username \$strength-to-attack-with" return 0 } if { ![regexp -all -nocase -- {[0-9]} $strength] } { ### MAKES SURE THAT STRENGTH IS NUMERIC CHARS ONLY putserv "PRIVMSG $chan :please supply numerical characters only" return 0 } ### CALCULATION OF STRENGTH * 2 BELOW set newstrength [expr $strength * 2] ### OUTPUT TO CHANNEL WHAT HAS HAPPENED BELOW putserv "PRIVMSG $chan :$nick attacks $user with $newstrength hitpoints" } proc defend { nick uhost handle chan text } { #### CODE HERE } proc spy { nick uhost handle chan text } { #### CODE HERE }
Code: Select all
set newstrength [expr $strength * 2]
#Command substitution:
expr $strength * 2
#Variable substitution
expr {0[die]} * 2
Code: Select all
expr {0[die]} * 2 => "0[die] * 2"
#command substitution
die
#Oops, our bot died
Code: Select all
proc attack {nick uhost handle chan text} {
set arg [split $text]
set user [lindex $arg 0]
set strength [lindex $arg 1]