SRL Archive - Reflection Help

stacksize from item on bank


fre

2011-08-08 22:39:04

Hey all, it is pretty late, i have been searching for this solution for the last 2 hours.

Can't seem to find anything solid.

I am searching for a function that returns the highest value of a specified item in your bank

eg:
i have 1200 iron ores, 300 coal ores, 500 mithril ores:
it should give: iron and mith ores


Function HighestAmmountItemStackSize(items: TBankItemArray): TBankItem
[\code]


And i actually need the 2 items with the biggest stack size.
But that i can do by just letting the function run again but use ClearTPAfromTPA or some other minor adjustment.


~Fre

Brandon

2011-08-09 01:04:20

First I believe there is a function that dumps all bank items into an array then u can sort them by highest stacksize.. but uhh I don't have simba installed atm so I can't check (Formatted my computer)..

I believe U mean something like:

Function HighestStack(Items: TBankItemArray): TBankItem;
var
item: TBankItem;
i, x, Stop: Integer;

begin
Stop:= 0;

For I:= High(Items[x].StackSize) DownTo 0 do
begin
writeln(ToStr(Items[x].Name) + ToStr(Items[x].StackSize));
Stop:= Stop + 1;
If(Stop >= 2) then
break;
end;

end;
Something like that.. Well thats my pseudo code. I'll go install simba and check back after I get everything installed and see if i can help u write something… but thats the idea.

KingKong

2011-08-09 01:11:56

This might work, try it:

procedure displayhigheststack;
var
items: TBankItemArray;
a: Integer;
item1, item2: TBankItem;
begin
items := R_GetAllBankItems;
for a:= 0 to high(items) do
begin
if items[a].StackSize > item1.StackSize then
item1 := items[a]
else
if items[a].StackSize > item2.StackSize then
item2 := items[a];
end;
writeln(item1);
writeln(item2);
end;

fre

2011-08-09 06:09:42

Ty it works, and i use this to filter the items it need to search for.
[php]
procedure displayhigheststack;
var
items, capes: TBankItemArray;
a, i: Integer;
item1, item2: TBankItem;
begin
items := R_GetAllBankItems;
for i:= 0 to high(items) do
begin
if (items.name = 'Item1') or (items.name = 'Item2') or (items.name = 'Item3') or (items.name = 'Item4') or (items.name = 'Item5') then
if items.StackSize > item1.StackSize then
item1 := items
else
if (items.name = 'Item1') or (items.name = 'Item2') or (items.name = 'Item3') or (items.name = 'Item4') or (items.name = 'Item5') then
if items.StackSize > item2.StackSize then
item2 := items;
end;
writeln(item1);
writeln(item2);
end;
[/php]