|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
In the following code, I make a few hash tables which need to be stored if the bot leaves the room for any reason, then have the information reloaded when the bot returns. After testing it out, and using another script to view the information in the hash tables, I find that the information isn't being reloaded when the bot returns...any suggestions? on *:start:{
strip +burc
hmake TD 50
if ($exists(TD.hsh)) { hload TD TD.hsh }
hmake bank 100
if ($exists(bank.hsh)) { hload bank bank.hsh }
hmake visits 50
if ($exists(visits.hsh)) { hload visits visits.hsh }
hmake seen 100
if ($exists(seen.dat)) { hload seen seen.dat }
hmake Truths 10
if $exists(Truths.hsh) { hload Truths Truths.hsh }
hmake Dares 10
if $exists(Dares.hsh) { hload Dares Dares.hsh }
}
on *:disconnect: {
hsave -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
ON *:EXIT: {
hasve -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
ON *:TEXT:*:#: {
hadd seen $nick text $chan $ctime $1-
if ($1 = !seen) { msg $nick $seenparse($2) }
}
ON *:ACTION:*:#: { hadd seen $nick act $chan $ctime $1- }
ON *:QUIT: {
hadd seen $nick quit $ctime $1-
hsave -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
on *:PART:#: {
hadd seen $nick part $chan $ctime $1-
.notice $nick Thank you for visiting # $+ .
hsave -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
ON *:NICK: {
hadd seen $nick nick $newnick $ctime
hadd -m visits $+(nicks.,$gettok($address($nick,5),2,33)) $addtok($hget(visits,$+(nicks.,$gettok($address($nick,5),2,33))),$newnick,32)
}
ON *:KICK:#: {
hadd seen $nick kicking $chan $ctime $knick $1-
hadd seen $knick kick $chan $ctime $nick $1-
hinc -m visits $+(kicked.,$gettok($address($nick,5),2,33))
hsave -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
The on start routine only trips when mirc starts up, so it well only ever be tripped once per session, you would need a ON !*:JOIN: for when it returns to the channel, although as you dont erase the hashtables anywhere i can see, they should still be present, so that might not be the problem I guess, couldnt hurt tho. Or maybe at least an ON *:CONNECT How about these two extra events in blue? PS: i put the hload and hsaves into alias's so the code didnt need to be repeated over and over, helps incase you add a new table, but its exactly the same code in them, well besides in the hload where i have to check if the table doesnt already exist before doing the hmake. [color:blue]on *:connect:{ td.hload }
on !*:join:#:{ td.hload }[/color]
on *:start:{ strip +burc | td.hload }
on *:disconnect: { td.hsave }
ON *:EXIT: { td.hsave }
ON *:TEXT:*:#: {
hadd seen $nick text $chan $ctime $1-
if ($1 = !seen) { msg $nick $seenparse($2) }
}
ON *:ACTION:*:#: { hadd seen $nick act $chan $ctime $1- }
ON *:QUIT: {
hadd seen $nick quit $ctime $1-
td.hsave
}
on *:PART:#: {
hadd seen $nick part $chan $ctime $1-
.notice $nick Thank you for visiting # $+ .
td.hsave
}
ON *:NICK: {
hadd seen $nick nick $newnick $ctime
hadd -m visits $+(nicks.,$gettok($address($nick,5),2,33)) $addtok($hget(visits,$+(nicks.,$gettok($address($nick,5),2,33))),$newnick,32)
}
ON *:KICK:#: {
hadd seen $nick kicking $chan $ctime $knick $1-
hadd seen $knick kick $chan $ctime $nick $1-
hinc -m visits $+(kicked.,$gettok($address($nick,5),2,33))
td.hsave
}
;
alias -l td.hload {
if !$hget(bank) { hmake bank 100 }
if !$hget(seen) { hmake seen 100 }
if !$hget(visits) { hmake visits 50 }
if !$hget(TD) { hmake TD 50 }
if !$hget(Truths) { hmake Truths 10 }
if !$hget(Dares) { hmake Dares 10 }
if ($exists(bank.hsh)) { hload bank bank.hsh }
if ($exists(seen.dat)) { hload seen seen.dat }
if ($exists(visits.hsh)) { hload visits visits.hsh }
if ($exists(TD.hsh)) { hload TD TD.hsh }
if ($exists(Truths.hsh)) { hload Truths Truths.hsh }
if ($exists(Dares.hsh)) { hload Dares Dares.hsh }
}
;
alias -l td.hsave {
hsave -o bank bank.hsh
hsave -o seen seen.dat
hsave -o visits visits.hsh
hsave -o TD TD.hsh
hsave -o Truths Truths.hsh
hsave -o Dares Dares.hsh
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Wouldn't the on !*:join:#:{ td.hload } activate whenever somebody, other than me (or in this case my bot) joined? Don't want the information in the hash tables to be overwritten everytime someone joins, just in case there's new information that hasn't been saved to the file yet.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Sorry your right, brains on a lag today, was thinking ! ment only myself, rather than anyone but myself.
what about...
on !*:join:#:{ } on *:join:#:{ td.hload }
lol, i wonder if thats faster than checing if $nick == $me , migth be you know.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
I already have an ON me:*:JOIN:# event in another script, which works quite well
Any reason that you can think of that I shouldn't or can't put the td.hload command in there?
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
none, just take the -l off the alias so it can be refrenced from the other script.
|
|
|
|
|