Results 1 to 7 of 7

Thread: Help

  1. #1
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Help

    I want this form to do one of the following:
    • constantly run Update;
    • when the mouse moves run Update;
    • when the uptext changes run Update;

    SCAR Code:
    program New;
    var
      EndForm : Boolean;
      frmDesign : TForm;
      Label1 : TLabel;
     
    Function Username:String;
    begin
      Result:= Between('Walk here ', '(level-', rs_GetUpText);
    end;

    Procedure Update;
    Var
      UN, S:String;
      I:Integer;
      TSA:TStringArray;
    begin
      UN:=Username;
      Label1.Caption:='Username:'+UN;
      For I:=1 to 5 do
      begin
        S:=GetPage('http://hiscore.runescape.com/overall.ws?table='+IntToStr(I)+'&user='+UN);
        S:= Between(UN+'</a></td>', '/td>', s)
        TSA[I-1]:=Between('<td class="alL ARow">', '<', S)
      end;
      Label1.Caption:='Username:'+UN+' Attack:'+TSA[0]+' Defence:'+TSA[1]+' Strength:'+TSA[2]+' Hitpoints:'+TSA[3]+' Ranged:'+TSA[4]+' Prayer:'+TSA[5]+' Magic:'+TSA[6];
    end;

    procedure FormOnClose(Sender : TObject; var Action : TCloseAction);
    begin
      if (not(frmDesign.ModalResult = 1)) then
        EndForm := True;
    end;

    procedure Form;
    begin
      frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @FormOnClose;
        FormStyle := fsStayOnTop;
        Left := 250;
        Top := 114;
        Width := 386;
        Height := 53;
        Caption := '';
        Color := clBtnFace;
        Font.Color := clWindowText;
        Font.Height := -11;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
        PixelsPerInch := 96;
      end;
      Label1 := TLabel.Create(frmDesign);
      with Label1 do
      begin
        Parent := frmDesign;
        Left := 0;
        Top := 0;
        Width := 3;
        Height := 13;
      end;
    end;

    procedure SafeForm;
    var
      V : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('Form', V);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      V : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('ShowFormModal', V);
    end;

    procedure MainForm;
    begin
      SafeForm;
      SafeShowFormModal;
      FreeForm(frmDesign);
    end;

    begin
      ClearDebug;
      GetSelf.WindowState := wsMinimized;
      MainForm;
      GetSelf.WindowState := wsNormal;
      if (EndForm) then
        TerminateScript;
    end.

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Make a timer and make it fire as often as needed (every 100ms would be good I would say) and just make it check if the username has changed and if so then run update and it should work fine, though may be laggy if the timer is set off too fast.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Before I go and try, use Ctrl + Space and see if you can find any useful booleans etc from frmdesign.

    I will look myself.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    1. constantly run Update;
    2. when the mouse moves run Update;
    3. when the uptext changes run Update;

    1. Use a TTimer, like mixster said
    2. in the OnTimer event, get the new position of the mouse, and check it against the old position (which you will save at the end of the OnTimer procedure)
    3. Check this in the OnTimer event also.

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    program New;
    var
      EndForm : Boolean;
      frmDesign : TForm;
      Label1 : TLabel;

    Function Username:String;
    begin
      Result:= Between('Walk here ', '(level-', rs_GetUpText);
    end;

    Procedure UpdateUser(Sender : TObject);
    Var
      UN, S, OUN:String;
      I:Integer;
      TSA:TStringArray;
    begin
      repeat
        Wait(200);
        if OUN = Username then continue;
        UN:=Username;
        OUN := UN;
        Label1.Caption:='Username:'+UN;
        For I:=1 to 5 do
        begin
          S:=GetPage('http://hiscore.runescape.com/overall.ws?table='+IntToStr(I)+'&user='+UN);
          S:= Between(UN+'</a></td>', '/td>', s)
          TSA[I-1]:=Between('<td class="alL ARow">', '<', S)
        end;
        Label1.Caption:='Username:'+UN+' Attack:'+TSA[0]+' Defence:'+TSA[1]+' Strength:'+TSA[2]+' Hitpoints:'+TSA[3]+' Ranged:'+TSA[4]+' Prayer:'+TSA[5]+' Magic:'+TSA[6];

      until false;
    end;

    procedure FormOnClose(Sender : TObject; var Action : TCloseAction);
    begin
      if (not(frmDesign.ModalResult = 1)) then
        EndForm := True;
    end;

    procedure Form;
    begin
      frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @FormOnClose;
        FormStyle := fsStayOnTop;
        Left := 250;
        Top := 114;
        Width := 386;
        Height := 53;
        Caption := '';
        Color := clBtnFace;
        Font.Color := clWindowText;
        Font.Height := -11;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
        PixelsPerInch := 96;
        OnActivate := @UpdateUser;
      end;
      Label1 := TLabel.Create(frmDesign);
      with Label1 do
      begin
        Parent := frmDesign;
        Left := 0;
        Top := 0;
        Width := 3;
        Height := 13;
      end;
    end;

    procedure SafeForm;
    var
      V : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('Form', V);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      V : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('ShowFormModal', V);
    end;

    procedure MainForm;
    begin
      SafeForm;
      SafeShowFormModal;
      FreeForm(frmDesign);
    end;

    begin
      ClearDebug;
      GetSelf.WindowState := wsMinimized;
      MainForm;
      GetSelf.WindowState := wsNormal;
      if (EndForm) then
        TerminateScript;
    end.

    That Might work. MIGHT!

    when the client is activated, it will update the label, then, when the updating is done, it waits 200 ms and does it again. Crude, but SHOULD work. Its also an infinite loop but yeah... Also, I added a failsafe so it will check if the username has changed. if it hasn't then it wont redo it.

    Suggestion:

    Make an array of labels and update them that way, will make the form look nicer.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  6. #6
    Join Date
    Nov 2006
    Location
    'Pergamino, BA, Argentina';
    Posts
    473
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    SCAR Code:
    Function Username:String;
    begin
      Result:= Between('Walk here ', '(level-', rs_GetUpText);
    end;

    you might want to change that to something like this, because sometimes the text before the username is not Walk here:

    SCAR Code:
    Function GetUsername:String;
    begin
      if IsUpText('ere') then Result:= Between('here ', '(lev', rs_GetUpText);
      if IsUpText('ight') then Result:= Between('ight ', '(lev', rs_GetUpText);
      if IsUpText('tack') then Result:= Between('tack ', '(lev', rs_GetUpText);
    end;

    Idk, just a thought. Btw thats what i use in my hp above heads script, well similar.

  7. #7
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Actually, you can try using just ShowForm, instead of modal.

    This results in the Form being in a separate thread, and therefore, you can "continue" on with the rest of the script. And the rest of the script would be your loop that checks when the mouse moves, if the UpText changes, etc.

    Of course, it's kinda buggy...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •