Contador de Item


const
ItemName = 'Gold Coins'; //nome do item, coloque no plural
ItemNumber = 3031; //ItemID

var
seconds, min, mini, hours, count, item, AverageItem, total: integer;
hourText,minText,secText: string;

function CountItemAmountFromOpenBackpack(ID: integer): integer;
var
x: integer;
y: integer;
begin
Result := 0;
for x := 0 to Self.Containers.Count - 1 do
begin
if x >= Self.Containers.Count then Break;
for y := 0 to Self.Containers.Container[x].Count - 1 do begin
if y >= Self.Containers.Container[x].Count then Break;
if Self.Containers.Container[x].Item[y].ID = ID then begin
Result := Result + Self.Containers.Container[x].Item[y].Amount;
end;
end;
end;
end;

begin
UpdateWorld;
AverageItem := 0;
item := CountItemAmountFromOpenBackpack(ItemNumber);
count := 0;
seconds := 0;
min := 0;
hours := 0;
while not terminated do
begin
sleep(1000);
UpdateWorld;
count := count+1;
Seconds := count mod 60;
if count>=60 then min := count div 60;
mini := min mod 60;
if min>=60 then Hours := min div 60;
total := (CountItemAmountFromOpenBackpack(ItemNumber)-Item);
AverageItem := total/count*60*60;
HourText := IntToStr(Hours);
MinsText := IntToStr(mini);
SecText := IntToStr(seconds);
if Length(HourText) = 1 then HourText := '0' + HourText;
if Length(MinsText) = 1 then MinsText := '0' + MinsText;
if Length(SecText) = 1 then SecText := '0' + SecText;
self.displayText('Running for '+HourText+':'+MinsText+':'+SecText+' | '+ItemName+' collected: '+inttostr(total)+' | '+ItemName+' average/h: '+inttostr(AverageItem)+'.');
ProcessEvents;
end;
end;