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.

Don't understand -_-

Old posts that have not been replied to for several years.
Locked
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Don't understand -_-

Post by metroid »

Code: Select all

set users {
[screw]mjuertah
dot2|Zekk
jykh330
lgur641
}

bind pub - !moo pub:moo

proc pub:moo {nick uhost hand chan text} { 
                global users
	putquick "NOTICE $text :Blah blah $users"
	putquick "NOTICE $text :mooo"
	}
What i want this code to do is pm the person said in text (yes its a crappy code but i made it fast) but the thing is it won't say users while i think i did it right? I should do one of those randomly?
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

You have to read the users one by one using foreach, and you mixed up $text and $user in the notice..

Try this

Code: Select all

set users {
[screw]mjuertah
dot2|Zekk
jykh330
lgur641
}

bind pub - !moo pub:moo

proc pub:moo {nick uhost hand chan text} {
global users
 foreach user $users {
   putquick "NOTICE $user :blah blah $text"
   putquick "NOTICE $user :mooo"
 }
}
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

nono, i didnt mix it up, i wanted the bot to pm $text not the user :>
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

hmm, the script doesn't work as i planned it to do so,

I wanted the script to pick a random name from the set users part and use it once, what the script does now is use all nicks

so now im getting:

Code: Select all

<bot> blah blah <name>
<bot> mooo

<bot> blah blah <name2>
<bot> mooo

<bot> blah blah <name3>
<bot> mooo

<bot> blah blah <name4>
<bot> mooo
when i want it to do:

Code: Select all

<bot> blah blah <random name from list>
<bot> mooo
Only 1 name, not all of them :>
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

ok, instead of the foreach, pick a random user with something like this

Code: Select all

set user [lindex $users [rand [llength $users]]]
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Ah, It works like a charm now :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yeah, I think he wanted them to be displayed as a list. Rather than using foreach and displaying each defined nick seperately.

By the way, for this specific nick in your nicklist:

Code: Select all

[screw]mjuertah
You might want to try and escape it with the "\" character, so it doesn't make the procedure choke on special characters, which would be:

Code: Select all

\[screw\]mjuertah
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

And what was the meaning with that post awyeah.

The problem was already solved and everyone is happy, so there is no need for you to be stating the obvious like you've been doing on most threads on this forum lately.

It's unnecessary and kinda annoying.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

There is alot of newcomers to tcl reading these forums aswell as the more experienced, so there is nothing unnessesary in stating the obvious from time to time.
Yes. They could and should use the search button before posting to see if their question has already been answered.. but by reading other posts you get the kind of information you might not need at the present, but most likely will need in the future.
Hell.. I've learned ALOT that way ;)

If there is one thing people should learn, it is to be careful with the "special characters" in tcl.
Elen sila lúmenn' omentielvo
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

dollar, here sometimes just gets too frustrated, heh :mrgreen:

Maybe dollar helped him, but he might have a problem with those ] and [ chars, so I tried to help him, by letting him know... that they might cause a problem. Not at the first time, because the random one selected might not be the one with the ]'s or ['s but once its selected, it will choke and an error will occur. ;)

This doesn't mean we only need to correct the thing the person asked for, we can correct the things, also which we can see.. can cause trouble later onwards.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

nvm
XplaiN but think of me as stupid
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Naw, the script works fine and doesnt seem to choke on the brackets
Locked