Yeah that's possible if you create a new type in the script which will store the item data. Give me a few minutes and I'll see what I can come up with.
Try this on for size:
Simba Code:
program Pricechecker;
{$DEFINE SMART}
{$I SRL-OSR/SRL.Simba}
Type T07Item = record
Name : String;
ID,Average,RecentLow,
RecentHigh,AlchPrice : Integer;
end;
var
LastT : string;
// By Flight
function getItem(Item: String): T07ITem;
var
fullS,s1,s2: String;
begin
Result.ID := 0;
fullS := GetPage('http://forums.zybez.net/runescape-2007-prices/api/' + Item);
if (Pos('"error"', fullS) > 0) then
Exit;
Result.Name := capitalize(Item);
Result.ID := Round(StrToInt(between('"id":"', '"', fullS)));
Result.Average := Round(StrToFloat(between('age":"', '"', fullS)));
Result.RecentHigh := Round(StrToFloat(between('t_high":"', '"', fullS)));
Result.RecentLow := Round(StrToFloat(between('t_low":"', '"', fullS)));
Result.AlchPrice := Round(StrToFloat(between('lch":"', '"', fullS)));
end;
procedure start();
var
T,S : String;
I : Integer;
item: T07Item;
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);
item := getItem(T);
if (item.ID > 0) then
TypeSend('/'+item.Name+': '+intToStr(item.Average))
else
begin
writeln('Incorrect item');
TypeSend('/Incorrect Item');
end;
end;
end else if (Expl[I] = '!full') then
begin
T := replace(T, '!full ', '');
T := replace(T, ' ', '_');
if not (T = LastT) then
begin
LastT := T;
writeLn(T);
item := getItem(T);
if (item.ID > 0) then
begin
S := toStr(item);
TypeSend('/'+S);
end else
begin
writeln('Incorrect item');
TypeSend('/Incorrect Item');
end;
end;
end;
end;
until false;
end;
begin
setupSRL();
activateClient();
start();
end.
Type "!pc (item name)" for getting the average price only. Type "!full (item name)" for getting all the data of an item (Name, ID, average price, recent high, recent low, high alch value). For example, if you did "!full raw monkfish" this is what you would get:
Code:
"{'Raw_monkfish', 3889, 415, 415, 414, 138}"
...assuming my code above is correct.