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.

Help with code adjustements

Old posts that have not been replied to for several years.
Locked
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

Hi guys,

Can anyone convert this code to make it work even if my eggdrop is op on many channels.
The code works fine now because my eggie is op on just 1 channel, but I want to op it on many. If I use the current code and the same nick join 2 different channels, it will trigger a ban which is wrong.

Here's the code:
set nickjoinlast ""
set nickjointimes 0
set nickjoinsafe 0

bind join - * nickjoin

proc nickjoin {nick uhost hand chan} {
global nickjoinlast nickjointimes nickjoinsafe


if {$nickjoinlast != ""} {
if {"$nickjoinlast" == "$nick"} {
if {$nickjointimes >= 3} {
if {$nickjoinsafe == 0} {
putquick "MODE $chan +b $nick!*@*" -next
set nickjoinsafe 1
utimer 20 {set nickjoinsafe 0}
}
} else {
set nickjointimes [expr $nickjointimes + 1]
}
} else {
set nickjoinlast $nick
if ([info exists mynickjointimer]) { killutimer $mynickjointimer }
set mynickjointimer [utimer 10 {set nickjoinlast ""}]
set nickjointimes 1
}
} else {
set nickjoinlast $nick
if ([info exists mynickjointimer]) { killutimer $mynickjointimer }
set mynickjointimer [utimer 10 {set nickjoinlast ""}]
}

}
<font size=-1>[ This Message was edited by: z_one on 2002-02-19 06:38 ]</font>
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

Can anyone help guys. I really and urgently need this code to work when the eggdrop is op on multiple channels (I tried using arrays for variable and timer names to make them channel specific, didn't work).

Slennox, Egghead, Petersen, Ppslim or anyone else out there ?

Thanks in advance
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

yes, arrays and channel specific timers are the way
set nickjoinlast() ""
set nickjointimes() ""
set nickjoinsafe() ""

bind join - * nickjoin

proc nickjoin {nick uhost hand chan} {
global nickjoinlast nickjointimes nickjoinsafe mynickjointimer

if {![info exists nickjointimes($chan)} {
set nickjointimes($chan) 0
}

if {![info exists nickjoinsafe($chan)} {
set nickjoinsafe($chan) 0
}



if {$nickjoinlast($chan) != ""} {
if {"$nickjoinlast($chan)" == "$nick"} {
if {$nickjointimes($chan) >= 3} {
if {$nickjoinsafe($chan) == 0} {
putquick "MODE $chan +b $nick!*@*" -next
set nickjoinsafe($chan) 1
utimer 20 {set nickjoinsafe($chan) 0}
}
} else {
set nickjointimes($chan) [expr $nickjointimes($chan) + 1]
}
} else {
set nickjoinlast($chan) $nick
if ([info exists mynickjointimer($chan)]) { killutimer $mynickjointimer($chan) }
set mynickjointimer($chan) [utimer 10 {set nickjoinlast($chan) ""}]
set nickjointimes($chan) 1
}
} else {
set nickjoinlast($chan) $nick
if ([info exists mynickjointimer($chan)]) { killutimer $mynickjointimer($chan) }
set mynickjointimer($chan) [utimer 10 {set nickjoinlast($chan) ""}]
}

}
note that this is a direct port - i made no effort to fix some of the crap code (except I declared mynickjointimer globally as it should have been)

[edit]
typo fix
[/edit]

<font size=-1>[ This Message was edited by: Petersen on 2002-02-21 09:53 ]</font>
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

Thx dude I owe u one. By the way, in the code u added, there's a missing closing bracket within the if statement in the line (and others like it):
if {![info exists nickjointimes($chan)} {
set nickjointimes($chan) 0
}
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

thats what i get for coding when drunk with no testing :razz:
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

lol well I hope you're not drunk this time :smile:

I declared myipjointimer as a global variable.
and I even tried to compile with (and without) the following line.
if {![info exists myipjointimer($chan)]} {set myipjointimer($chan) ""}

I get an error in both cases (with and without it) when it gets to the line
if {[info exists myipjointimer($chan)]} { killutimer $myipjointimer($chan) }
set myipjointimer($chan) [utimer 10 {set ipjoinlast($chan) ""}]
I get the following error msg:
Invalid TimerID

Any ideas why ? and how to make channel specific timers work ?
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

gonna need some unset lines

eg

set myipjointimer($chan) [utimer 10 {set ipjoinlast($chan) "" ; unset myipjointimer($chan) }]
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

why would I wanna unset the timerID. I need to keep track of it to kill it later on
"killutimer $myipjointimer($chan)" before starting a new one. Otherwise, I'll end up having so many timers if I don't stop the current one before starting a new one. right ?
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

you need to unset it when the timer runs. once the timer has run, the value in that var is now an invalid timer id (as the timer doesnt exist anymore)
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

I got your point. But even when I unset the timer as u proposed, I am still getting the msg "Invalid Timer ID"

All I want to do is:

1- Check if a channel specific timer exists - say it's called mytimer(#mychan)

2- If it doesn't exist then simply set it for 10 seconds to perform an action.

3- If it exists, kill it first then set it again for another 10 seconds. The reason I wanna kill it is because I don't wanna set the timer with a diff. ID everytime someone joins ... if there's a fast flood it will probably make the bot crash.
I just wanna kill the timer and set it again with the SAME ID for a specific channel.


<font size=-1>[ This Message was edited by: z_one on 2002-02-25 01:40 ]</font>
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

I adjusted the code. Thanks for ur help Petersen and sorry for asking too many questions.
I used "foreach timr [utimers]" to check for timer existance on "[lindex $timr 2]" and kill it.

z_one
Locked