All the Ping and Ping Reply scripts I have seen use $ctime so thought to try be more accurate let's use $ticks instead. Have tested quite a few times and find this pretty accurate down to 1/1000th of a second.
Can ping one person at a time or ping all people in channel.
Best used in another copy of mIRC i.e a bot
Usage:
!phelp - Displays Ping commands.
!ping - Pings the nick that used !ping and displays result in channel.
!mping - Pings every nick in channel and displays result in channel. (Do not abuse)
!rping - Retrieves your own ping record when used as !rping or !rping nickname retrieves nickname you specified.
!wping - Retrieves your own worst ping record when used as !wping or !wping nickname retrieves nickname you specified.
!aping - Retrieves your own mean ping average when used as !aping or !aping nickname retrieves nickname you specified.
!top10 - Displays Top 10 Pings Recorded.
Note: After 120 seconds (2mins) with no ping reply variables will unset
!ping has flood control for 3 seconds
!mping has flood control for 5 seconds
All other commands have flood control for 3 seconds
Installation:
Copy below snippet, Alt + R, File > New, Paste, save As.. whatever.mrc
EDIT:
Edit to your hearts desire and personal preference.
Ratings, comments and suggestions are welcome.
on *:LOAD: {
echo -a Ping Tick v2.1 by Kasbah 2008 Loaded.
echo -a Commands: !phelp, !ping, !mping, !rping, !wping, !aping, !top10 or use the popup Menu via Commands, Channel and Status.
}
on *:UNLOAD: {
var %s $hget(0)
var %ss 1
while (%ss <= %s) { hsave $hget(%ss) $hget(%ss) $+ .hsh | write -c backup.txt $hget(%ss) | hfree -s $hget(%ss) | inc %ss 1 }
echo -a Ping Tick v2.1 by Kasbah 2008 unloaded.
echo -a Hash tables removed but backed-up to backup.txt, Record.txt containing ping records remain.
}
on *:START: {
var %s $lines(backup.txt)
var %ss 1
while (%ss <= %s) {
var %nick $read(backup.txt, %ss)
if !$hget(%nick) { .hmake %nick 100 }
if $exists(%nick $+ .hsh) { hload $read(backup.txt, %ss) %nick $+ .hsh }
inc %ss 1
}
}
on *:QUIT: {
if ($nick == $me ) {
var %s $hget(0)
var %ss 1
while (%ss <= %s) { hsave $hget(%ss) $hget(%ss) $+ .hsh | write -c backup.txt $hget(%ss) | inc %ss 1 }
}
}
on *:EXIT: {
var %s $hget(0)
var %ss 1
while (%ss <= %s) { hsave $hget(%ss) $hget(%ss) $+ .hsh | write -c backup.txt $hget(%ss) | inc %ss 1 }
}
on *:DISCONNECT: {
var %s $hget(0)
var %ss 1
while (%ss <= %s) { hsave $hget(%ss) $hget(%ss) $+ .hsh | write -c backup.txt $hget(%ss) | inc %ss 1 }
}
menu menubar,channel {
-
Ping Tick V2.1 by Kasbah
.Mass Ping Channel:$Mping
.Ping Records
..Top10:$Top10
..Best by Nick:set -u10 %getnick $?="Enter Nickname?" | $Rpingbest
..Worst by Nick:set -u10 %getnick $?="Enter Nickname?" | $Rpingworst
..Mean Ping Average by Nick:set -u10 %getnick $?="Enter Nickname?" | $Rpingmedium
.Display Help:msg $active $Phelp
.Advertise:msg $active Ping Tick Version 2.1 By Kasbah 2008 Get it: http://www.hawkee.com/snippet/5411/
.About:msg $active Ping Tick Version 2.1 By Kasbah 2008 using System ticks for accuracy.
}
alias Mping {
var %p $nick(#,0)
var %pp 1
while (%pp <= %p) { var %nick $nick(#,%pp) | if (!$hget(%nick)) { var %nick $nick(#,%pp) | hadd -m %nick record 20 | hadd %nick worst 0.1 } | hadd -u120 %nick pnick %nick | hadd -u120 %nick pchan $chan | hadd -u120 %nick pping $ticks | ctcp $nick(#,%pp) ping | inc %pp 1 }
}
alias Top10 {
var %file = Records.txt, %l = 10, %d = $lines(%file), %w = @top10
window -hn %w
clear %w
while %d {
tokenize 32 $read(%file,nt,%d)
aline %w $2 $1 $+ secs $+ : $duration($calc($ctime - $3),2) ago
dec %d
}
filter -ctuww 2 32 %w %w
var %k = 1, %k1
while %k <= %l {
%k1 = $addtok(%k1,$+($chr(32),12,$chr(35),%k,) $iif($line(%w,%k),$v1,N/A),44)
inc %k
}
msg $chan Top 10 Ping Times:
msg $chan %k1 $+ .
}
alias Rpingbest {
if (!$hget(%getnick)) { msg $chan I have no record of %getnick | halt }
if ($hget(%getnick,record) == 20) { msg $chan I have no best ping reply for %getnick yet lol, problems aye ;) | halt }
if ($hget(%getnick,record)) { msg $chan %getnick $+ 's Ping Record is $hget(%getnick,record) seconds. }
}
alias Rpingworst {
if (!$hget(%getnick)) { msg $chan I have no record of %getnick | halt }
if ($hget(%getnick,worst) == 0.1) { msg $chan I have no worst ping reply for %getnick yet lol, problems aye ;) | halt }
if ($hget(%getnick,worst)) { msg $chan %getnick $+ 's Ping Record is $hget(%getnick,worst) seconds. }
}
alias KaiPing { return Ping Tick v2.1 by Kasbah 2008 }
alias Rpingmedium {
if (!$hget(%getnick)) { msg $chan I have no record of %getnick | halt }
if ($hget(%getnick,worst) == 0.1) || ($hget(%getnick,record) == 20) { msg $chan I cannot calculate %getnick $+ 's Mean Average due to insufficient data | halt }
var %high $hget(%getnick,record)
var %low $hget(%getnick,worst)
msg $chan %getnick $+ 's High-Low Ping Medium is $calc( (%high + %low) / 2)
}
alias Phelp {
if ($hget($nick,help) == yes) { halt }
hadd -u3 $nick help yes
.notice $nick $KaiPing
.notice $nick Commands: !ping, !mping, !rping, !wping, !aping, !top10 or use the popup Menu via Commands, Channel and Status.
}
on *:TEXT:!Phelp*:#: {
if ($hget($nick,help) == yes) { halt }
hadd -u3 $nick help yes
.notice $nick $KaiPing
.notice $nick Commands: !ping, !mping, !rping, !wping, !aping, !top10 or use the popup Menu via Commands, Channel and Status.
}
on *:TEXT:!top10*:#: {
if ($hget($nick,top) == yes) { halt }
hadd -u3 $nick top yes
var %file = Records.txt, %l = 10, %d = $lines(%file), %w = @top10
window -hn %w
clear %w
while %d {
tokenize 32 $read(%file,nt,%d)
aline %w $2 $1 $+ secs $+ : $duration($calc($ctime - $3),2) ago
dec %d
}
filter -ctuww 2 32 %w %w
var %k = 1, %k1
while %k <= %l {
%k1 = $addtok(%k1,$+($chr(32),12,$chr(35),%k,) $iif($line(%w,%k),$v1,N/A),44)
inc %k
}
msg $chan Top 10 Ping Times:
msg $chan %k1 $+ .
}
on *:TEXT:!ping*:#: {
if ($hget($nick,pinged) == yes) { halt }
if ($hget($nick)) { hadd -u3 $nick pinged yes | hadd -u120 $nick pnick $nick | hadd -u120 $nick pchan $chan | hadd -u120 $nick pping $ticks | ctcp $nick ping }
else { hadd -m $nick record 20 | hadd $nick worst 0.1 | hadd -u3 $nick pinged yes | hadd -u120 $nick pnick $nick | hadd -u120 $nick pchan $chan | hadd -u120 $nick pping $ticks | ctcp $nick ping }
}
on *:TEXT:!mping*:#: {
if ($hget($nick,mpinged) == yes) { halt }
hadd -mu5 $nick mpinged yes
var %p $nick(#,0)
var %pp 1
while (%pp <= %p) { var %nick $nick(#,%pp) | if (!$hget(%nick)) { hadd -m %nick record 20 | hadd $nick worst 0.1 } | hadd -u120 %nick pnick %nick | hadd -u120 %nick pchan $chan | hadd -u120 %nick pping $ticks | ctcp $nick(#,%pp) ping | inc %pp 1 }
}
on *:TEXT:!rping*:#: {
if ($hget($nick,flood) == yes) { halt }
hadd -u3 $nick flood yes
if (!$2) {
if ($hget($nick,record) == 20) { msg $chan I have no ping reply from you yet $nick lol, problems aye ;) | halt }
if ($hget($nick,record)) { msg $chan $nick $+ , Your Ping Record is $hget($nick,record) seconds. }
else { msg $chan I have no ping record for you $nick $+ . }
}
else {
if ($hget($2,record) == 20) { msg $chan I have no ping reply from $2 yet lol, problems aye ;) | halt }
if ($hget($2,record)) { msg $chan $nick $+ , $2 $+ 's Ping Record is $hget($2,record) seconds. }
else { msg $chan I have no ping record for $2 $+ . }
}
}
on *:TEXT:!wping*:#: {
if ($hget($nick,flood) == yes) { halt }
hadd -u3 $nick flood yes
if (!$2) {
if ($hget($nick,worst) == 0.1) { msg $chan I have no ping reply from you yet $nick lol, problems aye ;) | halt }
if ($hget($nick,worst)) { msg $chan $nick $+ , Your Worst Ping Record is $hget($nick,worst) seconds. }
else { msg $chan I have no ping record for you $nick $+ . }
}
else {
if ($hget($2,worst) == 0.1) { msg $chan I have no ping reply from $2 yet lol, problems aye ;) | halt }
if ($hget($2,worst)) { msg $chan $nick $+ , $2 $+ 's Worst Ping Record is $hget($2,worst) seconds. }
else { msg $chan I have no ping record for $2 $+ . }
}
}
on *:TEXT:!aping*:#: {
if ($hget($nick,flood) == yes) { halt }
hadd -u3 $nick flood yes
if (!$2) {
if ($hget($nick,worst) == 0.1) || ($hget($nick,record) == 20) { msg $chan I cannot calculate your Mean Average due to insufficient data, $nick $+ . | halt }
var %high $hget($nick,record)
var %low $hget($nick,worst)
msg $chan $nick Your High-Low Ping Medium is $calc( (%high + %low) / 2)
else { msg $chan I have no ping record for you $nick $+ . }
}
else {
if ($hget($2,worst) == 0.1) || ($hget($2,record) == 20) { msg $chan I cannot calculate $2 $+ 's Mean Average due to insufficient data, $nick $+ . | halt }
var %high $hget($2,record)
var %low $hget($2,worst)
msg $chan $2 $+ 's High-Low Ping Medium is $calc( (%high + %low) / 2)
else { msg $chan I have no ping record for $2 $+ . }
}
}
on *:CTCPREPLY:PING*: {
var %ans $calc( ($ticks - $hget($nick,pping)) / 1000 )
write Records.txt %ans $nick $ctime
if (%ans > $hget($nick,worst)) { hadd $nick worst %ans }
if (%ans < $hget($nick,record)) {
msg $hget($nick,pchan) $hget($nick) you have a New Record: by $calc(%ans - $hget($nick,record)) seconds
hadd $nick record %ans
}
msg $hget($nick,pchan) $nick ping reply is %ans seconds from server: $server $+ .
}