Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Help with gumps detection repetition.

Ask for help
Post Reply
Hisered
Posts: 9
Joined: 02.06.2016 6:20

Help with gumps detection repetition.

Post by Hisered »

VerifyGump

Code: Select all

procedure verifygump;
var i,loop,loop2,cont : integer;
GumpLines : TStringList;
begin
  i := 0;
  cont := 0;
  While (i = 0) do //as 'i' is equal to '0'
  begin
    cont := cont + 1;
    if IsGump then //if Gump
    begin       
      GumpLines := TStringList.Create; // create a list.
      Wait(1000);
      loop := 0;
      For loop := 0 to GetGumpsCount-1 do //go through all active gumps.
      begin
        If (GetGumpSerial(loop) = SelfId) then //Gump is the loop position is equal to the serial character
        begin
          GetGumpfullLines(loop,GumpLines); //Add Gump all lines of the GumpLines
          for loop2 := 0 to GumpLines.Count-1 do //Will read and compare all lines added to GumpLines 
          begin
            If (GumpLines.Strings[loop2] = 'texto 1') or (GumpLines.Strings[loop2] = 'texto 2') then  // in the Gump has these two string
            begin
              ClientPrint(inttostr(loop1)+' '+GumpLines.Strings[loop2]);
              // i := i + 1; // Increments the variable I, Causing the while is deactivated.
              ClientPrint('successful'); // successful
              Repeat
                  Wait(100);
              Until Not IsGump;
            end;
          end;
        end;
      end;
    end;
    ClientPrint('Verificando... '+IntToStr(cont));
    Wait(5000); //security pause
  end;
end;
the problem is that after this script spends time running.
it stops working.
could someone please help me.


Some have solution?

I would like to also know what is the correct way to run more than one script at a time.

as closing the menu via script?
example: tracking menu.
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Help with gumps detection repetition.

Post by drabadan »

Hisered wrote:
VerifyGump

Code: Select all

procedure verifygump;
var i,loop,loop2,cont : integer;
GumpLines : TStringList;
begin
  i := 0;
  cont := 0;
  While (i = 0) do //as 'i' is equal to '0'
  begin
    cont := cont + 1;
    if IsGump then //if Gump
    begin       
      GumpLines := TStringList.Create; // create a list.
      Wait(1000);
      loop := 0;
      For loop := 0 to GetGumpsCount-1 do //go through all active gumps.
      begin
        If (GetGumpSerial(loop) = SelfId) then //Gump is the loop position is equal to the serial character
        begin
          GetGumpfullLines(loop,GumpLines); //Add Gump all lines of the GumpLines
          for loop2 := 0 to GumpLines.Count-1 do //Will read and compare all lines added to GumpLines 
          begin
            If (GumpLines.Strings[loop2] = 'texto 1') or (GumpLines.Strings[loop2] = 'texto 2') then  // in the Gump has these two string
            begin
              ClientPrint(inttostr(loop1)+' '+GumpLines.Strings[loop2]);
              // i := i + 1; // Increments the variable I, Causing the while is deactivated.
              ClientPrint('successful'); // successful
              Repeat
                  Wait(100);
              Until Not IsGump;
            end;
          end;
        end;
      end;
    end;
    ClientPrint('Verificando... '+IntToStr(cont));
    Wait(5000); //security pause
  end;
end;
the problem is that after this script spends time running.
it stops working.
could someone please help me.


Some have solution?

I would like to also know what is the correct way to run more than one script at a time.

as closing the menu via script?
example: tracking menu.
u should free the TStringList object...

And can't you use just events?
it's much more simpler.
Try to avoid using more than 1 script at the moment.
Hisered
Posts: 9
Joined: 02.06.2016 6:20

Re: Help with gumps detection repetition.

Post by Hisered »

drabadan wrote: u should free the TStringList object...

And can't you use just events?
it's much more simpler.
Try to avoid using more than 1 script at the moment.
1. you could give an example of the release of TStringList object please
2. you could give an example of how to use events please
3. I will try

thank you!
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Help with gumps detection repetition.

Post by Vizit0r »

1. you could give an example of the release of TStringList object please

Code: Select all

procedure verifygump;
var i,loop,loop2,cont : integer;
GumpLines : TStringList;
begin
  i := 0;
  cont := 0;
  GumpLines := TStringList.Create; // create a list.

  While (i = 0) do //as 'i' is equal to '0'
  begin
    ....
  end;
  GumpLines.Free;
end;
2. you could give an example of how to use events please

Code: Select all

procedure OnGumpIncoming(Serial, GumpID, X, Y: Cardinal);
begin
AddToSystemJournal('hey guys, we have a new gump here!');
end;

begin
SetEventProc(evIncomingGump, 'OnGumpIncoming');
while true do wait(1000);//infinite cycle, otherwise if script stop - event cant be executed.
end.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Hisered
Posts: 9
Joined: 02.06.2016 6:20

Re: Help with gumps detection repetition.

Post by Hisered »

I ended up making the code from scratch !.
Amazingly it worked !.
I can not explain why tava not working before.!
Post Reply