#l2.stats.check on alias l2chk.chktime { if (%l2.check.time) && (!$1) { return %l2.check.time } return 300 } alias l2chk.timeout { return 5 } alias l2.chk { ;Format: ;order_id - order from lower (cannot use duplicate digits or skip any digits) ;Correct: 1 2 3 4 5 6 ;Incorect: 2 4 5 6 7 8 ;IP - Server IP ;Port - Server port ;Name - Name, that will be displayed ;l2.chk.returnlist order_id IP Port Name ; ; l2.chk.opensock 1 127.0.0.1 80 Web Server ; l2.chk.opensock 2 192.168.0.2 80 Other PC l2.chk.opensock 1 193.219.74.107 2106 Login Serv l2.chk.opensock 2 193.219.74.105 8686 Eternal Serv l2.chk.opensock 3 193.219.74.107 2106 Reborn Serv l2.chk.opensock 4 bfdr.eu 80 Web Serv } alias l2.chk.opensock { sockclose l2.statcheck. $+ $1 sockopen l2.statcheck. $+ $1 $2 $3 sockmark l2.statcheck. $+ $1 $1 $+ _ $+ $ticks .timerl2chk.timeout. $+ $1 1 $l2chk.timeout set % $+ l2chk. $+ $1 0 $chr(124) sockclose l2.statcheck. $+ $1 set %l2chk.name. [ $+ [ $1 ] ] $4- } on *:sockopen:l2.statcheck.*: { if ($sockerr) { .timerl2chk.timeout. $+ $gettok($sock($sockname).mark,1,95) off set %l2chk. [ $+ [ $gettok($sock($sockname).mark,1,95) ] ] 0 halt } else { .timerl2chk.timeout. $+ $gettok($sock($sockname).mark,1,95) off set %l2chk. [ $+ [ $gettok($sock($sockname).mark,1,95) ] ] 1 set %l2chk.png. [ $+ [ $gettok($sock($sockname).mark,1,95) ] ] $calc($calc($ticks - $gettok($sock($sockname).mark,2,95)) / 1000) $+ s } sockclose $sockname } alias l2chk.status { if (!%l2chk.name. [ $+ [ $1 ] ]) { return } if (%l2chk. [ $+ [ $1 ] ] == 1) { return %l2chk.name. [ $+ [ $1 ] ] - ON - %l2chk.png. [ $+ [ $1 ] ] $+ :return } elseif ($sock(l2.statcheck. $+ $1)) { return %l2chk.name. [ $+ [ $1 ] ] - Refreshing:return } else { return %l2chk.name. [ $+ [ $1 ] ] - OFF:return } } alias l2.chk.all { .unset -s %l2chk.* l2.chk if ($1 = -r) { .timerl2statschk 0 $l2chk.chktime(1) l2.chk.all } } on *:appactive: { if ($appactive) { if (!$timer(l2statschk)) { ;if (!$sock(l2.statcheck.*,0)) { l2.chk.all } .timerl2statschk 1 $l2chk.chktime l2.chk.all -r } } else { if ($timer(l2statschk)) { set %l2.check.time $timer(l2statschk).secs .timerl2statschk off } } } on *:load: { echo -a BFD Server status by Vycka_xxx loaded! l2.chk.all -r .timerl2statschk 0 $l2chk.chktime l2.chk.all } on *:start: { l2.chk.all -r .timerl2statschk 0 $l2chk.chktime l2.chk.all } on *:unload: { echo -a Disabling timers... timerl2statschk off echo -a Done echo -a Unseting Variables... unset -s %l2chk* echo -a Done echo -a Closing Sockets sockclose l2.statcheck.* echo -a Done echo -a BFD Server status by Vycka_xxx unloaded! } alias l2chkSayStat { var %x = 1 while (%l2chk.name. [ $+ [ %x ] ]) { var %msg = %msg %l2chk.name. [ $+ [ %x ] ] $+ : $iif(%l2chk. [ $+ [ %x ] ],ON - %l2chk.png. [ $+ [ %x ] ],OFF) inc %x } msg $active $right(%msg,-4) } menu status,channel,query,menubar { BFD Status .-=BFD Status=-:return .- .$submenu($l2chk.status($1)) .- .$iif($sock(l2.statcheck.*,0) > 0,$style(2) Refreshing,Refresh):l2.chk.all -r .Until refresh $+ $chr(58) $iif($timer(l2statschk).secs == $null,N/A,$v1) $+ s :return .- .$iif($sock(l2.statcheck.*,0) > 0,$style(2),) Say status:l2chkSayStat } #l2.stats.check end