|
Joined: Jan 2006
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2006
Posts: 7 |
Okay so I have a !price script, which is a socket. for some reason it doesnt work, will someoen help me? on *:TEXT:!price *:#:{
/set %item $$2-
/set %chan $chan
if ($sock(rsc)) {
/sockclose rsc
}
/sockopen rsc runescapecommunity.com 80
}
on *:SOCKOPEN:rsc:{
/sockwrite -t $sockname GET /index.php?showtopic=136820# $+ %item $+ $crlf
/sockwrite -t $sockname Host: runescapecommunity.com $+ $crlf
/sockwrite -t $sockname $crlf
}
on *:SOCKREAD:rsc:{
if ($sockerr) {
/msg %chan Socket error: $sockerr $+ , while looking up %item
/unset %item
/unset %chan
}
else {
/var %read
/sockread %read
if (%item $+ : *<br /> iswm %read) {
/msg %chan %read
/unset %item
/unset %chan
/sockclose rsc
}
}
}
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
You are missing the HTTP/1.1 in your GET request. Use this:
on *:SOCKOPEN:rsc:{
sockwrite -nt $sockname GET /index.php?showtopic=136820# $+ %item HTTP/1.1
sockwrite -nt $sockname Host: runescapecommunity.com
sockwrite -nt $sockname
}
Since I don't know what you would be entering into the script to search for, I can't test the rest of the script. -genius_at_work
|
|
|
|
Joined: Jan 2006
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2006
Posts: 7 |
Basically It pulls out prices from runescapecommunity website, whenever I type this of example
!price Abyssal whip
It should say "The price of the following item is 4.2-4.6mill"
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Change your SOCKOPEN event to the following:
on *:SOCKOPEN:rsc:{
sockwrite -nt $sockname GET /index.php?showtopic=136820 HTTP/1.1
sockwrite -nt $sockname Host: runescapecommunity.com
sockwrite -nt $sockname
}
The website you are using is VERY long. It took almost 18 seconds to reach the line containing your example. Does that data change often or do the values stay the same. If the values stay the same, it would be easier to save the values to your hard drive (to an ini file) and then search them locally. -genius_at_work
|
|
|
|
Joined: Jan 2006
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2006
Posts: 7 |
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
First get $download() Then you can use this code: alias price {
var %url = http://www.runescapecommunity.com/index.php?showtopic=136820#
if (!$file(prices.txt)) && (!$download(prices.txt, GET, %url, 3, text)) {
return Error retrieving source
}
return $remove($read(prices.txt,nw,$1:*<br />),<br />)
} You use it like: $price(<item>), and it will only retrieve the source if you haven't already. If you want it to download a newer version of the source then just remove the file with /remove prices.txt, and it will download the new source next time you call $price. That source is very big so downloading takes a little while depending on your connection. To relay this to a channel do it like this: on *:text:!price *:#channel: set %item $2- | .timer 1 0 msgprice # alias msgprice { if ($price(%item)) msg $1 Price for %item $+ : $ifmatch } FYI: The download process using $download is done synchronously, that means it will only go to that return command when the source is fully retrieved. mIRC is not frozen in the mean time though, it only pauses the current thread where you call $download, in this case it pauses the alias price until the download is complete. That is also why I use a timer to call msgprice, because we wouldn't want to pause the on text event.
Gone.
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Actually, since the items contain spaces, it is probably easier to use a txt file instead of an ini. All you have to do is save the data from the website into a txt file. You can do this manually by taking each line from the website and copying it into a regular text file. After all the items are in the file, use this script to search for them:
on *:TEXT:!price *:#:{ var %read = $read(prices.txt,w,$2- $+ :*) if (!%read) { msg $chan Unable to locate item $2- return } msg $chan %read }
-genius_at_work
|
|
|
|
Joined: Jan 2006
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2006
Posts: 7 |
I would love to do this but, I dont get the $download() thing... I get the script, what do i do with it? sorry im new to mIRC scripting First get $download() Then you can use this code: alias price {
var %url = http://www.runescapecommunity.com/index.php?showtopic=136820#
if (!$file(prices.txt)) && (!$download(prices.txt, GET, %url, 3, text)) {
return Error retrieving source
}
return $remove($read(prices.txt,nw,$1:*<br />),<br />)
} You use it like: $price(<item>), and it will only retrieve the source if you haven't already. If you want it to download a newer version of the source then just remove the file with /remove prices.txt, and it will download the new source next time you call $price. That source is very big so downloading takes a little while depending on your connection. To relay this to a channel do it like this: on *:text:!price *:#channel: set %item $2- | .timer 1 0 msgprice # alias msgprice { if ($price(%item)) msg $1 Price for %item $+ : $ifmatch } FYI: The download process using $download is done synchronously, that means it will only go to that return command when the source is fully retrieved. mIRC is not frozen in the mean time though, it only pauses the current thread where you call $download, in this case it pauses the alias price until the download is complete. That is also why I use a timer to call msgprice, because we wouldn't want to pause the on text event.
|
|
|
|
Joined: Jun 2003
Posts: 5,024
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 5,024 |
When you click on the Download link you can just copy and paste the whole lot into your Remote section - to access it, press ALT+R when in mIRC. If you're using Internet Explorer just click the 'Copy to clipboard' link at the top of the page to quickly copy it. Otherwise highlight everything below the dotted line.
For instructions on using the snippet, read the extensive documentation that can be seen at the top of the code!
Regards,
Mentality/Chris
|
|
|
|
Joined: Jan 2006
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2006
Posts: 7 |
Okay first of all genius's change worked, but the problem now is that whenever I try to look up somthing it always goes like this:
Price Abyssal whip 4.2-4.6mill<br />
Can you gusy fix that?
|
|
|
|
|