mIRC Home    About    Download    Register    News    Help

Print Thread
Reading from an online txt file #149955 25/05/06 11:49 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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

Re: Reading from an online txt file #149956 26/05/06 12:07 AM
Joined: Mar 2006
Posts: 13
Z
ZorgonX Offline
Pikka bird
Offline
Pikka bird
Z
Joined: Mar 2006
Posts: 13
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.

Re: Reading from an online txt file #149957 26/05/06 01:03 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
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

Re: Reading from an online txt file #149958 26/05/06 05:01 AM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
wow!

Alright, I'm gonna read and work with it a bit.
Works like a charm so far! Thanks a lot MikeChat!

Re: Reading from an online txt file #149959 26/05/06 08:24 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline OP
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
=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

Re: Reading from an online txt file #149960 26/05/06 08:45 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
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.