mIRC Homepage
Posted By: arkt1k ctcp ping reply calculation - 18/02/06 02:36 PM
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()
Posted By: xDaeMoN Re: ctcp ping reply calculation - 18/02/06 04:20 PM
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

}
 
Posted By: HobophobE Re: ctcp ping reply calculation - 20/02/06 03:19 AM
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)
}
Posted By: puterfixer Re: ctcp ping reply calculation - 21/02/06 11:43 AM
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
Posted By: landonsandor Re: ctcp ping reply calculation - 22/02/06 01:23 AM
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
© mIRC Discussion Forums