mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2015
Posts: 112
B
Blas Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
I've been trying to wrap my head around this for hours now. I have wrote a complex Twitch Autohost script that is almost completely functional except for this last piece of the puzzle. The issue I am having is that it appears as if variables are not being set/returned fast enough. This is the "checking if channel is live" portion of my autohost script (I got the template on this forum). The issue is that the other portion of my script is quickly scanning each channel in my autohost list in a while loop, and needs to know right away if a channel is live so it can do the hosting and then halt the while loops that keep searching for a channel to host before it tries to host another. The issue in this code is that the "IF (%tuptime == True) { return true }" line of tuptime does not actually return "true" fast enough, as when I used the "!ahtest channelname" in the script show, it will not msg channel until the second time that I run it, which it will then return both "test2" and then "test1" to the channel. However, the %tuptime variable IS getting set in mIRC immediately after I first use the !ahtest command. My question is, how can I have my tuptime alias start and then finish and return true before the tuptime alias is called on again in the while loops I have created in the rest of my script that I have written?

Code:
ON *:TEXT:!ahtest &:#: {
  $tuptime($2)
  IF (%tuptime) MSG $chan test1
}


alias tuptime {

  SET %uptimechan $1
  sockclose tuptime
  sockopen tuptime nightdev.com 80
  IF (%tuptime == True) { msg $chan test2 | return true }
}


ON *:SOCKOPEN:tuptime: {
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %uptimechan HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname $crlf
}


ON *:SOCKREAD:tuptime: {
  if ($sockerr) { sockclose $sockname }
  var %data
  sockread %data
  if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
    SET %tuptime True
  }
}

Joined: Oct 2015
Posts: 112
B
Blas Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Well I spent a few more hours on the script, and it appears at the moment that I have a working autohost script with multiple "tiers" of possible hosts. However, I had to set a LOT of various timers to have it function properly due to the above issue.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You can't do that with mIRC sockets, structure the code differently to execute your commands after the sockets have finished.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
You can have a look at this addon i've made it for an other user but may it is that you want for: http://pastebin.com/zMiwANBC or look and this one: http://hawkee.com/snippet/16314/

Last edited by westor; 28/11/15 02:56 PM.

Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Oct 2015
Posts: 112
B
Blas Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Thanks for the replies. The scripts that westor linked to are the scripts that I used to start writing my script. I have structured the code in a way now that checks each channel about six seconds after each other to see if they are online. It seems like this method takes a lot longer than it probably needs to, but it is working so far.


Link Copied to Clipboard