Results 1 to 5 of 5

Thread: TForm - TComboBox

  1. #1
    Join Date
    May 2012
    Posts
    60
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default TForm - TComboBox

    SOLVED

    I'm having problems using TComboBox in my auto curser.
    I've added a second location and want to have a drop-down menu to pick which npc to curse.




    What I want to do, is run the procedure CastCurseMonk if that option is selected, and the procedure CastCurseSkeleton if that's selected.


    I had a look at rjj95's fletching script and tried using it below, but without any success. I think I might be needing something in the mainloop?

    Simba Code:
    Program TheAutoCurser;

    {$DEFINE SMART}
    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}

    (********************************************************)
    (*           TheAutoCurser - Made by Sequence           *)
    (********************************************************)
    (*      1. Specify how many casts you want to do.       *)
    (*      2. Start the script, and enter login info       *)
    (*      3. Be sure to stand at the Monk of Zamorak      *)
    (*         in the cage at Varrock Castle                *)
    (********************************************************)

    var
      x, y, MonkColor, SkeletonColor1, SkeletonColor2, Casts, I : Integer;
      CastsDone, CastsPerHour, TimeGone : Integer;
      DsgnForm : TForm;
      Username, Password, CurseCasts : TEdit;
      StartBtn : TButton;
      NPCCombo : TComboBox;
      SelectNPC : String;

    const
      ScriptVersionNumber = '1.21';
      default = 'Calibri';

    procedure DTM;
    begin
      Casts := 2000; //Change to specify how many casts you want to do.
      MonkColor := 3488916;
      SkeletonColor1 := 8885140;
      SkeletonColor2 := 9804448;
    end;

    procedure LogOutPlayer;
    begin
    P07_TabInventoryTab(11);
    Wait(RandomRange(400, 700));
    P07_MouseBox(575, 362, 706, 388, mouse_left);
    TerminateScript;
    end;

    procedure ProgressReport;
    begin
      ClearDebug;
      TimeGone := (GetTimeRunning/1000);
      CastsPerHour :=(3600*(CastsDone))/((TimeGone));
      begin
        Writeln('********************************************************');
        Writeln('            TheAutoCurser - Made by Sequence            ');
        Writeln('********************************************************');
        Writeln('              Time running: ' + MsToTime((GetTimeRunning), Time_Short));
        Writeln('                     Casts: ' + IntToStr(CastsDone) + ' ');
        Writeln('                 Casts p/h: ' + IntToStr(CastsPerHour) + ' ');
        Writeln('********************************************************');
      end;
    end;

    procedure CheckFriends;
    begin
    P07_TabInventoryTab(9);
    Wait(RandomRange(300, 500));
    MMouse(RandomRange(X - 10, X + 10), RandomRange(y - 10, y + 10), 0, 0);
    Wait(RandomRange(2000, 3000));
    end;

    procedure CheckInventory;
    begin
    P07_TabInventoryTab(4);
    Wait(RandomRange(200, 600));
    end;

    Function AntiBan : Boolean;
    begin
      case random(300) of
      0: P07_HoverSkill('magic', random(5000));
      1: P07_MakeCompassDegree(RandomRange(140, 170));
      2: P07_MakeCompassDegree(RandomRange(190, 220));
      3: MMouse(random(650), random(350), 0, 0);
      4: CheckInventory;
      5: CheckFriends;
      end;
    end;

    procedure CastCurseMonk;
    begin
      case LowerCase(SelectNPC) of
        'monk':
          begin
          repeat
            If (Not FindColorSpiralTolerance(x, y, MonkColor, 176, 84, 393, 320, 20)) then
            LogOutPlayer
            else begin
              P07_MakeCompassEast;
              P07_MakeCameraAngleHigh;
              Wait(RandomRange(200, 350));
              P07_CastSpell(12);
              Wait(RandomRange(900, 1100));
              MMouse(RandomRange(X - 3, X + 3), RandomRange(y - 3, y + 3), 0, 0);
              ClickMouse2(mouse_left);
              ProgressReport;
              AntiBan;
              Inc(CastsDone);
            end;
          Until(I = Casts);
        end;
      end;
    end;

    procedure CastCurseSkeleton;
    begin
      case LowerCase(SelectNPC) of
        'skeleton':
          begin
          repeat
            P07_MakeCompassDegree(20);
            P07_MakeCameraAngleLow;
              begin
              Wait(RandomRange(200, 350));
              P07_CastSpell(12);
              Wait(randomRange(500, 700));
              if P07_FindObjCustom(x, y, ['Skeleton', 'Ske', 'ton', 'Skelet', 'leton'], [SkeletonColor1, SkeletonColor2], 14) then
                begin
                  ClickMouse2(mouse_left);
                  Wait(RandomRange(400, 600));
                  Inc(CastsDone);
                end
                else
                  begin
                    Wait(RandomRange(1034, 1503));
                    if (Not P07_FindObjCustom(x, y, ['Skeleton', 'Ske', 'ton', 'Skelet', 'leton'], [8885140, 9804448], 14)) then
                    WriteLn('NPC Not found, terminating script...');
                    Wait(RandomRange(100, 300));
                    Mouse(992, 293, random(5), random(5), true);
                    Wait(RandomRange(500, 1000));
                    LogOutPlayer;
                    Wait(RandomRange(500, 1000));
                    TerminateScript;
                  end;
                end;
              ProgressReport;
              AntiBan;
              Inc(I);
            until(I = Casts);
          end;
        end;
      end;

    procedure AutoUpdateScript;
    var
        NewFile : Integer;
        OnlineVersion, NewScript, NewFileName : String;
    begin
      begin
        Writeln('Checking TheAutoCurser VersionNumber');
        OnlineVersion := GetPage('http://07scape-theautocurser.googlecode.com/svn/trunk/TheAutoCurser/AutoScriptUpdate.txt');
        Writeln('Local : ' + ScriptVersionNumber + ' / Latest : ' + OnlineVersion);
        if (Trim(OnlineVersion) > ScriptVersionNumber) then
        begin
          Writeln('New TheAutoCurser Version Available! Updating...');
          NewScript := GetPage('http://07scape-theautocurser.googlecode.com/svn/trunk/TheAutoCurser/TheAutoCurser.simba');
          NewFileName := AppPath + 'Scripts\TheAutoCurser v' + OnlineVersion + '.simba';
          NewFile := RewriteFile(NewFileName, true);
          try
            WriteFileString(NewFile, NewScript);
          except
            begin
              Writeln('Fatal error writing to ' + NewFileName + '!');
              TerminateScript;
            end;
          end;
          CloseFile(NewFile);
          Writeln('New TheAutoCurser Version Downloaded Please Restart Simba!');
          Writeln('TheAutoCurser version ' + OnlineVersion + ' has been added to your Simba/Scripts folder.');
          TerminateScript;
        end else
          writeln('You already have version ' + OnlineVersion + ' of TheAutoCurser');
      end;
    end;

    procedure StartUp;
    begin
      ClearDebug;
      AutoUpdateScript;
      P07_AutoUpdateMe;
      SetupP07Include;
      ActivateClient;
      Wait(2000);
      If (Not P07_LoggedIn) Then
        P07_LogInPlayer;
      DTM;
    end;

    procedure YourClickProcedure(Sender: TObject);
    begin
     // ShowMessage('click');
    end;

    procedure SetNPC;
    begin
      case NPCCombo.ITEMINDEX of
        0:
        Begin
          Writeln('You have choosen to curse the Monk of Zamorak');
          SelectNPC := 'Monk';
        End;
        1:
        Begin
          Writeln('You have choosen to curse Skeletons in Varrock Sewer');
          SelectNPC := 'Skeleton';
        End;
      End;
    End;

    procedure SaveSettings(Sender: TObject);
    begin
      DsgnForm.ModalResult := mrOk;
      P07_PlayerName := Username.TEXT;
      P07_PlayerPass := Password.TEXT;
      SetNPC;
      DsgnForm.CLOSE;
    end;

    procedure InitForm;
    begin
    //DsgnForm
     DsgnForm:=TForm.Create(nil);
      with DsgnForm do
        begin
          Caption:='TheAutoCurser - by Sequence';
          Left:=93;
          Top:=163;
          Width:=320;
          Height:=144;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;

    //Username
     Username:=TEdit.Create(DsgnForm);
      with Username do
        begin
          Parent:=DsgnForm;
          Text:='Username';
          Left:=10;
          Top:=10;
          Width:=300;
          Height:=23;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;

    //Password
     Password:=TEdit.Create(DsgnForm);
      with Password do
        begin
          Parent:=DsgnForm;
          Text:='Password';
          Left:=10;
          Top:=43;
          Width:=300;
          Height:=23;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
          Password.PASSWORDCHAR:='*';
          Password.MAXLENGTH:=20;
      end;

    //NPCCombo\\
     NPCCombo:=TComboBox.Create(DsgnForm);
      with NPCCombo do
        begin
          Caption:='Select NPC and Location';
          Parent:=DsgnForm;
          Left:=10;
          Top:=76;
          Width:=300;
          Height:=23;
          Items.Add('Monk of Zamorak - Varrock Castle');
          Items.Add('Skeleton - Varrock Sewer');
          Text := Items[0];
          OnClick:=@YourClickProcedure;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;

    //StartBtn
     StartBtn := TButton.Create(DsgnForm);
      with StartBtn do
        begin
          Parent:=DsgnForm;
          Caption:='Save Settings';
          Left:=10;
          Top:=109;
          Width:=300;
          Height:=25;
          OnClick:=@SaveSettings;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;


    procedure ShowFormModal;
    begin
      DsgnForm.ShowModal;
      DsgnForm.Free;
    end;


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

    Begin
    SetupSRL;
    SafeInitForm;
    SafeShowFormModal;
    StartUp;
    end.



    The working script if anyone need it as an example:
    Simba Code:
    Program TheAutoCurser;

    {$DEFINE SMART}
    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}

    (********************************************************)
    (*           TheAutoCurser - Made by Sequence           *)
    (********************************************************)
    (*      1. Specify how many casts you want to do.       *)
    (*      2. Start the script, and enter login info       *)
    (*      3. Be sure to stand at the Monk of Zamorak      *)
    (*         in the cage at Varrock Castle                *)
    (********************************************************)

    var
      x, y, MonkColor, SkeletonColor1, SkeletonColor2, Casts, I : Integer;
      CastsDone, CastsPerHour, TimeGone : Integer;
      DsgnForm : TForm;
      Username, Password : TEdit;
      StartBtn : TButton;
      NPCLocSetting : Integer;
      NPCCombo : TComboBox;

    const
      ScriptVersionNumber = '1.3';
      default = 'Calibri';

    procedure DTM;
    begin
      Casts := 2000; //Change to specify how many casts you want to do.
      MonkColor := 3488916;
      SkeletonColor1 := 8885140;
      SkeletonColor2 := 9804448;
    end;

    procedure LogOutPlayer;
    begin
    P07_TabInventoryTab(11);
    Wait(RandomRange(400, 700));
    P07_MouseBox(575, 362, 706, 388, mouse_left);
    TerminateScript;
    end;

    procedure CheckFriends;
    begin
    P07_TabInventoryTab(9);
    Wait(RandomRange(300, 500));
    MMouse(650, 270, 3, 3);
    Wait(RandomRange(2000, 3000));
    end;

    procedure CheckInventory;
    begin
    P07_TabInventoryTab(4);
    Wait(RandomRange(200, 600));
    end;

    procedure ProgressReport;
    begin
      ClearDebug;
      TimeGone := (GetTimeRunning/1000);
      CastsPerHour :=(3600*(CastsDone))/((TimeGone));
      begin
        Writeln('********************************************************');
        Writeln('            TheAutoCurser - Made by Sequence            ');
        Writeln('********************************************************');
        Writeln('              Time running: ' + MsToTime((GetTimeRunning), Time_Short));
        Writeln('                     Casts: ' + IntToStr(CastsDone) + ' ');
        Writeln('                 Casts p/h: ' + IntToStr(CastsPerHour) + ' ');
        Writeln('********************************************************');
      end;
    end;

    procedure AutoUpdateScript;
    var
        NewFile : Integer;
        OnlineVersion, NewScript, NewFileName : String;
    begin
      begin
        Writeln('Checking TheAutoCurser VersionNumber');
        OnlineVersion := GetPage('http://07scape-theautocurser.googlecode.com/svn/trunk/TheAutoCurser/AutoScriptUpdate.txt');
        Writeln('Local : ' + ScriptVersionNumber + ' / Latest : ' + OnlineVersion);
        if (Trim(OnlineVersion) > ScriptVersionNumber) then
        begin
          Writeln('New TheAutoCurser Version Available! Updating...');
          NewScript := GetPage('http://07scape-theautocurser.googlecode.com/svn/trunk/TheAutoCurser/TheAutoCurser.simba');
          NewFileName := AppPath + 'Scripts\TheAutoCurser v' + OnlineVersion + '.simba';
          NewFile := RewriteFile(NewFileName, true);
          try
            WriteFileString(NewFile, NewScript);
          except
            begin
              Writeln('Fatal error writing to ' + NewFileName + '!');
              TerminateScript;
            end;
          end;
          CloseFile(NewFile);
          Writeln('New TheAutoCurser Version Downloaded Please Restart Simba!');
          Writeln('TheAutoCurser version ' + OnlineVersion + ' has been added to your Simba/Scripts folder.');
          TerminateScript;
        end else
          writeln('You already have version ' + OnlineVersion + ' of TheAutoCurser');
      end;
    end;

    procedure StartUp;
    begin
      ClearDebug;
      SetupP07Include;
      AutoUpdateScript;
      P07_AutoUpdateMe;
      //P07_DeclarePlayer;
      ActivateClient;
      Wait(2000);
      If (Not P07_LoggedIn) Then
        P07_LogInPlayer;
      //P07_MakeCameraAngleHigh;
      //P07_MakeCompassEast;
      DTM;
    end;

    Function AntiBan : Boolean;
    begin
      case random(300) of
      0: P07_HoverSkill('magic', random(5000));
      1: P07_MakeCompassDegree(RandomRange(140, 170));
      2: P07_MakeCompassDegree(RandomRange(190, 220));
      3: MMouse(random(650), random(350), 0, 0);
      4: CheckInventory;
      5: CheckFriends;
      end;
    end;

    procedure CastCurse;
    begin
    if P07_TabInventoryTab(7) then
      begin
        P07_MouseBox(661, 258, 673, 269, mouse_left)
      end;
    end;

    procedure CastCurseMonk;
    begin
    P07_MakeCompassEast;
    P07_MakeCameraAngleHigh;
    WriteLn('You have choosen to curse the Monk of Zamorak in Varrock Castle');
      repeat
        If (Not FindColorSpiralTolerance(x, y, MonkColor, 176, 84, 393, 320, 20)) then
          LogOutPlayer
        else begin
          P07_MakeCompassEast;
          P07_MakeCameraAngleHigh;
          Wait(RandomRange(200, 350));
          P07_CastSpell(12);
          Wait(RandomRange(800, 1000));
          MMouse(RandomRange(X - 3, X + 3), RandomRange(y - 3, y + 3), 0, 0);
          ClickMouse2(mouse_left);
          ProgressReport;
          AntiBan;
          Inc(CastsDone);
        end;
      Until(I = Casts);
    end;

    procedure CastCurseSkeleton;
    begin
    repeat
      P07_MakeCompassDegree(20);
      P07_MakeCameraAngleLow;
      WriteLn('You have choosen to curse Skeletons at the Varrock sewer');
        begin
        Wait(RandomRange(200, 350));
        P07_CastSpell(12);
        Wait(randomRange(500, 700));
        if P07_FindObjCustom(x, y, ['Skeleton', 'Ske', 'ton', 'Skelet', 'leton'], [SkeletonColor1, SkeletonColor2], 14) then
          begin
            ClickMouse2(mouse_left);
            Wait(RandomRange(400, 600));
            Inc(CastsDone);
          end
          else
            begin
              Wait(RandomRange(1034, 1503));
              if (Not P07_FindObjCustom(x, y, ['Skeleton', 'Ske', 'ton', 'Skelet', 'leton'], [8885140, 9804448], 14)) then
              WriteLn('NPC Not found, terminating script...');
              Wait(RandomRange(100, 300));
              Mouse(992, 293, random(5), random(5), true);
              Wait(RandomRange(500, 1000));
              LogOutPlayer;
              Wait(RandomRange(500, 1000));
              TerminateScript;
            end;
          end;
        ProgressReport;
        AntiBan;
        Inc(I);
      until(I = Casts);
    end;

    procedure CastCurseGlobal;
    begin
      case NPCLocSetting of
        0: CastCurseMonk;
        1: CastCurseSkeleton;
      end;
    end;

    procedure SaveSettings(Sender: TObject);
    begin
      DsgnForm.ModalResult := mrOk;
      P07_PlayerName := Username.TEXT;
      P07_PlayerPass := Password.TEXT;
      NPCLocSetting := NPCCombo.ITEMINDEX;
      DsgnForm.CLOSE;
    end;

    procedure YourClickProcedure(Sender: TObject);
    begin
      //ShowMessage('click');
    end;

    procedure InitForm;
    begin
    //DsgnForm
     DsgnForm:=TForm.Create(nil);
      with DsgnForm do
        begin
          Caption:='TheAutoCurser - by Sequence';
          Left:=93;
          Top:=163;
          Width:=320;
          Height:=144;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;

    //Username
     Username:=TEdit.Create(DsgnForm);
      with Username do
        begin
          Parent:=DsgnForm;
          Text:='Username';
          Left:=10;
          Top:=10;
          Width:=300;
          Height:=23;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;

    //Password
     Password:=TEdit.Create(DsgnForm);
      with Password do
        begin
          Parent:=DsgnForm;
          Text:='Password';
          Left:=10;
          Top:=43;
          Width:=300;
          Height:=23;
          Font.Name:=default;
          Font.Color:=clDefault;
          Font.Size:=11;
          Password.PASSWORDCHAR:='*';
          Password.MAXLENGTH:=20;
      end;

    //NPCCombo\\
    NPCCombo:=TComboBox.Create(DsgnForm);
    with NPCCombo do
      begin
        Caption:='Select NPC and Location';
        Parent:=DsgnForm;
        Left:=10;
        Top:=76;
        Width:=300;
        Height:=23;
        Items.Add('Monk of Zamorak - Varrock Castle');
        Items.Add('Skeleton - Varrock Sewer');
        Text := Items[0];
        OnClick:=@YourClickProcedure;
        Font.Name:=default;
        Font.Color:=clDefault;
        Font.Size:=11;
      end;

    //StartBtn
     StartBtn := TButton.Create(DsgnForm);
      with StartBtn do
        begin
          Parent:=DsgnForm;
          Caption:='Save Settings';
          Left:=10;
          Top:=109;
          Width:=300;
          Height:=25;
          OnClick:=@SaveSettings;
          Font.Color:=clDefault;
          Font.Size:=11;
      end;
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;


    procedure ShowFormModal;
    begin
      DsgnForm.ShowModal;
    end;


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

    Begin
    SetupSRL;
    SafeInitForm;
    SafeShowFormModal;
    StartUp;
    CastCurseGlobal;
    end.
    Last edited by Sequence; 03-04-2013 at 03:32 PM.

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Try
    Simba Code:
    procedure SetNPC(Sender: TObject);
    begin
      case NPCCombo.ITEMINDEX of
        0:
        Begin
          Writeln('You have choosen to curse the Monk of Zamorak');
          SelectNPC := 'Monk';
        End;
        1:
        Begin
          Writeln('You have choosen to curse Skeletons in Varrock Sewer');
          SelectNPC := 'Skeleton';
        End;
      End;
    End;

  3. #3
    Join Date
    May 2012
    Posts
    60
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Unfortunately that doesn't work.

  4. #4
    Join Date
    Sep 2007
    Location
    Australia, NSW
    Posts
    934
    Mentioned
    6 Post(s)
    Quoted
    145 Post(s)

    Default

    The way I would go about this is use a global variable (probably an integer) to store the setting the user inputs, eg.
    Simba Code:
    var
      NPCLocSetting: Integer;

    procedure YourClickProcedure(Sender: TObject);
    begin
     NPCLocSetting := NPCCombo.ITEMINDEX;  // Which would return either 0 or 1 depending on user selection
    end;

    Then, I would create a procedure that deals with which method to execute:
    Simba Code:
    procedure CastCurseGlobal;
    begin
      case NPCLocSetting of
        0: CastCurseMonk;
        1: CastCurseSkeleton;
      end;
    end;

    Script looks good by the way; only had a quick glance however

    INACTIVE
    How-to: Make S.M.A.R.T. less laggy

    Sell me your Maple Shieldbows (u)! Up to 95gp ea!

    My Scripts:
    Ivy Chopper Ultra [RS3] | Fantastic Fletcher [RS3]
    99 x78 | 99 x10 | 99 x2 | 99 x12


    Use the REPORT tags when posting progress reports to make life easier (:
    [REPORT]Put progress report in here![/REPORT]

    Super Savvy Smither V1.06Cool Classy Cooker V1.02 [EoC]

  5. #5
    Join Date
    May 2012
    Posts
    60
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Press Play View Post
    The way I would go about this is use a global variable (probably an integer) to store the setting the user inputs, eg.
    Simba Code:
    var
      NPCLocSetting: Integer;

    procedure YourClickProcedure(Sender: TObject);
    begin
     NPCLocSetting := NPCCombo.ITEMINDEX;  // Which would return either 0 or 1 depending on user selection
    end;

    Then, I would create a procedure that deals with which method to execute:
    Simba Code:
    procedure CastCurseGlobal;
    begin
      case NPCLocSetting of
        0: CastCurseMonk;
        1: CastCurseSkeleton;
      end;
    end;

    Script looks good by the way; only had a quick glance however
    This seems to be working perfect I didn't know it was that simple, thanks a lot +rep
    Last edited by Sequence; 03-04-2013 at 01:18 PM.

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
  •