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.

problem with a variable

Old posts that have not been replied to for several years.
Locked
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

problem with a variable

Post by ranny »

Hello,

The first time that one user returns on a chan, the egg writes the number of people who are returns on this chan ==> it'ok. I will want that the second time that it returns the egg writes the number of people who came since her last visit.

If you could guide me,

Thanks
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

bind to JOIN, keeping track of joining users, i.e. increment a counter

also, save that counter, associated with joining user's nick; thus you'll be able to show the difference between current and saved counters (i.e. the number of users joined since then)
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

Hello,

I have this script

Code: Select all

if ![info exists countinside($nick)] {
set countinside($nick)  [expr $total] 
putserv "privmsg $channel :  $countinside($nick)"
return 0}
putserv "privmsg $channel : [expr $total - $countinside($nick)] news"
set countinside($nick) [expr $total] 
But the egg always writes $countinside($nick) ??

Thanks
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Because you always write it after the proc is done?

Code: Select all

#If the variable countinside($nick) does NOT exist, we create it.
if ![info exists countinside($nick)] {
set countinside($nick)  [expr $total]
putserv "privmsg $channel :  $countinside($nick)"
return 0
}
# This will pm the channel with something
putserv "privmsg $channel : [expr $total - $countinside($nick)] news"
# THEN you write it again, and that's why you write it anyway.
set countinside($nick) [expr $total]
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

Thanks all,

it's ok
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

It's ok,

but if the egg connection is stopped, it erases the data.
How to make to have this information same if the egg connection is stopped??

Thanks
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ranny wrote:It's ok,

but if the egg connection is stopped, it erases the data.
How to make to have this information same if the egg connection is stopped??

Thanks
dump it in a file, instead of using an array

Code: Select all

if {![catch {open mylogfile.txt a+} af]} {
  puts $af $variable
  close $af
}
or do both, and load it back into an array when you loading the bot..

Code: Select all

if {![catch {open mylogfile.txt r} rf]} {
  foreach {x} [split [read $rf] \n] {
    #here set the array
  }
  close $rf
}
XplaiN but think of me as stupid
Locked