SRL Archive - OSR Utility Scripts

GetPrice


Shatterhand

2013-05-12 05:19:38

Here is a function for getting item prices from the zybez price guide. Calculates weighted average from the last X offers.
API: http://forums.zybez.net/runescape-2007-prices/api/?info

type
Offer = record
selling : Boolean;
quantity : Integer;
price : Integer;
date : Integer;
name : String;
valid : Boolean;
comment : String;
end;



function GetPrice(Item: String) : Integer;
var
str, templine, s1, s2 : String;
Offers : Array[1..100] of Offer;
explodes : Array of String;
maxsamples, i, j,
recentlow, recenthigh, highalch : Integer;
buyquantity, sellquantity, buyvalue, sellvalue,
buyprice, sellprice : Integer;
DebugMode : Boolean;
begin
Result := 0;
buyquantity := 0;
sellquantity := 0;
buyvalue := 0;
sellvalue := 0;

//DEBUG
DebugMode := True;

//last X offers
maxsamples := 100;

//getting page
explodes := Explode(' ',Item);
Item := Implode('+',explodes);

str := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
if (str = '{"error":"No results found."}') then
begin
Writeln('{"error":"No results found."}');
Exit;
end;

explodes := Explode('+',Item);
explodes[0] := Capitalize(explodes[0]);
Item := Implode(' ',explodes);

str := Between('"name":"'+Item+'"', ']}', str);
str := str + ']}';

recentlow := StrToInt(Between('recent_low":"', '"',str));
recenthigh := StrToInt(Between('recent_high":"', '"',str));
highalch := StrToInt(Between('high_alch":"', '"',str));

str := Between('"offers":[', ']}', str);
str := str + ',';

//getting lines
s1 := '{';
s2 := '},';
for i:=1 to maxsamples do
begin
templine := Between(s1, s2, str);
s1 := templine + '},{';
case Between('selling":"', '"', templine) of
'0': Offers[i].selling := False;
'1': Offers[i].selling := True;
end;
Offers[i].quantity := CashStrToInt(Between('quantity":"', '"', templine));
Offers[i].price := CashStrToInt(Between('price":"', '"', templine));
Offers[i].date := CashStrToInt(Between('date":"', '"', templine));
Offers[i].name := Between('rs_name":"', '"', templine);
Offers[i].valid := True;
Offers[i].comment := '';
end;

//removing: name duplicates
for i:=1 to maxsamples do
begin
j := 1;
while (j < i) do
begin
if (Offers[i].name = Offers[j].name) then
begin
Offers[i].valid := False;
Offers[i].comment := '[name duplicate]';
Break;
end;
Inc(j);
end;
end;

//removing: lower than 0.8*highalch
for i:=1 to maxsamples do
begin
if (Offers[i].price < (highalch*0.8)) then
begin
Offers[i].valid := False;
Offers[i].comment := '[lower than 0.8*highalch]';
end;
end;

//removing: higher than 1.5*recenthigh
for i:=1 to maxsamples do
begin
if not (recenthigh = 0) then
if (Offers[i].price > (recenthigh*1.5)) then
begin
Offers[i].valid := False;
Offers[i].comment := '[higher than 1.5*recenthigh]';
end;
end;

//removing: overflow
for i:=1 to maxsamples do
begin
if ((Offers[i].price * Offers[i].quantity) < 0) then
begin
Offers[i].valid := False;
Offers[i].comment := '[overflow]';
end;
end;

//Offers - DEBUG
for i:=1 to maxsamples do
begin
Writeln('['+IntToStr(i)+'] '+ 'selling: '+BoolToStr(Offers[i].selling)+', quantity: '+IntToStr(Offers[i].quantity)+', price: '+IntToStr(Offers[i].price)+', date: '+IntToStr(Offers[i].date)+', name: '+Offers[i].name+', valid: '+BoolToStr(Offers[i].valid)+' '+Offers[i].comment);
end;

//getting quantities, prices
for i:=1 to maxsamples do
begin
if (Offers[i].valid = True) then
begin
if (Offers[i].selling = True) then
begin
sellvalue := sellvalue + Offers[i].quantity * Offers[i].price;
sellquantity := sellquantity + Offers[i].quantity;
end;

if (Offers[i].selling = False) then
begin
buyvalue := buyvalue + Offers[i].quantity * Offers[i].price;
buyquantity := buyquantity + Offers[i].quantity;
end;
end;
end;

//calculating result
if not (buyquantity = 0) then
buyprice := buyvalue / buyquantity
else
buyprice := 0;
if not (sellquantity = 0) then
sellprice := sellvalue / sellquantity
else
sellprice := 0;
Result := (buyprice + sellprice) / 2;

//DEBUG
if DebugMode then
begin
Writeln('buyprice: ' + IntToStr(buyprice));
Writeln('buyvalue: ' + IntToStr(buyvalue));
Writeln('buyquantity: ' + IntToStr(buyquantity));
Writeln('sellprice: ' + IntToStr(sellprice));
Writeln('sellvalue: ' + IntToStr(sellvalue));
Writeln('sellquantity: ' + IntToStr(sellquantity));
end;
end;

Writeln(IntToStr(GetPrice('rune scimitar'))); 

(Working on this…)
CalcInvPrice. Calculates the price of the inventory, using GetPrice or manual prices for each items.
program PriceChecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.simba}

{$IFDEF SMART}
{$I SRL-OSR/SRL/misc/SmartGraphics.simba}
{$ENDIF}
const

ManualPrice = False;
//set it True if you want to set the prices yourself
//set it False if you want to use zybez price guide prices


type
Item = record
name : String;
amount : Integer;
price : Integer;
end;



function GetPrice(Item: String) : Integer;
var
str, templine, s1, s2 : String;
name, selling, quantity, price : String;
Lines, Names : Array[1..100] of String;
maxsamples, i, j,
buyquantity, sellquantity, buyvalue, sellvalue,
buyprice, sellprice: Integer;
match : Boolean;
begin
Result := 0;
//last X offers
maxsamples := 50;

buyquantity := 0;
sellquantity := 0;
buyvalue := 0;
sellvalue := 0;

//getting page
str := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
if (str = '{"error":"No results found."}') then Exit;
str := Between('"offers":[', ']}]', str);
str := str + ',';

s1 := '{';
s2 := '},';

//getting lines
for i:=1 to maxsamples do
begin
templine := Between(s1, s2, str);
s1 := templine + '},{';
Lines[i] := templine;
end;

//getting names, removing duplicates
for i:=1 to maxsamples do
begin
name := Between('"rs_name":"', '"', Lines[i]);
match := False;
j := 1;
while ((j < i) and (match = False)) do
begin
if (name = Names[j]) then
match := True;
Inc(j);
end;
if (match = False) then
Names[i] := name
else
Lines[i] := '-------------------------------- DELETED, NAME DUPLICATES --------------------------------';
end;

//getting quantities, prices
for i:=1 to maxsamples do
begin
templine := Lines[i];
if not (templine = '') then
begin
selling := Between('"selling":"', '"', templine);
quantity := Between('"quantity":"', '"', templine);
price := Between('"price":"', '"', templine);

if (selling = '1') then
begin
sellvalue := sellvalue + StrToInt(quantity) * StrToInt(price);
sellquantity := sellquantity + StrToInt(quantity);
end;

if (selling = '0') then
begin
buyvalue := buyvalue + StrToInt(quantity) * StrToInt(price);
buyquantity := buyquantity + StrToInt(quantity);
end;
end;
end;
if not (buyquantity = 0) then
buyprice := Round(buyvalue / buyquantity)
else
buyprice := 0;
if not (sellquantity = 0) then
sellprice := Round(sellvalue / sellquantity)
else
sellprice := 0;
Result := (buyprice + sellprice) / 2;

//DEBUG
//for i:=1 to maxsamples do
// Writeln('[' + IntToStr(i) + '] ' + Lines[i]);
//Writeln('buyprice: ' + IntToStr(buyprice));
//Writeln('buyvalue: ' + IntToStr(buyvalue));
//Writeln('buyquantity: ' + IntToStr(buyquantity));
//Writeln('sellprice: ' + IntToStr(sellprice));
//Writeln('sellvalue: ' + IntToStr(sellvalue));
//Writeln('sellquantity: ' + IntToStr(sellquantity));
end;



function FormatValue(value : Integer) : String;
var
kmod, mmod : Integer;
begin
if (value < 1000) then
Result := IntToStr(value)
else
begin
kmod := value mod 1000;
Result := IntToStr((value-kmod)/1000) + 'k';
end;
end;



procedure CalcInvPrice;
var
X,Y, i, sum, price : Integer;
opts : Array of TOptions;
text, input : String;
Items : Array[1..28] of Item;
begin
for i:=1 to 28 do
begin
if ExistsItem(i) then
begin
Items[i].amount := GetAmountBox(InvBox(i));
end;
end;

for i:=1 to 28 do
begin
if ExistsItem(i) then
begin
MouseItem(i,mouse_right);
opts := GetChooseOptions;
text := opts[High(opts)-1].str;

text := Replace(text,'Examine ','');
text := Replace(text,'Examine','');

Items[i].name := text;
ChooseOption('asd');
end;
end;

sum := 0;
for i:=1 to 28 do
begin
if not (Items[i].amount = 0) then
begin
if (Items[i].name = 'Coins') then
begin
Writeln(IntToStr(Items[i].amount) + ' x ' + Items[i].name + ' = ' + FormatValue(Items[i].amount));
sum := sum + Items[i].amount;
end else
begin
text := Items[i].name;
text := Replace(text,' ','+');
if ManualPrice then
if InPutQuery('Price',Items[i].name + ':',input) then
price := StrToInt(input)
else
price := GetPrice(text)
else
price := GetPrice(text);
Writeln(IntToStr(Items[i].amount) + ' x ' + Items[i].name + ' = ' + IntToStr(Items[i].amount) + ' x ' + IntToStr(price) + ' = ' + FormatValue(Items[i].amount*price));
sum := sum + Items[i].amount*price;
end;
end;
end;

Writeln('');
Writeln('Total value: ' + FormatValue(sum));
end;



begin
ClearDebug;
SetupSRL;
CalcInvPrice;
end.

IMayoboeiI

2013-05-12 05:20:49

The average price for the item on Zybez is 99% totally inaccurate. However, I do like this piece of code and will certainly be useful in fighter scripts.

iTimmy

2013-05-12 05:21:07

This could be useful for getting gp/hr on scripts :P

jelknab

2013-05-12 06:04:39

This is going in my fishing script :). Will credit you. This is awesome!

Haxz

2013-05-12 06:35:46

Wonder if you could exclude the unreasonable price and only find the average of the reasonable price. Let's say the item is buying/selling at the range of 140gp-160gp, but someone accidently typed 1500gp.

jelknab

2013-05-12 06:45:49

Yeah, sadly the prices aren't that accurate. I put the pricechecker in a script of mine and some of the fish are a little overpriced. , but other fish seem p. accurate.

Shatterhand

2013-05-12 06:50:32

Yea well its not that accurate, but better than nothing. :)

samerdl

2013-05-13 00:35:46

Very nice! Thank you!.

pescados666

2013-05-13 01:35:40

I was going to make something similar to this for my irc bot when the price guide first came out, then I noticed the price manipulation and thought it might be a better idea to work out a formula to grab all the buy/sell prices, remove outliers and then avg those for a more accurate market price.

Shatterhand

2013-05-13 04:00:56

From: pescados666
I was going to make something similar to this for my irc bot when the price guide first came out, then I noticed the price manipulation and thought it might be a better idea to work out a formula to grab all the buy/sell prices, remove outliers and then avg those for a more accurate market price.

Hmm. And how would you do that? What prices count as outliers? Like prices not between recent low and high? Or determining one price from the rest prices average +/- 10%, and mark as outlier if not in range?
I need ideas. :)

EDIT: Added new version. :)

mohammed49

2013-05-13 14:51:30

so how can i make it into a actual script for my clan chat?

mohammed49

2013-05-13 15:05:19

and i added this
program new;
{$Define Smart}
{$i srl/srl.simba}
function GetPrice(Item: String) : Integer;
var
str, templine, s1, s2 : String;
name, selling, quantity, price : String;
Lines, Names : Array[1..100] of String;
maxsamples, i, j,
buyquantity, sellquantity, buyvalue, sellvalue,
buyprice, sellprice: Integer;
match : Boolean;
begin
//last X offers
maxsamples := 50;

buyquantity := 0;
sellquantity := 0;
buyvalue := 0;
sellvalue := 0;

//getting page
str := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
str := Between('"offers":[', ']}]', str);
str := str + ',';

s1 := '{';
s2 := '},';

//getting lines
for i:=1 to maxsamples do
begin
templine := Between(s1, s2, str);
s1 := templine + '},{';
Lines := templine;
end;

//getting names, removing duplicates
for i:=1 to maxsamples do
begin
name := Between('"rs_name":"', '"', Lines);
match := False;
j := 1;
while ((j < i) and (match = False)) do
begin
if (name = Names[j]) then
match := True;
Inc(j);
end;
if (match = False) then
Names := name
else
Lines := '——————————– DELETED, NAME DUPLICATES ——————————–';
end;

//getting quantities, prices
for i:=1 to maxsamples do
begin
templine := Lines;
if not (templine = '') then
begin
selling := Between('"selling":"', '"', templine);
quantity := Between('"quantity":"', '"', templine);
price := Between('"price":"', '"', templine);

if (selling = '1') then
begin
sellvalue := sellvalue + StrToInt(quantity) * StrToInt(price);
sellquantity := sellquantity + StrToInt(quantity);
end;

if (selling = '0') then
begin
buyvalue := buyvalue + StrToInt(quantity) * StrToInt(price);
buyquantity := buyquantity + StrToInt(quantity);
end;
end;
end;

buyprice := buyvalue / buyquantity;
sellprice := sellvalue / sellquantity;
Result := (buyprice + sellprice) / 2;

//DEBUG
for i:=1 to maxsamples do
Writeln('[' + IntToStr(i) + '] ' + Lines);
Writeln('Buy: ' + IntToStr(buyprice));
Writeln('Sell: ' + IntToStr(sellprice));
end;
begin
end.


i know it's probabley 100% wrong i just started scripting can you help please?

Shatterhand

2013-05-13 15:08:20

From: mohammed49
i know it's probabley 100% wrong i just started scripting can you help please?

You have to call the function itself in the begin-end block at the bottom.

mohammed49

2013-05-13 15:14:16

to be honest i just started learning i can only make simple scripts such as typers and stuff can you explain it to me or help me make it i need it to tell the price in the clan chat when a player says !pc rune scimitar ect you know what im talking about?

mohammed49

2013-05-13 15:17:49

can you pm on how to make it or it i really dont wanna ask you to do it just a waste of time for you lol but help me out man :D

mohammed49

2013-05-13 15:34:13

i need it asap man can you please show me how? im sorry im just not that good at this kind of stuff :(

mohammed49

2013-05-13 15:39:58

this is what i came up with? still doesn't work
program new;
{$Define Smart}
{$i srl/srl.simba}
function GetPrice(Item: String) : Integer;
var
str, templine, s1, s2 : String;
name, selling, quantity, price : String;
Lines, Names : Array[1..100] of String;
maxsamples, i, j,
buyquantity, sellquantity, buyvalue, sellvalue,
buyprice, sellprice: Integer;
match : Boolean;
begin
//last X offers
maxsamples := 50;

buyquantity := 0;
sellquantity := 0;
buyvalue := 0;
sellvalue := 0;

//getting page
str := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
str := Between('"offers":[', ']}]', str);
str := str + ',';

s1 := '{';
s2 := '},';

//getting lines
for i:=1 to maxsamples do
begin
templine := Between(s1, s2, str);
s1 := templine + '},{';
Lines := templine;
end;

//getting names, removing duplicates
for i:=1 to maxsamples do
begin
name := Between('"rs_name":"', '"', Lines);
match := False;
j := 1;
while ((j < i) and (match = False)) do
begin
if (name = Names[j]) then
match := True;
Inc(j);
end;
if (match = False) then
Names := name
else
Lines := '——————————– DELETED, NAME DUPLICATES ——————————–';
end;

//getting quantities, prices
for i:=1 to maxsamples do
begin
templine := Lines;
if not (templine = '') then
begin
selling := Between('"selling":"', '"', templine);
quantity := Between('"quantity":"', '"', templine);
price := Between('"price":"', '"', templine);

if (selling = '1') then
begin
sellvalue := sellvalue + StrToInt(quantity) * StrToInt(price);
sellquantity := sellquantity + StrToInt(quantity);
end;

if (selling = '0') then
begin
buyvalue := buyvalue + StrToInt(quantity) * StrToInt(price);
buyquantity := buyquantity + StrToInt(quantity);
end;
end;
end;

buyprice := buyvalue / buyquantity;
sellprice := sellvalue / sellquantity;
Result := (buyprice + sellprice) / 2;

//DEBUG
for i:=1 to maxsamples do
Writeln('[' + IntToStr(i) + '] ' + Lines);
Writeln('Buy: ' + IntToStr(buyprice));
Writeln('Sell: ' + IntToStr(sellprice));
end;
begin
getprice;
end.
begin
end.

mohammed49

2013-05-13 15:43:54

latest thing i came up with it runs open runescape then stops
program new;
{$Define Smart}
{$i srl/srl.simba}
begin
setupSRL;
end.

procedure GetPrice(Item: String) : Integer;
var
str, templine, s1, s2 : String;
name, selling, quantity, price : String;
Lines, Names : Array[1..100] of String;
maxsamples, i, j,
buyquantity, sellquantity, buyvalue, sellvalue,
buyprice, sellprice: Integer;
match : Boolean;
begin
//last X offers
maxsamples := 50;

buyquantity := 0;
sellquantity := 0;
buyvalue := 0;
sellvalue := 0;

//getting page
str := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
str := Between('"offers":[', ']}]', str);
str := str + ',';

s1 := '{';
s2 := '},';

//getting lines
for i:=1 to maxsamples do
begin
templine := Between(s1, s2, str);
s1 := templine + '},{';
Lines := templine;
end;

//getting names, removing duplicates
for i:=1 to maxsamples do
begin
name := Between('"rs_name":"', '"', Lines);
match := False;
j := 1;
while ((j < i) and (match = False)) do
begin
if (name = Names[j]) then
match := True;
Inc(j);
end;
if (match = False) then
Names := name
else
Lines := '——————————– DELETED, NAME DUPLICATES ——————————–';
end;

//getting quantities, prices
for i:=1 to maxsamples do
begin
templine := Lines;
if not (templine = '') then
begin
selling := Between('"selling":"', '"', templine);
quantity := Between('"quantity":"', '"', templine);
price := Between('"price":"', '"', templine);

if (selling = '1') then
begin
sellvalue := sellvalue + StrToInt(quantity) * StrToInt(price);
sellquantity := sellquantity + StrToInt(quantity);
end;

if (selling = '0') then
begin
buyvalue := buyvalue + StrToInt(quantity) * StrToInt(price);
buyquantity := buyquantity + StrToInt(quantity);
end;
end;
end;

buyprice := buyvalue / buyquantity;
sellprice := sellvalue / sellquantity;
Result := (buyprice + sellprice) / 2;

//DEBUG
for i:=1 to maxsamples do
Writeln('[' + IntToStr(i) + '] ' + Lines);
Writeln('Buy: ' + IntToStr(buyprice));
Writeln('Sell: ' + IntToStr(sellprice));
end;
begin
function Getprice;
end.

jelknab

2013-05-13 16:00:18

Made you a pcer…


program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl[I] = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;
ActivateClient;

Start;
end.


mohammed49

2013-05-13 16:39:36

omfg if this works i love you :D!

mohammed49

2013-05-13 17:11:17

From: jelknab
Made you a pcer…


program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl[I] = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;
ActivateClient;

Start;
end.


i get this error
rror: Exception: Invalid float at line 12
help me anyone :(

jelknab

2013-05-13 17:34:25


program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
if (str = '') then exit;
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl[I] = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;
ActivateClient;

Start;
end.

mohammed49

2013-05-13 18:13:54

look what i need is a pc bot that works on command !price (item) and can speak in clan chat does this do it?

mohammed49

2013-05-14 16:17:11

How can i make it open eoc or sit in lobby and answer price checks

mohammed49

2013-05-17 20:39:51

can u make it open up eoc i dont want my 07 banned
From: jelknab

program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
if (str = '') then exit;
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl[I] = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;
ActivateClient;

Start;
end.

Haxz

2013-05-17 20:49:30

:cartman:Why would you want to check 07 item prices while you're on EoC?

mohammed49

2013-05-17 22:37:41

can u help me lol it's for my clan lol so my 07 accounts dont get banned 1 got muted when i used it on 07 lol can you please <3? :D!
From: Haxz
:cartman:Why would you want to check 07 item prices while you're on EoC?

mohammed49

2013-05-17 22:39:13

but can u make it i would love you forever :D
program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
if (str = '') then exit;
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;


Start;
end.
From: Haxz
:cartman:Why would you want to check 07 item prices while you're on EoC?

Shatterhand

2013-05-20 05:48:42

From: mohammed49
but can u make it i would love you forever :D

Use SIMBA tags. And no, sorry, Im not making EOC things.

mohammed49

2013-05-23 16:00:04

its not eoc i just need it to work on eoc :/

mohammed49

2013-05-23 16:06:03

i need it to open eoc and work on there man lol :/
From: Shatterhand
Use SIMBA tags. And no, sorry, Im not making EOC things.

San122

2013-05-24 08:56:22

I don't know how you could do this but, maybe to make the prices more accurate use the Inter quartile range (middle 50%). So it grabs all the prices then ignores the highest/lowest 25%.

Just an idea. :)

Shatterhand

2013-06-01 05:10:27

From: San122
I don't know how you could do this but, maybe to make the prices more accurate use the Inter quartile range (middle 50%). So it grabs all the prices then ignores the highest/lowest 25%.

Just an idea. :)

Thanks for your tip.

Updated the GetPrice function. It should be a lot more accurate.
Im working on a bank/inventory price checker, but currently having problems with reading potion names.

zachemicals

2013-06-11 19:11:38

Works great, thank you!

bob_dole

2013-06-12 12:22:36

Removing outliers you say?

Standard deviations? hello? statistics 101 here

Riylo69

2013-06-14 13:49:15

sweet

Peanuts

2013-06-14 14:30:00

Is there a way to altar this to work with http://www.grandexchangecentral.com/ …?

Because GEC is updated every few hours and is very accurate..

Kevin

2013-06-14 14:32:02

From: Peanuts
Is there a way to altar this to work with http://www.grandexchangecentral.com/ …?

Because GEC is updated every few hours and is very accurate..


It could easily be changed (or written from scratch) to work with any source so long as there is a simple manner URL or request side to guarantee you would access the desired item.

Shatterhand

2013-06-14 14:57:04

From: Peanuts
Is there a way to altar this to work with http://www.grandexchangecentral.com/ …?

Because GEC is updated every few hours and is very accurate..

That site is for EOC, why would you want to use that? You can use GetGEPrice for EOC. :)

Peanuts

2013-06-14 15:02:57

From: Shatterhand
That site is for EOC, why would you want to use that? You can use GetGEPrice for EOC. :)


Oh… My.. God….
Awesome!…
Well that was a good waste of time making a GetPrice function for eoc.. lol.

mohammed49

2013-07-18 19:59:59

ok so i need this to somehow say the highest price lowest price avrage and alch value

Le_don

2013-08-01 17:48:10

From: mohammed49
ok so i need this to somehow say the highest price lowest price avrage and alch value


Stop leaching and learn how to do it yourself.

Awkwardsaw

2013-08-01 18:35:47

cant you just read the average buy/ sell price that the page already gives you?

The Killer

2013-08-02 10:59:26

From: Awkwardsaw
cant you just read the average buy/ sell price that the page already gives you?


It does, but this way is fast and efficient :), good work by shatterhand tbh..

Shatterhand

2013-08-03 16:14:45

From: Awkwardsaw
cant you just read the average buy/ sell price that the page already gives you?

I made this function before those existed. :D

From: The Killer
It does, but this way is fast and efficient :), good work by shatterhand tbh..

Thanks.

Mehran

2013-08-05 09:56:01

Hey I'm trying to use you script for pcing in my cc but it won't work as it just says Pricechecked at 0 Gp I did change a bit of the script u had because it won't work on my simba ( I'm very new at this ) would love if you could take a look and see the issue.

program Pricechecker;
{$DEFINE SMART8}
{$I SRL/SRL.Simba}
var
LastT : string;

function GetPrice(Item: String) : Integer; // Made by Shatterhand, you're awesome! :)
var
str : String;
begin
str := Between('"average":"','"',GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item));
if (str = '') then exit;
Result := Round(StrToFloat(str));
end;

procedure Start;
var
I: integer;
T : string;
Expl : TStringArray;

begin
repeat
T := lowercase(GetChatBoxText(8, 128));
Expl := explode(' ', T)

for I:=0 to high(Expl) do
begin
if (Expl = '!pc') then
begin
T := replace(T, '!pc ', '');
T := replace(T, ' ', '+');

if not (T = LastT) then
begin
LastT := T;
writeLn(T)
TypeSend('/Pricechecked at ' + IntTostr(GetPrice(T)) + ' GP')
end;
end;
end;
until false;
end;

begin
SetUpsrl;
ActivateClient;

Start;
end.

tocxic1

2013-08-12 19:03:06

can you please help me?
1.- great job with the price checker
2.- i want to ask you a favour… would you change the script so the bot says [<items name>] pricechecked at: instead of just pricechecked at
3.- Thank you so much
Please i really need this script

neeger

2014-02-10 21:14:55

Oo really nice snippet :P
But what you do for some items, like 4 dose potions? http://forums.zybez.net/runescape-2007-prices/1487-energy-potion-4
Api not found: http://forums.zybez.net/runescape-2007-prices/api/energy_potion_4

Flight

2014-02-10 21:33:31

From: neeger
Oo really nice snippet :P
But what you do for some items, like 4 dose potions? http://forums.zybez.net/runescape-2007-prices/1487-energy-potion-4
Api not found: http://forums.zybez.net/runescape-2007-prices/api/energy_potion_4


Use this instead:
http://forums.zybez.net/runescape-2007-prices/api/energy_potion_(4)

The dosage, in this case '4', should be in parenthesis, exactly as the in-game item is.

neeger

2014-08-25 00:08:46

Hmm doesn't work anymore, something has changed in API?

Shatterhand

2014-08-28 21:27:14

From: neeger
Hmm doesn't work anymore, something has changed in API?

Yes.
http://forums.zybez.net/runescape-2007-prices/api/rune+axe
Note that the numbers arent in "…" anymore. "quantity":"40" is now "quantity":40
You gotta change the Between() lines. :)