Results 1 to 4 of 4

Thread: Forms and storing

  1. #1
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    698
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Forms and storing

    Can someone help me with using forms, ive made a form in the script but now i want it to be able to enter usernames, create new players and what not. I also want to be able to store the user names and passwords to a file. How would i do this?

    SCAR Code:
    {.include srl/srl.scar}
    {.include SRL/SRL/Skill/WoodCutting.scar}
    var
          cUser: Integer;
          willows,i:integer;
          StartXP, EndXP, TotalXP, WillowLoads, LoadNumber:integer;
          StartScript: Boolean;
          frmDesign : TForm;
          CPlayer : TButton;
          PPlayer : TButton;
          BeginScript : TButton;
          Cancel : TButton;
          NPlayer : TButton;
          DPlayer : TButton;
          GroupBox1 : TGroupBox;
          Label1 : TLabel;
          Label2 : TLabel;
          Label3 : TLabel;
          Label4 : TLabel;
          Label5 : TLabel;
          UName : TEdit;
          Pword : TEdit;
          Loads : TEdit;
          Activity : TComboBox;

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer:= 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;

    {__________________________________________
    |                   Form                   |
    |__________________________________________|}

    procedure Inititate(Sender: TObject);
    begin
      label5.Caption := 'Player '+IntToStr(cUser);
      Players[cUser].Name := UName.Text;
      Players[cUser].Pass := Pword.Text;
      if (activity.Text = 'True') then
        Players[cUser].Active := True
      else
        Players[cUser].Active := False;
      cUser := GetArrayLength(Players) - 1;
    end;

    procedure LeftPlayer(sender: TObject);
    begin
      Players[cUser].Name := UName.Text;
      Players[cUser].Pass := Pword.Text;
      if (Activity.Text = 'True') then
        Players[cUser].Active := True
      else
        Players[cUser].Active := False;
      if (cUser + 1 > GetArrayLength(Players) - 1) then
        cUser := 0
      else
        cUser := cUser + 1;
        Label5.Caption := 'Player '+IntToStr(cUser);
      UName.Text := Players[cUser].Name;
      Pword.Text := Players[cUser].Pass;
      if (Players[cUser].Active) then
        Activity.Text := 'True'
      else
        Activity.Text := 'False';
    end;

    procedure RightPlayer(sender: TObject);
    begin
      Players[cUser].Name := UName.Text;
      Players[cUser].Pass := Pword.Text;
      if (Activity.Text = 'True') then
        Players[cUser].Active := True
      else
        Players[cUser].Active := False;
      if (cUser - 1 < 0) then
        cUser := GetArrayLength(Players) - 1
      else
        cUser := cUser - 1;
      Label5.Caption := 'Player '+IntToStr(cUser);
      UName.Text := Players[cUser].Name;
      Pword.Text := Players[cUser].Pass;
      if (Players[cUser].Active) then
        Activity.Text := 'True'
      else
        Activity.Text := 'False';
    end;

    procedure Backspace(sender: TObject);
    var
      na: string;
      ac: Boolean;
    begin
      na := Players[GetArrayLength(Players) - 1].Name;
      ac := Players[GetArrayLength(Players) - 1].Active;
      Players[cUser].Name := na;
      Players[cUser].Active := ac;
      SetArrayLength(Players, GetArrayLength(Players) - 1);
      if (cUser + 1 > GetArrayLength(Players) - 1) then
        cUser := 0
      else
        cUser := cUser + 1;
      Label5.Caption := 'Player '+IntToStr(cUser);
      UName.Text := Players[cUser].Name;
      Pword.Text := Players[cUser].Pass;
      if (Players[cUser].Active) then
        Activity.Text := 'True'
      else
        Activity.Text := 'False';
    end;

    procedure AddUser;
    begin
      SetArrayLength(Players, GetArrayLength(Players) + 1);
      Players[GetArrayLength(Players) - 1].Name := 'New Name';
      Players[GetArrayLength(Players) - 1].Pass := 'New Pass';
      Players[GetArrayLength(Players) - 1].Active := True;
    end;

    procedure NewPlayer(sender: TObject);
    begin
      Players[cUser].Name := UName.Text;
      Players[cUser].Pass := Pword.Text;
      if (Activity.Text = 'True') then
        Players[cUser].Active := True
      else
        Players[cUser].Active := False;
      AddUser;
      cUser := GetArrayLength(Players) - 1;
      Label5.Caption := 'Player '+IntToStr(cUser);
      UName.Text := Players[cUser].Name;
      Pword.Text := Players[cUser].Pass;
      if (Players[cUser].Active) then
        Activity.Text := 'True'
      else
        Activity.Text := 'False';
    end;

    procedure CancelScript(sender: TObject);
    var
      v: TVariantArray;
    begin
      SetArrayLength ( V, 0);
      Writeln('Script Cancelled');
      frmDesign.ModalResult:= mrOk;
      StartScript := False;
    end;

    Procedure BScript(Sender: TObject);
    var
      v: TVariantArray;
    begin
      SaveUs
      SetArrayLength ( V, 0);
      frmDesign.ModalResult:= mrOk;
      StartScript := True;
        Label5.Caption := 'Player '+IntToStr(cUser);
      UName.Text := Players[cUser].Name;
      Pword.Text := Players[cUser].Pass;
      if (Players[cUser].Active) then
        Activity.Text := 'True'
      else
        Activity.Text := 'False';
    end;

    procedure InitForm;
      Begin
      frmDesign := CreateForm;
      frmDesign.Left := 262;
      frmDesign.Top := 167;
      frmDesign.BorderStyle := bsSingle;
      frmDesign.Caption := 'Edge Cutter';
      frmDesign.ClientHeight := 293;
      frmDesign.ClientWidth := 377;
      frmDesign.Color := clCream;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -13;
      frmDesign.Font.Name := 'Comic Sans MS';
      frmDesign.Font.Style := [];
      frmDesign.KeyPreview := True;
      frmDesign.Visible := False;
      frmDesign.PixelsPerInch := 96;

      NPlayer := TButton.Create(frmDesign);
      NPlayer.OnClick:= @LeftPlayer;
      NPlayer.Parent := frmDesign;
      NPlayer.Left := 255;
      NPlayer.Top := 28;
      NPlayer.Width := 75;
      NPlayer.Height := 25;
      NPlayer.Caption := 'Next';
      NPlayer.Font.Color := clWindowText;
      NPlayer.Font.Height := -13;
      NPlayer.Font.Name := 'Comic Sans MS';
      NPlayer.Font.Style := [];
      NPlayer.ParentFont := False;
      NPlayer.TabOrder := 0;

      CPlayer := TButton.Create(frmDesign);
      CPlayer.OnClick:= @NewPlayer;
      CPlayer.Parent := frmDesign;
      CPlayer.Left := 186;
      CPlayer.Top := 28;
      CPlayer.Width := 67;
      CPlayer.Height := 25;
      CPlayer.Caption := 'Create';
      CPlayer.Font.Color := clWindowText;
      CPlayer.Font.Height := -13;
      CPlayer.Font.Name := 'Comic Sans MS';
      CPlayer.Font.Style := [];
      CPlayer.ParentFont := False;
      CPlayer.TabOrder := 1;

      DPlayer := TButton.Create(frmDesign);
      DPlayer.OnClick:= @Backspace;
      DPlayer.Parent := frmDesign;
      DPlayer.Left := 116;
      DPlayer.Top := 29;
      DPlayer.Width := 68;
      DPlayer.Height := 25;
      DPlayer.Caption := 'Delete';
      DPlayer.Font.Color := clWindowText;
      DPlayer.Font.Height := -13;
      DPlayer.Font.Name := 'Comic Sans MS';
      DPlayer.Font.Style := [];
      DPlayer.ParentFont := False;
      DPlayer.TabOrder := 2;

      PPlayer := TButton.Create(frmDesign);
      PPlayer.OnClick:= @RightPlayer;
      PPlayer.Parent := frmDesign;
      PPlayer.Left := 39;
      PPlayer.Top := 29;
      PPlayer.Width := 75;
      PPlayer.Height := 25;
      PPlayer.Caption := 'Previous';
      PPlayer.Font.Color := clWindowText;
      PPlayer.Font.Height := -13;
      PPlayer.Font.Name := 'Comic Sans MS';
      PPlayer.Font.Style := [];
      PPlayer.ParentFont := False;
      PPlayer.TabOrder := 3;

      Cancel := TButton.Create(frmDesign);
      Cancel.OnClick:= @CancelScript;
      Cancel.Parent := frmDesign;
      Cancel.Left := 200;
      Cancel.Top := 258;
      Cancel.Width := 75;
      Cancel.Height := 25;
      Cancel.Caption := 'Cancel';
      Cancel.Font.Color := clWindowText;
      Cancel.Font.Height := -13;
      Cancel.Font.Name := 'Comic Sans MS';
      Cancel.Font.Style := [];
      Cancel.ParentFont := False;
      Cancel.TabOrder := 4;

      BeginScript := TButton.Create(frmDesign);
      BeginScript.OnClick:= @BScript;
      BeginScript.Parent := frmDesign;
      BeginScript.Left := 90;
      BeginScript.Top := 258;
      BeginScript.Width := 75;
      BeginScript.Height := 25;
      BeginScript.Caption := 'Ok';
      BeginScript.TabOrder := 6;

      GroupBox1 := TGroupBox.Create(frmDesign);
      GroupBox1.Parent := frmDesign;
      GroupBox1.Left := 43;
      GroupBox1.Top := 61;
      GroupBox1.Width := 285;
      GroupBox1.Height := 190;
      GroupBox1.Color := clActiveCaption;
      GroupBox1.DragMode := dmAutomatic;
      GroupBox1.Font.Color := clWindowText;
      GroupBox1.Font.Height := -13;
      GroupBox1.Font.Name := 'Comic Sans MS';
      GroupBox1.Font.Style := [];
      GroupBox1.ParentColor := False;
      GroupBox1.ParentFont := False;
      GroupBox1.TabOrder := 5;

      Label1 := TLabel.Create(GroupBox1);
      Label1.Parent := GroupBox1;
      Label1.Left := 42;
      Label1.Top := 43;
      Label1.Width := 70;
      Label1.Height := 18;
      Label1.Caption := 'User Name:';
      Label1.Font.Color := clWindowText;
      Label1.Font.Height := -13;
      Label1.Font.Name := 'Comic Sans MS';
      Label1.Font.Style := [];
      Label1.ParentFont := False;

      Label2 := TLabel.Create(GroupBox1);
      Label2.Parent := GroupBox1;
      Label2.Left := 50;
      Label2.Top := 73;
      Label2.Width := 61;
      Label2.Height := 18;
      Label2.Caption := 'Password:';
      Label2.Font.Color := clWindowText;
      Label2.Font.Height := -13;
      Label2.Font.Name := 'Comic Sans MS';
      Label2.Font.Style := [];
      Label2.ParentFont := False;

      Label3 := TLabel.Create(GroupBox1);
      Label3.Parent := GroupBox1;
      Label3.Left := 68;
      Label3.Top := 103;
      Label3.Width := 42;
      Label3.Height := 18;
      Label3.Caption := 'Active:';
      Label3.Font.Color := clWindowText;
      Label3.Font.Height := -13;
      Label3.Font.Name := 'Comic Sans MS';
      Label3.Font.Style := [];
      Label3.ParentFont := False;

      Label4 := TLabel.Create(GroupBox1);
      Label4.Parent := GroupBox1;
      Label4.Left := 69;
      Label4.Top := 133;
      Label4.Width := 39;
      Label4.Height := 18;
      Label4.Caption := 'Loads:';

      Label5 := TLabel.Create(GroupBox1);
      Label5.Parent := GroupBox1;
      Label5.Left := 112;
      Label5.Top := 8;
      Label5.Width := 46;
      Label5.Height := 23;
      Label5.Caption := 'Player '+IntToStr(cUser);
      Label5.Font.Color := clWindowText;
      Label5.Font.Height := -16;
      Label5.Font.Name := 'Comic Sans MS';
      Label5.Font.Style := [];
      Label5.ParentFont := False;

      UName := TEdit.Create(GroupBox1);
      UName.Parent := GroupBox1;
      UName.Left := 118;
      UName.Top := 40;
      UName.Width := 121;
      UName.Height := 26;
      UName.ParentShowHint := False;
      UName.ShowHint := True;
      UName.TabOrder := 4;
      UName.Text := 'UName';

      Pword := TEdit.Create(GroupBox1);
      Pword.Parent := GroupBox1;
      Pword.Left := 117;
      Pword.Top := 70;
      Pword.Width := 121;
      Pword.Height := 26;
      Pword.Hint := 'Password';
      Pword.ParentShowHint := False;
      Pword.PasswordChar := '*';
      Pword.ShowHint := True;
      Pword.TabOrder := 1;
      Pword.Text := 'Pword';

      Loads := TEdit.Create(GroupBox1);
      Loads.Parent := GroupBox1;
      Loads.Left := 118;
      Loads.Top := 130;
      Loads.Width := 121;
      Loads.Height := 26;
      Loads.OEMConvert := True;
      Loads.ParentShowHint := False;
      Loads.ShowHint := True;
      Loads.TabOrder := 2;
      Loads.Text := 'Loads';

      Activity := TComboBox.Create(GroupBox1);
      Activity.Parent := GroupBox1;
      Activity.Left := 117;
      Activity.Top := 100;
      Activity.Width := 122;
      Activity.Height := 26;
      Activity.ItemHeight := 18;
      Activity.ParentShowHint := False;
      Activity.ShowHint := True;
      Activity.TabOrder := 3;
      Activity.Text := 'True';
      Activity.Items.Add('True');
      Activity.Items.Add('False');

    end;

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

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

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

    {__________________________________________
    |                Sigantures                |
    |__________________________________________|}

    Procedure Siganture;
    Begin
        Writeln('_______________________________');
        Writeln('|         Me_ntal"s            |');
        Writeln('|         Edgeville            |');
        Writeln('|       Willow Cutter          |');
        Writeln('|______________________________|');
    end;

    procedure Report;
    begin
         ClearDebug;
         Writeln('_______________________________');
         Writeln('|                              |');
         Writeln('|         Me_ntal"s            |');
         Writeln('|         Edgeville            |');
         Writeln('|       Willow Cutter          |');
         Writeln('|______________________________|');
         Writeln('')
         Writeln('Willows Cut:'+IntToStr(Willows));
         Writeln('Exp Gained:'+IntToStr(TotalXP));
    end;


    {__________________________________________
    |                  Randoms                 |
    |__________________________________________|}

    Function FindFastRandoms:Boolean;   //By WT-Fakawi.
    begin
      for i := 1 to 16 do
      begin
        case I of
          1: CloseWindow;
          2: if FindTalk then
              Result := True;
          3: if FindDead then
              Result := True;
          4: if FindMod then
              Result := True;
          5: if FindMime then
              Result := True;
          6: if FindMaze then
              Result := True;
          7: if FindQuiz then
              Result := True;
          8: if FindDemon then
              Result := True;
          9: if FindScapeRune then
              Result := True;
          10: if FindTalk then
              Result := True;
          11: if FindLamp(LampSkill) then
              Result := True;
          12: if (FindNewBox) then
            begin
              Result := True;
              if (UseBoxSolver) then
                SolveBox
              else
                GambleNewBox;
            end;

          14:
            begin
              if NoGameTab then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'No GameTab';
                Logout;
                Exit;
              end;
            end;
            16: if RC then
              Result := True;
        end;
        Wait(1);
      end;
    end;

    procedure Randomfind;
    begin
      FindFastRandoms;
      FindNormalRandoms;
    end;
    {__________________________________________
    |                  AntiBan                 |
    |__________________________________________|}

    Procedure WereHuman;

    begin

        wait(10)

    end;

    {__________________________________________
    |               tree clicking              |
    |__________________________________________|}

    Procedure Fallen;
    Begin
       repeat
            Randomfind;
            WereHuman;
            wait(1000+Random(1000));
            Report;
            If (InvFull) then
            Randomfind;
            exit;
       until (not(IsUpText('hop')));
    end;


    {__________________________________________
    |                 Main Loop                |
    |__________________________________________|}

    Procedure Doload;
    begin
      repeat
        If (FindColorTolerance(x,y, 3160112, msx1,msy1,msx2,msy2, 3)) or
        (FindColorTolerance(x,y, 3043424, msx1,msy1,msx2,msy2, 3)) then
        begin
        repeat
          Wait(100 + Random(500));
          MMouse(x,y,3,3);
          if(IsUpText('hop'))or(IsUpText('own'))then
          begin
            if IsUpTextMulti('ree', 'ak', 'ew') then
              Exit;
            if IsUpText('illow') then
              begin
                Report;
                Wait(100 + Random(500));
                Mouse(x, y, 3, 3, true);
                Randomfind;
                Wait(100 + Random(500));
                Fallen;
                FindHead;
                MMouse(x,y,3,3);
              end;
          end;
        until (not(IsUpText('hop')));
        end;
      Until (InvFull)
    end;

    Procedure Walkto;
    Begin
    end;

    Procedure BankLoad;
    Begin
    end;

    Procedure Walkfro;
    Begin
    end;

    {__________________________________________
    |                Once Setup                |
    |__________________________________________|}

    Procedure SetupScript;
    Begin
        ClearDebug;
        Wait(500)
        rs_DeleteUID;
        ActivateClient;
        LoginPlayer;
        If (Not(LoggedIn)) then
        Begin
          Loginplayer;
        end;
    end;

    Procedure SetupPlayer;
    begin
       HighestAngle;
       MakeCompass('E');
       StartXP := GetXp('Woodcutting');
       GameTab(5)
       FindAxeHeadColor;
    end;

    {__________________________________________
    |                 Main Loop                |
    |__________________________________________|}

    begin
      setupsrl;
      ClearDebug;
      cUser := 0;
      Siganture;
      if (GetArrayLength(Players) = 0) then
      AddUser;
      SafeInitForm;
      SafeShowFormModal;
      If not(StartScript) then TerminateScript;
          SetupScript;
          SetupPlayer;
        repeat
      repeat
            Report;
            DoLoad;
            if (InvFull) then
               Walkto;
               BankLoad;
               Walkfro;
        until (LoadNumber >= WillowLoads)
            EndXP := GetXp('Woodcutting')
            TotalXP := (EndXP - StartXP)
            Report;
            SRLRandomsReport;
            LogOut;
            NextPlayer(True);
            LoadNumber := 0
            SetupPlayer;
      until False;
    end.

  2. #2
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There are many different ways to. The best wa yto learn is to look through scripts that already have it i belive. StarBlaster100's powerskills has a good form alogn with Oak Annihilator. Or you can look at my script in my script which is in my signiture (its the big "Click Here". It is based off of Oak Annihalator basically. Also, you can look at the air crafting script in the free script section, it is based off of starblaster's script i believe.

  3. #3
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    698
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Yeah thanks starblasters was originally where i got the idea to implement forms from. I than managed to find a useful file in the includes file which contains a complete implementation of forms and everything.

    ::Edit solved my own problem.

    Just can someone help me with writing it to a file?

  4. #4
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think soemthing like this.
    SCAR Code:
    begin
      if (filename = '') then filename := 'chars'
        CharsFile := RewriteFile(AppPath + FileName + '.dat', False)
       for f := 0 to GetArrayLength(players) - 1 do
      begin
        WriteFileString(CharsFile, 'name' + IntToStr(f) + '=' + players[f].name + Chr(13))
        WriteFileString(CharsFile, 'pass' + IntToStr(f) + '=' + players[f].pass + Chr(13))
        WriteFileString(charsfile, 'nick' + IntToStr(f) + '=' + players[f].nick + Chr(13))
        WriteFileString(CharsFile, 'string1' +IntToStr(f)+ '=' +players[f].string1+ Chr(13))
        WriteFileString(CharsFile, 'string2' +IntToStr(f)+ '=' +players[f].string2+ Chr(13))
        WriteFileString(CharsFile, 'skill' +IntToStr(f)+ '=' +players[f].skill+ Chr(13))
        WriteFileString(CharsFile, 'integer1' +IntToStr(f)+ '=' +IntToStr(players[f].Integer1) + Chr(13))

      end;
       CloseFile(charsfile)
    end;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Storing coords
    By Prince in forum OSR Help
    Replies: 8
    Last Post: 02-23-2008, 04:58 PM
  2. Help with storing variable
    By Drew_Dawg in forum OSR Help
    Replies: 1
    Last Post: 02-02-2008, 11:54 AM
  3. Help on Forms
    By l33t_h4x0r in forum OSR Help
    Replies: 2
    Last Post: 10-25-2007, 08:13 AM
  4. int storing dtm
    By del_signo in forum OSR Help
    Replies: 4
    Last Post: 03-05-2007, 02:03 AM

Posting Permissions

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