This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

random generated nick script

Old posts that have not been replied to for several years.
Locked
M
MarlbMan
Voice
Posts: 20
Joined: Tue Apr 15, 2003 9:20 pm

random generated nick script

Post by MarlbMan »

I stole a bit out of the random password script to generate random nicks, here is what I've come up with.

Code: Select all

set sd_nlength "8"
bind pub - chnick sd_nchange
set sd_char {A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z}
proc sd_nchange { sd_nlength } {
global sd_char
set counter 0
set sd_rnick ""
while {$counter < $sd_nlength } {
set sd_rand [lindex $sd_char [rand [llength $sd_char]]]
set sd_rnick "$sd_nick$sd_rand"
incr counter
}
putserv "nick $sd_rnick"
}

but when I type chnick in channel, I get the following error:

Code: Select all

Tcl error [sd_nchange]: wrong # args: should be "sd_nchange sd_nlength"
can anyone help me?
M
MarlbMan
Voice
Posts: 20
Joined: Tue Apr 15, 2003 9:20 pm

Post by MarlbMan »

ok, got that figured out. Changed the script a bit, now it looks like this.

Code: Select all

bind pub - chnick sd_nchange
set sd_char {A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z}
proc sd_nchange { nick uhost hand chan arg } {
global sd_char
set counter 0
set sd_rnick ""
while {$counter < 8 } {
set sd_rand [lindex $sd_char [rand [llength $sd_char]]]
set sd_rnick "$sd_rnick$sd_rand"
incr counter
}
putserv "nick $sd_rnick"
}
Problem now is, it changes it's nick back. I change set keep-nick to 0, but it still does it. how do I fix this one?
M
MarlbMan
Voice
Posts: 20
Joined: Tue Apr 15, 2003 9:20 pm

Post by MarlbMan »

I love it when I answer my own question, I just added sd_rnick to the global line and it works fine now.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I'd suggest addin "counter" to the global line too, if its being used in another proc of this script.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Sir_Fz wrote:I'd suggest addin "counter" to the global line too, if its being used in another proc of this script.
The counter variable has no value outside the proc as it'll always contain "8" when the proc returns.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

oh yes, you're right :) I understoud.
Locked