mIRC Home    About    Download    Register    News    Help

Print Thread
#157085 22/08/06 12:01 AM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Hi
I am very unexperinced in mIRC but i spent some time putting together a CHANNEL seen script, So far its working fine, I just would like some comments and pointers to improve the script, i dont want anything fancy, just maybe make the code cleaner and some ideas are pointers forward, Thanks.

i didnt make the script silent by putting . before the commands as i wanted to see what it did for debugging purposes.

on *:start:{

if !$hget(seen) { hmake -s seen 100 }

if $exists(seen.hsh) { hload -s seen seen.hsh }

}

on *:JOIN:#: {
if (!$notify($nick)) {
notify $nick
if $hget(seen,$nick) {
hdel -sm seen $nick
}
}
}


on *:UNOTIFY: {
hadd -so seen $nick $day $date $time
notify -r $nick
}

on *^:TEXT:!seen*:#: {
if ($2 ison $chan) && ($2 != $nick) && ($2 != $me) {
msg $chan $2 is on $chan
}
elseif ($2 == $nick) {
msg $chan Hello $nick i found you.
.ignore -u7 $nick
}
elseif ($2 == $me) {
kick $chan $nick am here...
}
elseif !$hget(seen,$2) {
msg $chan i dont have any information on $2
.ignore -u7 $nick
}
else {
if $hget(seen,$2) {
msg $chan $2 was last seen $hget(seen,$2) GMT time
.ignore -u7 $nick
}
}
}

on *:exit: {

.hsave -o seen seen.hsh

}

on *:disconnect: {

.hsave -o seen seen.hsh

}


Newbie
#157086 22/08/06 12:25 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The -o switch in your hadd command is invalid.
The way /hadd works it will overwrite the current information if it exists.
I'd recommend using
Code:
 on @*^:TEXT:!seen*:#: { 
so that there's no possibility of a server error if you try to kick someone with
Code:
  elseif ($2 == $me) {
    kick $chan $nick am here...
  } 
and you not having ops in the channel.

I realize you'll probably ensure that you do have ops in the channel, so this is more of a safety than anything else.

As a basic !seen script, my compliments. If you want to take a look at some others that are more complex, you can find some on Hawkee , mIRC Scripts and possbily other sites that you can get to from links on those.

#157087 22/08/06 12:47 AM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Ok thanks that means alot. laugh
Is it possible to make it reply instead of the date and time how many weeks/days/mins ago the user wast last seen, i tried stuff myself but its a little complicated. Any pointers in which direction i should follow in order to achive that?
thanks


Newbie
#157088 22/08/06 05:21 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
add another item in the table with the value of $ctime:

hadd seen $nick $day $date $time $ctime

Then when you're querying the user, take the ctime, subtract t from the current $ctime (that gets the delta value), and use $duration. i.e.:

Code:
 if $hget(seen,$2) {
  var %ctime = $gettok($v1,-1,32), %last_seen = $remove($v1,%ctime)
  msg $chan $2 was last seen %last_seen GMT time ( $+ $duration($calc($ctime - %ctime)) ago)
.  ignore -u7 $nick
} 


-KingTomato
#157089 23/08/06 12:09 AM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Thanks so much, i have amended the code following the suggestions, thanks again.


Newbie

Link Copied to Clipboard