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.

Join script.

Old posts that have not been replied to for several years.
Locked
t
typefighter

Join script.

Post by typefighter »

Hi peeps.

I'm quite new to tcl still and I was wondering if anyone could help me out with this problem.

I want my bot to say Hi or Hello or whatever to anyone who joins a channel, which I have managed to do, but I don't want it to happen EVERY time someone joins, maybe 1:5 ratio. Is there a simple way of doing this ? Here's the script I have made ...

Thanks in advance

- type.

=====================


bind join - * randgreet

proc randgreet {nick host hand channel args} {
global library
puthelp "PRIVMSG $channel :\002$nick\002: [lindex $library [rand
[llength $library]]]" <--- all one line
}

set library {
"Hi"
"Hello"
"You seen my glasses ?"
}

EOF
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

somthing like

Code: Select all

if {![rand 5]} { return }
will work

This should be placed as the firsty line, and before the data is sent.
t
typefighter

Post by typefighter »

ppslim: thanks :o)

could you please tell me why that works too ? I understand the "rand 5" part, but I can't work out why it works.

- type
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

What it says is if (random number from 0 to 5) is zero then..

If !(a) will be triggered if a is FALSE i.e. 0 (! = NOT - check boolean algebra)

Therefore you have a 1 in 6 chance of if being true.

HTH
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The if command works on boolien values. IE, smthing is TRUE or FALSE, 1 or 0, it matches or it doesn't match.

In th 1 or 0 version, it can be extended further, by saying 0 = FALSE and any other value is TRUE.

The rand command (supplied by eggdrop) produces a random value, of 0 upto LIMIT-1.

Thus, giving it a value of 5, can give the values 0, 1, 2, 3, 4. This can be represented in boolien as F, T, T, T, T (first letters of false and true)

Aplying these together, you have a 4 in 5 chance of it being true, and 1 in 5 of false.

This is obviously the reverse to what you want.

In the matching system for IF, you also have a negate symbol (!). This will convert TRUE to FALSE, and FLASE to TRUE.

Thus, the boolien pattern above for the random value becomes T, F, F, F, F. IE, reversing the odds.

This rather techy way of saying it, but i'm sure you will get the idea.
t
typefighter

Post by typefighter »

Ok thanks guys :) Much MUCH appreciated. I get it now. Thankyou :)
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

LMAO :D

Remind me in future to let Slim do the explaining....
Locked