Any help is greatly appreciated.
Code: Select all
bind pub - !random pub_random
proc pub_random {nick uhost hand chan t} {
if {$t == ""} {
putserv "NOTICE $nick : Hi $nick, a random user is $randomuser"
}
}
Code: Select all
bind pub - !random pub_random
proc pub_random {nick uhost hand chan t} {
if {$t == ""} {
putserv "NOTICE $nick : Hi $nick, a random user is $randomuser"
}
}
Code: Select all
set users [chanlist $chan]
if {[set total [llength $users]] < 3} {
puthelp "NOTICE $nick :We are the only ones here!"
return 0
}
set randomuser $nick
while {$randomuser == $nick || [isbotnick $randomuser]} {
set randomuser [lindex $users [rand $total]]
}
you set randomuser $nick then check if $randomuser != $nick in the while condition, the code will never enter the loop then. You probably meant to set randomuser "" instead of $nick.De Kus wrote:a random username from the current people on the channel?!The counter to 10 just makes sure to not loop infinite, if the user and the bot are the only one in the channelCode: Select all
set users [chanlist $chan] if {[set total [llength $users]] < 3} { puthelp "NOTICE $nick :We are the only ones here!" return 0 } set randomuser $nick while {$randomuser != $nick && ![isbotnick $randomuser]} { set randomuser [lindex $users [rand $total]] }
Code: Select all
bind pub - !random pub_random
proc pub_random {nick uhost hand chan t} {
if {$t == ""} {
set users [chanlist $chan]
if {[set total [llength $users]] < 3} {
puthelp "NOTICE $nick :We are the only ones here $nick!"
return 0
}
set randomuser $nick
while {$randomuser != $nick && ![isbotnick $randomuser]} {
set randomuser [lindex $users [rand $total]]
}
putserv "NOTICE $nick : Hi $nick, a random user is $randomuser"
}
}
Code: Select all
bind pub - !random pub_random
proc pub_random {nick uhost hand chan t} {
if {$t == ""} {
set users [chanlist $chan]
if {[set total [llength $users]] < 3} {
puthelp "NOTICE $nick :We are the only ones here $nick!"
return 0
}
set randomuser ""
while {$randomuser != $nick && ![isbotnick $randomuser]} {
set randomuser [lindex $users [rand $total]]
}
putserv "NOTICE $nick : Hi $nick, a random user is $randomuser"
}
}
Code: Select all
bind pub - !random pub_random
proc pub_random {nick uhost hand chan t} {
global botnick
if {$t == ""} {
set users [chanlist $chan]
set rembot [lsearch $users $botnick]
set mylist [lreplace $users $rembot $rembot]
set listlength [llength $users]
set myindex [rand $listlength]
set target [lindex $users $myindex]
if {[set total [llength $users]] < 3} {
puthelp "NOTICE $nick :We are the only ones here $nick!"
return 0
}
set randomuser $nick
while {$randomuser != $nick && ![isbotnick $randomuser]} {
set randomuser [lindex $users [rand $total]]
}
putserv "PRIVMSG $chan : Hi $nick, a random user is $target"
}
}
Excellent job. Witha little help and an effort on your part your problem was solved.chaokusc wrote:It still did not work, but i tried it a little different.
Here is what i came up with and it works.
Thanks for all the help ^^Code: Select all
bind pub - !random pub_random proc pub_random {nick uhost hand chan t} { global botnick if {$t == ""} { set users [chanlist $chan] set rembot [lsearch $users $botnick] set mylist [lreplace $users $rembot $rembot] set listlength [llength $users] set myindex [rand $listlength] set target [lindex $users $myindex] if {[set total [llength $users]] < 3} { puthelp "NOTICE $nick :We are the only ones here $nick!" return 0 } set randomuser $nick while {$randomuser != $nick && ![isbotnick $randomuser]} { set randomuser [lindex $users [rand $total]] } putserv "PRIVMSG $chan : Hi $nick, a random user is $target" } }