Da 0wner
2009-05-25 12:03:43
Gets the inventory of the player :D.
It's pretty noob right now :(. I suck at Reflection, just started learning it :p.
Returns it in a TStringArray.
It detects duplicate items, i.e you have 28 shrimps it will get the first shrimp and detect all the other ones and set them to shrimp without getting the page (to make it faster).
It also attempts to get the name of items not in the Grand Exchange database (mime gloves, etc.).
That might fail though. I'm sure this can be shortened by a lot but really I am noob at Reflection :p.
It's pretty noob right now :(. I suck at Reflection, just started learning it :p.
function GetInventory : TStringArray;
var
i, ii, iii, h, hh, Inv : integer;
s : string;
Box : TBox;
IDs : TIntegerArray;
begin
Inv := GetInterface(149, 0);
for i := 0 to 28 do
begin
h := GetArrayLength(IDs) + 1;
SetArrayLength(IDs, h);
IDs[i] := SmartGetFieldArrayInt(Inv, InventoryItemIDs, i);
if IDs[i] = 0 then
Continue;
hh := GetArrayLength(Result) + 1;
SetArrayLength(Result, hh);
if h <> 1 then
begin
for ii := 0 to high(IDs) do
begin
if IDs[h - 1] = IDs[h - 2] then
begin
Result[hh - 1] := Result[hh - 2];
iii := 1;
break;
end;
end;
end;
if iii = 1 then
begin
iii := 0;
Continue;
end;
s := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj=' + IntToStr(IDs[i] - 1));
Result[hh - 1] := between('<div class="subsectionHeader">' + chr(10), '</div>', s);
delete(Result[hh - 1], pos(chr(10), Result[hh - 1]), 1);
if Result[hh - 1] = '' then
begin
if i + 1 = 29 then
MMouseItem(28)
else
MMouseItem(i + 1);
Wait(150 + random(150));
Result[hh - 1] := between(' ', ' /', GetUpText);
end;
end;
SmartFreeObject(Inv);
h := high(result) - 1;
Writeln('There are ' + IntToStr(h + 1) + ' items in your inventory.');
for i := 0 to h do
Writeln('Inventory slot ' + IntToStr(i) + ' contains ' + Result[i] + '.');
end;Returns it in a TStringArray.
It detects duplicate items, i.e you have 28 shrimps it will get the first shrimp and detect all the other ones and set them to shrimp without getting the page (to make it faster).
It also attempts to get the name of items not in the Grand Exchange database (mime gloves, etc.).
That might fail though. I'm sure this can be shortened by a lot but really I am noob at Reflection :p.