mIRC Homepage
Posted By: OrionsBelt Reading from an online txt file - 25/05/06 11:49 PM
I know you guys usually only help with tuning a script, but I wouldn't know where to start with this one, and I dont know if this would even be possible.

There is this online txt file (a dump from a game I play).
http://game.planetarion.com/botfiles/planet_listing.txt
This file is being updated every hour (tick), and keeps always same filename.

I would love to have a script that can read from this file.
Like !info 10:1:12
The script would then return all the details on that particular line.

I don't know if it would be better to download it first, and then read, or just read on-the-fly etc.

Does anyone have any idea how this can be done? And IF this can be done?

Thx a lot
Posted By: ZorgonX Re: Reading from an online txt file - 26/05/06 12:07 AM
There is, indeed, a way to do the action that you describe.. the "how" is the main thing, though. I believe it has to do with sockets.. I'd advise looking in the mIRC help file. I'm not an expert in this field, so I'm not certain.
Posted By: MikeChat Re: Reading from an online txt file - 26/05/06 01:03 AM
Code:
alias updateinfo { sockclose gameinfo | sockopen gameinfo game.planetarion.com 80 | write -c gameinfo.txt }
on *:sockopen:gameinfo:{
  echo -s opened: $sockname
  sockwrite -n $sockname GET http://game.planetarion.com/botfiles/planet_listing.txt HTTP/1.1
  sockwrite $sockname HOST: game.planetarion.com $+ $crlf $+ $crlf
}
on *:sockread:gameinfo:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  write gameinfo.txt %temp
  goto nextread
}
on *:sockclose:gameinfo:{ run gameinfo.txt }


this is basicly copied out of the help file
/help $sockname

you really should review that section before using
Posted By: OrionsBelt Re: Reading from an online txt file - 26/05/06 05:01 AM
wow!

Alright, I'm gonna read and work with it a bit.
Works like a charm so far! Thanks a lot MikeChat!
Posted By: OrionsBelt Re: Reading from an online txt file - 26/05/06 08:24 PM
=22:21:33= <@Me> !planet 10:1:12
=22:21:34= <@Bot> 10:1:12 - waytoocool of toosweet (Tick: 1007)
=22:21:34= <@Bot> Race: XAN, Size: 91, Value: 112.777, Score: 290.577, XP: 3.556

Definately awesome Mike.
This was exactly what I was looking for. Thx again!!! wink
Posted By: MikeChat Re: Reading from an online txt file - 26/05/06 08:45 PM
to see some more advanced uses of sockets you can do a search on these forums
search term $sockopen
select the scipts and popups forum
you can specify the author to list, people like
FiberOPtics DaveC Qwerty genious at work and others are good to look for in the history.
© mIRC Discussion Forums