_MM_IKKE

[mIRC] Ping tester

Sep 4th, 2012
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.38 KB | None | 0 0
  1. /*
  2. THIS SCRIPT HAS BEEN MADE BY [MM]IKKE
  3. DO NOT DELETE ANY OF THESE CREDITS
  4.  
  5. USAGE
  6. -----------
  7. 1. Copy-paste this to your remote tab (mIRC) in scripts editor.
  8. 2. Use /pingtest to test your own ping. It'll ping yourself 5 times by default, unless specified otherwise.
  9. 3. If you want to see the exact ping times used in the calculations, remove the ';' in front of the line 'echo -at Ping: $eval($+($chr(37),ping_ms,%ping_amount),2) ms' (at on *:CTCPREPLY:ping*:)
  10. 4. Enjoy!
  11. */
  12.  
  13.  
  14. alias pingtest {
  15.   set %ping_amount 0
  16.   ;set a global amount - will increase on each CTCP reply
  17.  
  18.   if ($1 isnum) {
  19.     ;check if it's a number
  20.  
  21.     set %ping_times $1
  22.     ;total amount of ping times
  23.  
  24.     var %i = 0
  25.     while (%i < $1) {
  26.       ;loop which calls the local function pingtest_do. Uses another function as 2 timers might not be triggered at same time.
  27.       .timer 1 $calc(%i * 3) pingtest_do %i
  28.       inc %i
  29.     }
  30.   }
  31.   else {
  32.     ;if it's not a number, do the same, but 5 times
  33.  
  34.     set %ping_times 5
  35.     var %i = 0
  36.     while (%i < 5) {
  37.       .timer 1 $calc(%i * 3) pingtest_do %i
  38.       inc %i
  39.     }
  40.   }
  41. }
  42. alias -l pingtest_do {
  43.   ;send the ping and set a variable with the current uptime of your mirc in ms
  44.   .ctcp $me ping
  45.   set %ping_sent $+ $1 $uptime(mirc)
  46. }
  47. on *:CTCPREPLY:ping*: {
  48.   if ($nick == $me && %ping_times) {
  49.     ;check if the ping was sent by yourself and if it's triggered by the script
  50.    
  51.     set %ping_ms $+ %ping_amount $calc(($uptime(mirc) - $+($chr(37),ping_sent,%ping_amount))/2)
  52.     ;calculate the ping - divide by 2 as it goes from yourself to the server and back
  53.  
  54.     ;echo -at Ping: $eval($+($chr(37),ping_ms,%ping_amount),2) ms
  55.     ;remove comment mark if you want to (see usage)
  56.  
  57.     inc %ping_amount
  58.     ;increase the global variable
  59.  
  60.     if (%ping_amount == %ping_times) {
  61.       ;when the script should end
  62.  
  63.       set %ping_total 0
  64.       ;set a global variable with all pings added to each other
  65.  
  66.       var %i = 0
  67.       while (%i < %ping_times) {
  68.         ;loop to do so
  69.         inc %ping_total $eval($+($chr(37),ping_ms,%i),2)
  70.         inc %i
  71.       }
  72.  
  73.       echo -at Average ping: $round($calc(%ping_total / %ping_times),1) ms
  74.       ;calculate total average ping
  75.  
  76.       unset %ping_total
  77.       unset %ping_ms*
  78.       unset %ping_sent*
  79.       unset %ping_amount
  80.       unset %ping_times
  81.       ;unset all variables used
  82.     }
  83.   }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment