mIRC Homepage
Posted By: Midori /ping - 03/10/06 02:11 AM
Ping replies are currently given in seconds; seeing as how with the advent of faster and faster internet connections (fios, cable, edu), this is no longer a viable way to see how much an individual lags, it would be nice if the ping reply was changed to a ms response time.

Thanks,
Midori
Posted By: landonsandor Re: /ping - 03/10/06 02:23 AM
for now, you can do something like this (ripped out of larger scripts):

Code:
ctcp ^*:*: {
  elseif ($1 == ping) {
    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 code here
  }
}


I had to add a line cause for some reason I could get negative replies. I know I know, "must be faulty coding" LOL

Code:
on *:ctcpreply:*: {
  if ($1 == ping) {
    if (($nick == $me) || (!$2) || ($2 !isnum)) { halt }
    var %pt = $calc(($ticks - $2)/1000)
    rest of code here
  }
}


These are just examples, but it has always worked for me smile In case you wanna know why I have it in both places, the reason is simple, when somebody pings, all they care about is how long it takes a message to get from you to me. nobody really cares about the return trip, so one of those scripts intercepts their ping request and just displays the lag from their request to my recieve. it cuts down on a trip. Think of it this way:

Trip 1) They request a ping
Trip 2) You send them the reply
Trip 3) They issue the custom display with milliseconds

So it goes from them to you (trip 1), you to them (trip 2) and them back to you (trip 3). With the other way, it does:

Trip 1) they request a ping
Trip 2) you recieve their request which includes a time you can utilize and send them back the one way lag check. See if that works for you in the meantime
Posted By: Jae Re: /ping - 03/10/06 05:42 AM
Quote:
Code:
ctcp ^*:*: {
  elseif ($1 == ping) { 


Im pretty sure that you're meant to do and 'if' before an 'elseif'. that said fixing it to an 'if' doesnt work.. and the code doesnt seem like it should so unless something drastic is missing.
Posted By: RusselB Re: /ping - 03/10/06 06:29 AM
You should read the entire post. landonsandor stated, right at the beginning of his post
Quote:
(ripped out of larger scripts)
Posted By: landonsandor Re: /ping - 03/10/06 02:45 PM
well, that might not work as listed, but it should certainly give you an option for handling it. My script works, but I wont copy/paste the whole thing here. There's at least a start to what you want (from a scripted POV - that doesnt mean it's not a valid suggestion).

ALSO, where I said REST OF CODE HERE, you're suppose to insert your OWN custom handling/displaying code there smile If you need more help, let me know
Posted By: MikeChat Re: /ping - 05/10/06 01:03 AM
this is code i got off the scripts forum here some years ago
Code:
alias ping .raw PRIVMSG $$1 : $+ $chr(1) $+ PING $ticks $+ $chr(1)
on *:CTCPREPLY:PING*: {
  var %ping = $calc(($ticks - $2) / 1000) Seconds
  echo -a $+($nick,'s) $1 is %ping
  .notice $nick Your $1 is %ping
  haltdef
}

this replaces the default IRC command /ping in mIRC so you might have to hunt down other places in code you might have the currently uses the seconds and convert that code to $ticks or milliseconds
Posted By: FNar Re: /ping - 07/10/06 02:54 AM
Code:
ctcp ^*:*: {
  elseif ($1 == ping) {
    if ($abs($calc(($2 - $ctime)/1000)) >= 0) { var %pt = $abs($calc(($2 - $ctime)/1000)) | goto display }


Off the top of my head - I didn't test it.
Posted By: landonsandor Re: /ping - 07/10/06 03:16 AM
yeah, that's one way of doing it, and the other way would be to $remove(value,-) which is the same as taking the $abs (absolute value) of it too smile there's all kinds of ways. The thing I ran into was that the negative number wasnt ALWAYS the opposite of the value.... I cant explain it all really.
Posted By: pishposh Re: /ping - 27/10/06 11:37 PM
Here's my variation. Enhances the existing ping command and (unless I screwed up) produces screen output exactly as the normal ping function does.

ping {
if ($1 != -m) /ctcp $$1 ping
else {
.raw PRIVMSG $$2 : $+ $chr(1) $+ PING $ticks msec $+ $chr(1)
echo -itlbfmrc ctcp -> $chr(91) $+ $$2 $+ $chr(93) PING
halt
}
}

on *:CTCPREPLY:PING * msec:{
echo -esitlbfmrc ctcp $+([,$nick) PING reply]: $calc(($ticks - $2)/1000) $+ secs
haltdef
}

/ping Nick = normal ping
/ping -m Nick = milisecond ping
© mIRC Discussion Forums