mIRC Home    About    Download    Register    News    Help

Print Thread
#38186 24/07/03 08:43 PM
Joined: Jun 2003
Posts: 36
E
elroyK Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2003
Posts: 36
I was just poking around in a script to see how they did something, and i came across this lag meter that does weird things.. code follows:

alias _checklag { .timerLagCheck 0 $_opt.rval(n5,3) .raw ping $ctime }
ON ^*:PONG: {
SET %_Mlag.pt $round($calc(($ctime - $2) / 1000),0)
SET %_Mlag.dpt $calc(($ctime - $2) / 1000)

The rest is the stuff that sets the timer and draws the lag in a window and stuff.. But i really don't get it. Why is the pong reply being divided by 1000 ? And why does it use the same time in the ping command every time ? (in the /timers i checked, it used the same number in every ping command)
That way the server just thinks i'm lagging a lot and the script divides it by 1000 .. or am i missing something here? confused

#38187 24/07/03 08:52 PM
Joined: Dec 2002
Posts: 86
D
Babel fish
Offline
Babel fish
D
Joined: Dec 2002
Posts: 86
Looks like a bug from here.

When a timer is created, the line is parsed/evaluated by mIRC like normal. This means that when the _checklag alias was called, $ctime was evaluated and stuck in there. Had the author chosen to use $!ctime to avoid evaluation at the time of the timer creation, at least you'd be seeing that its sending a raw ping with the current $ctime.

Also, dividing by 1000 makes absolutely no sense in this context ($ctime is seconds, not milliseconds). The author probably just glanced at the results of testing it anddividing by 1000 seemed to look more significant.

I'm not sure I'd be looking at more of this authors code if I were you. At least not without thourougly testing it like you appear to have done with this example.

-chris

#38188 24/07/03 09:56 PM
Joined: Jun 2003
Posts: 36
E
elroyK Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2003
Posts: 36
It's Mish script. I already thought it didn't make sense that he had it divided by 1000. I put an echo in there to see the command it was sending to the server and that's how i saw it kept sending the same time. Oh well, at least now i'm sure about it not making much sense. Thanks

#38189 24/07/03 10:21 PM
Joined: May 2003
Posts: 215
Fjord artisan
Offline
Fjord artisan
Joined: May 2003
Posts: 215
Quote:

SET %_Mlag.pt $round($calc(($ctime - $2) / 1000),0)

This returns a whole number so that the /draw command works.

Quote:

SET %_Mlag.dpt $calc(($ctime - $2) / 1000)

This will return the lag time in decimals. 0.123


- Jason

Link Copied to Clipboard