mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Hello, I have a complicated seen script, and I just have a problem, so I'm only showing edited parts of it for easy understanding.

Code:
on *:text:*:*: { 
    write -w" [ $nick ] $+ :*" seen.txt $nick $+ : $+ [ $ctime ] $+ : $+ [ $chan ] $+ :saying " $+ [ $1- ] $+ "
}


Code:
alias seen {
  var %temp, %chan, %nick
  %nick = $1
  %chan = $2
  %seennick = $3
  %temp = $read(seen.txt,w,%seennick $+ :* )
  if (%temp) {
    tokenize 58 %temp
    if ($1 == %nick) { 
      /msg %chan %nick $+ : there you are!
    }
    else { 
    /msg %chan %nick $+ : I last saw $+ $1 $+ in $+ $3 $+ $duration($calc($ctime - $2)) ago, $4- }
  }
  else { 
    /msg %chan %nick $+ : I've never seen $+ %seennick $+ in $+ $2 $+ before. }
  }
}


So let's say I someone says 'word 1' then the seen would return, 'word 1' Then let's say someone says 'word 2' etc.

But how do I get it to return the second or third last line?

In seen.txt, it will look like:


Neal:1124335052:#channel1:saying "word 2"
Neal:1119168890:#channel1:saying "word 1"

Notice the ctime, it is not in chronological order.

So the problem with this is:

%temp = $read(seen.txt,w,%seennick $+ :* )

I have tried

%temp = $read(seen.txt,w,%seennick $+ :*, $calc($readn +1) )

And

%temp = $read(seen.txt,w,%seennick $+ :*, $calc($readn -1) )

So, how would I return the second last line, and, how do I /write this in chronological order?

Thanks.

Joined: Aug 2005
Posts: 128
S
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
Quote:
Hello, I have a complicated seen script, and I just have a problem, so I'm only showing edited parts of it for easy understanding.

Code:
on *:text:*:*: { 
    write -w" [ $nick ] $+ :*" seen.txt $nick $+ : $+ [ $ctime ] $+ : $+ [ $chan ] $+ :saying " $+ [ $1- ] $+ "
}


Code:
alias seen {
  var %temp, %chan, %nick
  %nick = $1
  %chan = $2
  %seennick = $3
  %temp = $read(seen.txt,w,%seennick $+ :* )
  if (%temp) {
    tokenize 58 %temp
    if ($1 == %nick) { 
      /msg %chan %nick $+ : there you are!
    }
    else { 
    /msg %chan %nick $+ : I last saw $+ $1 $+ in $+ $3 $+ $duration($calc($ctime - $2)) ago, $4- }
  }
  else { 
    /msg %chan %nick $+ : I've never seen $+ %seennick $+ in $+ $2 $+ before. }
  }
}


So let's say I someone says 'word 1' then the seen would return, 'word 1' Then let's say someone says 'word 2' etc.

But how do I get it to return the second or third last line?

In seen.txt, it will look like:


Neal:1124335052:#channel1:saying "word 2"
Neal:1119168890:#channel1:saying "word 1"

Notice the ctime, it is not in chronological order.

So the problem with this is:

%temp = $read(seen.txt,w,%seennick $+ :* )

I have tried

%temp = $read(seen.txt,w,%seennick $+ :*, $calc($readn +1) )

And

%temp = $read(seen.txt,w,%seennick $+ :*, $calc($readn -1) )

So, how would I return the second last line, and, how do I /write this in chronological order?

Thanks.

For writing in chronological order you have to use /filter:
Code:
filter -fftu 2 58 seen.txt seen2.txt
if ($exists(seen2.txt)) {
.remove seen.txt
.copy seen2.txt seen.txt
.remove seen2.txt
}

Also there is one more bug, which exists in most scripts that are using the $read() or $readini().
Quote:

If the n switch is specified then the line read in will not be evaluated and will be treated as plain text.

If you don't use this switch at read, the read line will be evaluated. And if i type on channel:
a $findfile(.,*,1,quit) b
!seen stefys
will make the bot quit smile

Joined: Aug 2005
Posts: 1
C
Mostly harmless
Offline
Mostly harmless
C
Joined: Aug 2005
Posts: 1
it can be this way

Code:

;Coded by goXXip
;$_find($1,1) = nick, $_find($1,2) = time, $_find($1,3) == date
alias _find return $gettok($hget(seen. $+ $server,$hfind(seen. $+ $server,$+(*,$1,*),1,w).data),$2,46)
on *:JOIN:#: {
  if !$findfile($mircdir,$+(seen.,$server,.data),1) { 
    hmake seen. $+ $server 50
    hsave seen. $+ $server $+(seen.,$server,.data) 
  }
  elseif !$hget(seen. $+ $server) { hmake seen. $+ $server | hload seen. $+ $server $+(seen.,$server,.data) } 

  if $_find($nick,1) { hdel seen. $+ $server $hfind(seen. $+ $server,$+(*,$1,*),1,w).data }

  hadd seen. $+ $server $r(0,99999999) $+($nick,$chr(46),$time,$chr(46),$date)
  hsave seen. $+ $server $+(seen.,$server,.data)
  
}

alias seen {
  if $server {
    if $1 {
      if $1 == clear {
        hdel -w seen. $+ $server *
        echo -a Cleared
        hsave seen. $+ $server $+(seen.,$server,.data)
      }
      elseif $1 == list {
        var %s = 1,%nick,%time,%date
        while %s <= $hget(seen. $+ $server,0).item {
          %nick = $gettok($hget(seen. $+ $server,%s).data,1,46)
          %time = $gettok($hget(seen. $+ $server,%s).data,2,46)
          %date = $gettok($hget(seen. $+ $server,%s).data,3,46)
          echo -a %s Nick: %nick Time: %time Date: %date
          inc %s
        }
      }
      elseif $_find($1,1) {
        echo -a $_find($1,1) $+ , Last Seen $_find($1,3) in Date Saat $_find($1,2) in Clock 
      }
      else echo -a $1 $+ ,  none in my list
    }
  }
  else echo -a Not Connected
}  


You can edit this code smile Sorry My English very Bad smile

Last edited by Cagri; 20/08/05 02:36 PM.

Link Copied to Clipboard