mIRC Home    About    Download    Register    News    Help

Print Thread
#95155 22/08/04 03:36 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
I know that it's a simple matter - I have done a search and tried some of the solutions (with no results) - but this has been bugging me for a few weeks now, and I can't figure it out.
Code:
on *:input:*: if (/ping == $$1) { set %ping. [ $+ [ $$2 ] ] $ticks | .ctcp $$2 ping }
on *:CTCPREPLY:PING*: echo -s $calc(($ticks - %ping. [ $+ [ $nick ] ])/1000)
I modified the code a bit.. it had some IF's and /notices, but it doesnt change the issue.

What I want is to echo a ping reply in miliseconds. Eg: 1.282. I know that the theory is correct. I got the values that were echo'd, did a manual $calc and the results were as I wanted to: 1.282s.

My point is that I don't seem to be able to make that $calc in the script. I've tried to use both $ticks - $2 /1000 and the version with variable that you see above, none with success. And yet, if I do a manual $calc, it works fine.

What is the problem there? :P

Edit: fixed typo on post, ty dr Eamer wink

Last edited by Zyzzyx26; 22/08/04 04:20 PM.

"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
on *:CTCPREPLY:PING*: echo -s $calc(( $ticks - %ping. [ $+ [ $nick ] ])/1000)


Maybe I wake up one day to notice that all my life was just a dream!
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
It was a typo. Well, not really a typo, but a mix up of my part. I had 2 scripts.. one with no variables and one with lots of them.
Code:
on *:CTCPREPLY:PING*: echo -s $calc(([color:blue]$[/color]ticks - %ping. [ $+ [ $nick ] ])/1000)
The above was the one with no variables.
Code:
on *:input:*: if (/ping == $$1) { set %ping. [ $+ [ $$2 ] ] $ticks | .ctcp $$2 ping }
on *:CTCPREPLY:PING*: var %ticks = $ticks | echo -s $calc((%ticks - %ping. [ $+ [ $nick ] ])/1000)
This one has a few %variables. I used them to see if it was a bug with $ticks or some other problem.

When I pasted the code, I mixed them up, but now that you warned me about the confusion, you can see that they are correct (as far as I can see :P)

Btw, I edited the post above with the correction, and also got the extra } out. Ty.

Problem still persists, though smirk
Zyzzyx.

Last edited by Zyzzyx26; 22/08/04 04:22 PM.

"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2004
Posts: 42
T
Ameglian cow
Offline
Ameglian cow
T
Joined: Aug 2004
Posts: 42
Heres some code from my TBtriv script:

on *:TEXT:*:#: {
if ($1 == !pingme) {
set %TBtrivping. $+ [ $1 ] $ticks
ping $1
}
}

on *:CTCPREPLY:PING*: {
var %ticks = $ticks
var %oldticks = [ % [ $+ TBtrivping. $+ [ $nick ] ] ]
var %ping = $calc((%ticks - %oldticks) / 1000)
msg $nick 00,12 PINGREPLY $nick $+ : 12,08 %ping seconds 00,12 Im running on: $server
unset %TBtrivping. $+ [ $nick ]
}

Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
Leave an extra space:
Code:
on *:CTCPREPLY:PING*: var %ticks = $ticks | echo -s $calc((%ticks - %ping. [ $+ [ $nick ] ] )/1000)
;                                                                                          ^here 


btw $ticks - $2 / 1000 didn't work because ctcp <nick> ping sends over $ctime, NOT $ticks!


Maybe I wake up one day to notice that all my life was just a dream!
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
var %oldticks = [ % [ $+ TBtrivping. $+ [ $nick ] ] ]

That did the trick, thanks! laugh


"All we are saying is give peace a chance" -- John Lennon
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
lol, when I tried $ticks - $2 I got a huge negative number as a reply :P

Thanks for the help smile


"All we are saying is give peace a chance" -- John Lennon

Link Copied to Clipboard