Page 1 of 2

Out of Range

Posted: 27.01.2014 23:33
by Half-Life
Доброго времени суток. Есть процедура

Code: Select all

procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
  if Dead or not Connected then Exit;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  UseObject(BOD);
  Wait(WaitTime);
  CheckLag(WaitLag);
  If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
  GetGumpInfo(GetGumpsCount-1, gumpInfo); 
  CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
  if CountOfString = 0 then GetBODInfo;
  Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка
  Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
  Amount:=Amount-Count;
  Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
  if (Amount=0) then begin
    MoveItem(BOD,1,BulkDestination,0,0,0);
    Wait(WaitTime);
    CheckLag(WaitLag);
    while IsGump do CloseSimpleGump(GetGumpsCount-1);
    AddToSystemJournal('Бод '+Item+' выполнен');
    SalvageItems;
    SearchBOD;
  end;
  AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
  Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
  If Exep='All items must be exceptional.' then Exceptional:=True;
  if CountOfString>7 then begin
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with spined leather.' then Spined:=True;
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with horned leather.' then Horned:=True;
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with barbed leather.' then Barbed:=True;
  end;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  Wait(250);
end;
и на один из пяти десяти раз выдаёт ошибку - Exec: [Error] at (131:3): Out Of Range
что не так?

Re: Out of Range

Posted: 28.01.2014 0:50
by Vizit0r
Half-Life wrote:что не так?
версия стелса не так.
скачай последнюю.

Re: Out of Range

Posted: 28.01.2014 2:51
by Half-Life
Vizit0r wrote: версия стелса не так.
скачай последнюю.
Версия 6.2.1

Re: Out of Range

Posted: 28.01.2014 2:58
by Vizit0r
тогда 131 строку в студию

Re: Out of Range

Posted: 28.01.2014 3:45
by Half-Life
В первом посте она указана.

Re: Out of Range

Posted: 28.01.2014 9:04
by drabadan
Half-Life wrote:В первом посте она указана.
Так объясни как ее найти...
раззул глаза и увидел...

добавь задержечку небольшую перед строкой, посмотри если повторяется...

Re: Out of Range

Posted: 28.01.2014 10:55
by Vizit0r
Half-Life wrote:В первом посте она указана.
играть в угадайку не буду, подожду пока ты укажешь точную строку.

Re: Out of Range

Posted: 28.01.2014 14:43
by drabadan
Vizit0r wrote:
Half-Life wrote:В первом посте она указана.
играть в угадайку не буду, подожду пока ты укажешь точную строку.
а я вот, тоже такой думал... а там коммент есть соответствующий =)

Re: Out of Range

Posted: 29.01.2014 13:16
by Half-Life
procedure GetBODInfo(Старая)
procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
if Dead or not Connected then Exit;
While IsGump do CloseSimpleGump(GetGumpsCount-1);
UseObject(BOD);
Wait(WaitTime);
CheckLag(WaitLag);
If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
GetGumpInfo(GetGumpsCount-1, gumpInfo);
CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
if CountOfString = 0 then GetBODInfo;
Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка
Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
Amount:=Amount-Count;
Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
if (Amount=0) then begin
MoveItem(BOD,1,BulkDestination,0,0,0);
Wait(WaitTime);
CheckLag(WaitLag);
while IsGump do CloseSimpleGump(GetGumpsCount-1);
AddToSystemJournal('Бод '+Item+' выполнен');
SalvageItems;
SearchBOD;
end;
AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
If Exep='All items must be exceptional.' then Exceptional:=True;
if CountOfString>7 then begin
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with spined leather.' then Spined:=True;
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with horned leather.' then Horned:=True;
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with barbed leather.' then Barbed:=True;
end;
While IsGump do CloseSimpleGump(GetGumpsCount-1);
Wait(250);
end;
Переделал процедуру таким вот образом. Вроде больше не выскакивает сия ошибка.
Но всё равно интересно откуда этот баг вылазит.
Кстати задержка не помогала. Ни задержка ни проверка на лаг, гамп.
procedure GetBODInfo(Новая)

Code: Select all

procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
  if Dead or not Connected then Exit;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  UseObject(BOD);
  Wait(WaitTime);
  CheckLag(WaitLag);
  If GetGumpID(GetGumpsCount-1)=$5AFBD742 then begin
    GetGumpInfo(GetGumpsCount-1, gumpInfo);
    Wait(WaitTime);
    CheckLag(WaitLag);
    CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
    Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]);
    Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
    Amount:=Amount-Count;
    Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
    if (Amount=0) then begin
      MoveItem(BOD,1,BulkDestination,0,0,0);
      Wait(WaitTime);
      CheckLag(WaitLag);
      while IsGump do CloseSimpleGump(GetGumpsCount-1);
      AddToSystemJournal('Бод '+Item+' выполнен');
      SalvageItems;
      SearchBOD;
    end;
    AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
    Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
    If Exep='All items must be exceptional.' then Exceptional:=True;
    if CountOfString>7 then begin
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with spined leather.' then Spined:=True;
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with horned leather.' then Horned:=True;
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with barbed leather.' then Barbed:=True;
    end;
    While IsGump do CloseSimpleGump(GetGumpsCount-1);
    Wait(500);
    Exit;
  end;
  GetBODInfo;
end;

Re: Out of Range

Posted: 29.01.2014 13:56
by Half-Life
Ещё такой вопрос. Как можно узнать открыт ли банк или нет?

Re: Out of Range

Posted: 29.01.2014 15:36
by drabadan
Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
welcome to my world...

Пиши дллку на основе OCR... Закрывай все сундуки, и распознавай сундучек банка дллкой, експортировав из нее состояние банка.

Re: Out of Range

Posted: 29.01.2014 15:40
by Vizit0r
Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
запоминаешь LastContainer, орешь банк, ждешь изменения LAstContainer.

Re: Out of Range

Posted: 29.01.2014 15:42
by Vizit0r
Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка

ни одной проверки, а есть ли вообще нужный элемент в массиве - вот и обращаешься к несуществующему элементу.

Re: Out of Range

Posted: 29.01.2014 15:51
by drabadan
Vizit0r wrote:
Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
запоминаешь LastContainer, орешь банк, ждешь изменения LAstContainer.
а если ластконтейнер и был банк?

тут проблема как уловить момент, что банк закрыт. То-есть открыть его и сравнить проблем нету...

Code: Select all

Program New;

begin
if LastContainer = ObjAtLayer(BankLayer) then
    ClientPrint('There is spoon!')
else
    ClientPrint('There is no spoon!');
end.
но когда при работе, он потом закрывается, то ластконтэинер все равно помнит банк...

Re: Out of Range

Posted: 29.01.2014 17:03
by Half-Life
Vizit0r wrote:Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка

ни одной проверки, а есть ли вообще нужный элемент в массиве - вот и обращаешься к несуществующему элементу.
стоп стоп стоп
If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
GetGumpInfo(GetGumpsCount-1, gumpInfo);
CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
if CountOfString = 0 then GetBODInfo;

как ещё можно проверить?