PDA

View Full Version : GetPrice



Shatterhand
05-12-2013, 09:19 AM
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
05-12-2013, 09:20 AM
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
05-12-2013, 09:21 AM
This could be useful for getting gp/hr on scripts :P

jelknab
05-12-2013, 10:04 AM
This is going in my fishing script :). Will credit you. This is awesome!

Haxz
05-12-2013, 10:35 AM
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
05-12-2013, 10:45 AM
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. http://puu.sh/2RRVX.jpg , but other fish seem p. accurate.

Shatterhand
05-12-2013, 10:50 AM
Yea well its not that accurate, but better than nothing. :)

samerdl
05-13-2013, 04:35 AM
Very nice! Thank you!.

pescados666
05-13-2013, 05:35 AM
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
05-13-2013, 08:00 AM
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
05-13-2013, 06:51 PM
so how can i make it into a actual script for my clan chat?

mohammed49
05-13-2013, 07:05 PM
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[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;

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

//DEBUG
for i:=1 to maxsamples do
Writeln('[' + IntToStr(i) + '] ' + Lines[i]);
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
05-13-2013, 07:08 PM
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
05-13-2013, 07:14 PM
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
05-13-2013, 07:17 PM
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
05-13-2013, 07:34 PM
i need it asap man can you please show me how? im sorry im just not that good at this kind of stuff :(

mohammed49
05-13-2013, 07:39 PM
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[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;

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

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

mohammed49
05-13-2013, 07:43 PM
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[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;

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

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

jelknab
05-13-2013, 08:00 PM
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.


http://puu.sh/2SOWG.jpg

mohammed49
05-13-2013, 08:39 PM
omfg if this works i love you :D!

mohammed49
05-13-2013, 09:11 PM
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.


http://puu.sh/2SOWG.jpg
i get this error
rror: Exception: Invalid float at line 12
help me anyone :(

jelknab
05-13-2013, 09:34 PM
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
05-13-2013, 10:13 PM
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
05-14-2013, 08:17 PM
How can i make it open eoc or sit in lobby and answer price checks

mohammed49
05-18-2013, 12:39 AM
can u make it open up eoc i dont want my 07 banned


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
05-18-2013, 12:49 AM
:cartman:Why would you want to check 07 item prices while you're on EoC?

mohammed49
05-18-2013, 02:37 AM
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!

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

mohammed49
05-18-2013, 02:39 AM
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[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;


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

Shatterhand
05-20-2013, 09:48 AM
but can u make it i would love you forever :D
Use SIMBA tags. And no, sorry, Im not making EOC things.

mohammed49
05-23-2013, 08:00 PM
its not eoc i just need it to work on eoc :/

mohammed49
05-23-2013, 08:06 PM
i need it to open eoc and work on there man lol :/

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

San122
05-24-2013, 12:56 PM
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
06-01-2013, 09:10 AM
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
06-11-2013, 11:11 PM
Works great, thank you!

bob_dole
06-12-2013, 04:22 PM
Removing outliers you say?

Standard deviations? hello? statistics 101 here

Riylo69
06-14-2013, 05:49 PM
sweet

Peanuts
06-14-2013, 06:30 PM
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
06-14-2013, 06:32 PM
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
06-14-2013, 06:57 PM
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
06-14-2013, 07:02 PM
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
07-18-2013, 11:59 PM
ok so i need this to somehow say the highest price lowest price avrage and alch value

Le_don
08-01-2013, 09:48 PM
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
08-01-2013, 10:35 PM
cant you just read the average buy/ sell price that the page already gives you?

The Killer
08-02-2013, 02:59 PM
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
08-03-2013, 08:14 PM
cant you just read the average buy/ sell price that the page already gives you?
I made this function before those existed. :D


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

Mehran
08-05-2013, 01:56 PM
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[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.

tocxic1
08-12-2013, 11:03 PM
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
02-11-2014, 02:14 AM
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
02-11-2014, 02:33 AM
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
08-25-2014, 04:08 AM
Hmm doesn't work anymore, something has changed in API?

Shatterhand
08-29-2014, 01:27 AM
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. :)