mIRC Home    About    Download    Register    News    Help

Print Thread
IRC Stats #167099 20/12/06 12:01 AM
Joined: Apr 2006
Posts: 8
M
MisterMage Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Apr 2006
Posts: 8
Code:
;------------------------------------------------------- 
; IRC Stats - Made by `Mistermage` of #mister 
;------------------------------------------------------- 
; Credit to AlternativeNick for all his help 
;------------------------------------------------------- 


on $*:TEXT:/^[!@>]ircstats */Si:#: {
  var %send $iif($left($1-,1) == @,notice $nick,.notice $nick)
  if ($2 == $null) {  
    %send 14Your stats for [4 $+ $chan $+ 14]:
    %send 14Total number of lines:4 $hget(lines $+ $chan ,$nick)
    %send 14Total number of words:4 $hget(words $+ $chan ,$nick)
    %send 14Total number of letters:4 $hget(letters $+ $chan ,$nick)
    %send 14Times Kicked:4 $iif($hget($+(kicks,$chan), $nick),$hget($+(kicks,$chan), $nick),0)
    %send 14Total People Kicked:4 $iif($hget($+(kickcount,$chan), $nick),$hget($+(kickcount,$chan), $nick),0)
  }
  elseif ($2 !== $null) {
    %send $c2($2) $+ 14's stats for [4 $+ $chan $+ 14]:
    %send 14Total number of lines:4 $hget(lines $+ $chan , $2)
    %send 14Total number of words:4 $hget(words $+ $chan , $2)
    %send 14Total number of letters:4 $hget(letters $+ $chan , $2)
    %send 14Times Kicked:4 $iif($hget($+(kicks,$chan), $2),$hget($+(kicks,$chan), $2),0)
    %send 14Total People Kicked:4 $iif($hget($+(kickcount,$chan), $2),$hget($+(kickcount,$chan), $2),0)
  }

}
on *:TEXT:*:#: { 
  hinc lines $+ $chan $nick 1 
  hinc words $+ $chan $nick $numtok($1-,32) 
  hinc letters $+ $chan $nick $len($1-) 
}
on *:KICK:#: {
  hinc kicks $+ $chan $knick 1
}
on *:JOIN:#: {
  if ($nick == $me) {
    hmake words $+ $chan 1000
    hmake letters $+ $chan 1000
    hmake lines $+ $chan 1000
    hmake kicks $+ $chan 1000
    hmake kickcount $+ $chan 1000
  }
}
on *:TEXT:!k*:#: {
  if (($nick isop $chan) || ($nick ishop $chan)) {
    hinc kickcount $+ $chan $nick 1
  }
}
on *:TEXT:!kb*:#: {
  if (($nick isop $chan) || ($nick ishop $chan)) {
    hinc kickcount $+ $chan $nick 1
  }
}


Anyway I can make it better + should i fix it up at all?

Re: IRC Stats [Re: MisterMage] #167100 20/12/06 12:33 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
A few things I would suggest...

1) Your kick counter (for the person doing the kicking) only tracks the kicks if !k or !kb is used and not if the person does it another way (/kick /ban etc). Why not just put it all into the on KICK event? Increase the number of kicks for $knick and also for $nick at the same time.

2) I don't see anything loading or saving the hash tables. Hash tables are stored in memory and if you close mIRC, they will be erased.

3) Why so many hash tables? My own channel's stats script, that I just rewrote a couple of days ago, uses 2 hash tables and tracks even more. It could use one, but I have a top 10 lines display and to easily sort that, I just put the lines into its own hash table. Anyhow, I have it set up like this:

#chan_stats
- $nick.kicks (total kicks to the nick)
- $nick.smiles (total smiles - using a ton of smile triggers)
- $nick.frowns (total frowns - using a ton of frown triggers)
- $nick.laughs (total laughs - using a ton of laugh triggers)
- $nick.quote (random quote)
- $nick.days (days since nick first joined, though I will probably change that to $ctime of first join)
- Lines (total channel lines)
- Smiles (total channel smiles)
- Frowns (total channel frowns)
- Laughs (total channel laughs)
#chan_stats_lines
- $nick (total lines for the nick)

If I wasn't doing a top 10 for the lines, I'd just have 1 for the channel and the lines would be $nick.lines .

It won't hurt anything to have that many hash tables, but it is easier, imo, to work with only 1 if possible.

You may also want to have your stats insert commas... $bytes(number,b) . I actually have some identifiers I made that return $bytes($hget(#chan $+ _stats,$nick $+ .smiles),b) (or other stats) so that I can just use a short identifier whenever I need the stats instead of typing that whole thing out every time.

Another thing... everyone sees the Total People Kicked stat. If the person never kicked anyone (usually because he/she isn't an op), why display anything there?

Code:
$iif($hget($+(kickcount,$chan), $nick),%send 14Total People Kicked:4 $v1)



That will only display that line if there were kicks to display.

I'd also set up your times kicked display as:
Code:
%send 14Times Kicked:4 $iif($hget($+(kicks,$chan), $nick),$v1,0)



Notice the use of $v1. It'll save space for you.

Another thing is the on JOIN > hmake idea. What if you part then rejoin? You'll get an error that the tables are already made. Check for them...
Code:
if (!$hget(table)) { run hmake/hload stuff }


Another thing is the letters stat. Do you really want to count control codes and spaces as letters? If not, use:

Code:
hinc letters $+ $chan $nick $len($remove($strip($1-),$chr(32))


Yet another one... your !k* prevents !kb* from running because you already ran !k* which includes !kb*. Of course, if you do what I said for the on KICK event, you don't even need these.

Finally, if you only want to increase something by one (such as lines), you don't need to put 1 there. Without a value included in inc or hinc, it increases automatically by 1.

That's what I see right now. I hope it helps.


Invision Support
#Invision on irc.irchighway.net