Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- THIS SCRIPT HAS BEEN MADE BY [MM]IKKE
- DO NOT DELETE ANY OF THESE CREDITS
- USAGE
- -----------
- 1. Copy-paste this to your remote tab (mIRC) in scripts editor.
- 2. Use /pingtest to test your own ping. It'll ping yourself 5 times by default, unless specified otherwise.
- 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*:)
- 4. Enjoy!
- */
- alias pingtest {
- set %ping_amount 0
- ;set a global amount - will increase on each CTCP reply
- if ($1 isnum) {
- ;check if it's a number
- set %ping_times $1
- ;total amount of ping times
- var %i = 0
- while (%i < $1) {
- ;loop which calls the local function pingtest_do. Uses another function as 2 timers might not be triggered at same time.
- .timer 1 $calc(%i * 3) pingtest_do %i
- inc %i
- }
- }
- else {
- ;if it's not a number, do the same, but 5 times
- set %ping_times 5
- var %i = 0
- while (%i < 5) {
- .timer 1 $calc(%i * 3) pingtest_do %i
- inc %i
- }
- }
- }
- alias -l pingtest_do {
- ;send the ping and set a variable with the current uptime of your mirc in ms
- .ctcp $me ping
- set %ping_sent $+ $1 $uptime(mirc)
- }
- on *:CTCPREPLY:ping*: {
- if ($nick == $me && %ping_times) {
- ;check if the ping was sent by yourself and if it's triggered by the script
- set %ping_ms $+ %ping_amount $calc(($uptime(mirc) - $+($chr(37),ping_sent,%ping_amount))/2)
- ;calculate the ping - divide by 2 as it goes from yourself to the server and back
- ;echo -at Ping: $eval($+($chr(37),ping_ms,%ping_amount),2) ms
- ;remove comment mark if you want to (see usage)
- inc %ping_amount
- ;increase the global variable
- if (%ping_amount == %ping_times) {
- ;when the script should end
- set %ping_total 0
- ;set a global variable with all pings added to each other
- var %i = 0
- while (%i < %ping_times) {
- ;loop to do so
- inc %ping_total $eval($+($chr(37),ping_ms,%i),2)
- inc %i
- }
- echo -at Average ping: $round($calc(%ping_total / %ping_times),1) ms
- ;calculate total average ping
- unset %ping_total
- unset %ping_ms*
- unset %ping_sent*
- unset %ping_amount
- unset %ping_times
- ;unset all variables used
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment