mIRC Home    About    Download    Register    News    Help

Print Thread
ctcp ping reply calculation #142528 18/02/06 02:36 PM
Joined: Jan 2005
Posts: 3
A
arkt1k Offline OP
Self-satisified door
OP Offline
Self-satisified door
A
Joined: Jan 2005
Posts: 3
Code:
on *:CTCPREPLY:*:{
  if ($1 == ping) { goto ping }
  :ping
  %ping = $calc($ticks - $2)
  echo -a ctcp 1,1 $str($chr(160),10) 09 ctcp ping reply from $nick %ping sec(s)
}


Nevermind, but i'm going to post my fix incase anyone ever had the same problem this post could be refered to smile

Code:
ctcp { 
  if ($2 == ping) { set %ping $ticks
    echo -ai18 $theme(ctcp) 1,1 $str($chr(160),10) 9 $theme(ctcp $2 to $1)
    .ctcp $1 $2
    .halt
  }
}

on *:CTCPREPLY:*:{
  if ($1 == ping) { goto ping }
  :ping
  %pingz = $round($calc($calc($ticks - %ping) / 1000),4) 
  echo -a $theme(ctcp) 1,1 $str($chr(160),10) 09 $theme(ctcp ping reply from $nick %pingz sec(s))
  halt
}


Also nevermind the $theme()

Last edited by arkt1k; 18/02/06 03:33 PM.
Re: ctcp ping reply calculation #142529 18/02/06 04:20 PM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
You can shorten your On ctcpreply event to this

Code:
 on *:CTCPREPLY:PING*:{

  %pingz = $round($calc(($ticks - %ping) / 1000),4) 

  echo -a $theme(ctcp) 1,1 $str($chr(160),10) 09 $theme(ctcp ping reply from $nick %pingz sec(s))

halt

}
 


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Re: ctcp ping reply calculation #142530 20/02/06 03:19 AM
Joined: Dec 2002
Posts: 29
H
HobophobE Offline
Ameglian cow
Offline
Ameglian cow
H
Joined: Dec 2002
Posts: 29
If you want, you can actually send your $ticks value in your CTCP Ping, rather than setting it locally.
example:
Code:
/ctcpticks {
.raw privmsg $1 $+(:,$chr(1),PING,$chr(32),$ticks,$chr(1))
echo -a (whatever you want to show when you send the CTCP Ping)
}
on *:ctcpreply:PING*:{
echo -a $nick replied after $round($calc($calc($ticks - $2) / 1000),4) sec(s)
}

Re: ctcp ping reply calculation #142531 21/02/06 11:43 AM
Joined: Dec 2002
Posts: 28
P
puterfixer Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Dec 2002
Posts: 28
I used $ticks to calculate a ping reply in milliseconds. See the explanation and code here: Ping in milliseconds. Please don't rip the code (use it without giving credit to the original author), or you will have bad sex for the rest of your life wink

Re: ctcp ping reply calculation #142532 22/02/06 01:23 AM
Joined: Dec 2002
Posts: 1,527
L
landonsandor Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,527
As a side note to all this ping calculation, here's how I do miliseconds:

1) standard ping request comes in (ctcp my-nick ping)
2) using the script:

Code:
ctcp ^*:*: {
  elseif ($1 == ping) {
    if ($nick != $me) {
      custom reply code snipped
      if ($calc(($2 - $ctime)/1000) >= 0) { var %pt = $calc(($2 - $ctime)/1000) | goto display }
      if ($calc(($ctime - $2)/1000) >= 0) { var %pt = $calc(($ctime - $2)/1000) | goto display }
      :display
      rest of script
    }
  }
}


I KNOW it could be done differently, but it works well by intercepting the $ctime value placed on $2 and just manipulates that vs using $ticks


Those who fail history are doomed to repeat it