So I've been thinking for like over an hour but did not arrive any conclusion with this script. I basically am trying to add a "status check" for 3 IRC servers via mIRC sockets. The problem I'm facing is that the execution jumps over to the next step without the socket connection being completed hence it returns a false value i.e Offline.
I tried using timer before goto commands but that returns ' not found'
Code:
on *:text:!stats:#: {
sockopen IRCAurora aurora.irchound.tk 6667
sockopen IRCKepler kepler.irchound.tk 6667
sockopen IRCJupiter jupiter.irchound.tk 6667
sockpause IRCAurora
sockpause IRCKepler
sockpause IRCJupiter
:true
msg $chan ----STATUS----
goto check1
halt
:check1
if ($sock(IRCAurora,pause) == 1) {
msg $chan 1Aurora - 9Online
}
else {
msg $chan 1Aurora - 4Offline
}
goto check2
halt
:check2
if ($sock(IRCJupiter,pause) == 1) {
msg $chan 1Jupiter - 9Online
}
else {
msg $chan 1Jupiter - 4Offline
}
goto check3
halt
:check3
if ($sock(IRCKepler,pause) == 1) {
msg $chan 1Kepler - 9Online
}
else {
msg $chan 1Kepler - 4Offline
}
halt
}
I know one solution is simply set up a php bot, but I want it on mIRC.
Any help would be appreciated. Thanks in advance.
Never mind .. I've already found the solution for the problem. Simple needed to add an alias function (that replies if socket pause if true / false) with a timer.
Solved code:
on *:text,loaddservers:#: {
if (%admin. [ $+ [ $nick ] ] = 1) {
msg $chan All default servers are now being loaded.
set %server1 aurora.irchound.tk
set %server2 jupiter.irchound.tk
set %server3 kepler.irchound.tk
}
else {
msg $chan Access denied.
}
}
;Create socket connection to servers on trigure.
on *:text:,status*:#: {
if ($2 = all) {
sockopen IRCAurora %server1 6667
sockopen IRCKepler %server2 6667
sockopen IRCJupiter %server3 6667
set %chan $chan
msg $chan Connecting to servers...
msg $chan >>>Status of all servers<<<
timer2 1 5 checkall
}
if ($2 = aurora) {
sockopen IRCAurora %server1 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerAURORA 1 5 checkaurora
}
if ($2 = kepler) {
sockopen IRCKepler %server2 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerKEPLER 1 5 checkkepler
}
if ($2 = jupiter) {
sockopen IRCJupiter %server3 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerJUPITER 1 5 checkjupiter
}
}
;Aliases for each server status response.
alias checkaurora {
if ($sock(IRCAurora,pause) == 1) {
msg %chan 1Aurora - 9Online
}
else {
msg %chan 1Aurora - 4Offline
}
halt
}
alias checkjupiter {
if ($sock(IRCJupiter,pause) == 1) {
msg %chan 1Jupiter - 9Online
}
else {
msg %chan 1Jupiter - 4Offline
}
halt
}
alias checkkepler {
if ($sock(IRCKepler,pause) == 1) {
msg %chan 1Kepler - 9Online
}
else {
msg %chan 1Kepler- 4Offline
}
halt
}
alias checkall {
if ($sock(IRCAurora,pause) == 1) {
msg %chan 1Aurora - 9Online
}
else {
msg %chan 1Aurora - 4Offline
}
goto check2
halt
:check2
if ($sock(IRCJupiter,pause) == 1) {
msg %chan 1Jupiter - 9Online
}
else {
msg %chan 1Jupiter - 4Offline
}
goto check3
halt
:check3
if ($sock(IRCKepler,pause) == 1) {
msg %chan 1Kepler - 9Online
}
else {
msg %chan 1Kepler - 4Offline
}
}
NOTE: I've excluded some part of the script that's not related to the question.. so you may find some undefined variables.