Results 1 to 7 of 7

Thread: Player active/TcomboBox help

  1. #1
    Join Date
    Sep 2006
    Posts
    322
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default Player active/TcomboBox help

    For the passwords, I'm using this (and it works)
    SCAR Code:
    Username0, Password0 : String;

    SCAR Code:
    Username0 := Edit1.Text;
      Password0 := Edit2.Text;


    How can I make something similar to this(^) to determine if the player is active/false?

    SCAR Code:
    ComboBox5 := TComboBox.Create(frmDesign);
      ComboBox5.Parent := frmDesign;
      ComboBox5.Left := 464;
      ComboBox5.Top := 64;
      ComboBox5.Width := 65;
      ComboBox5.Height := 21;
      ComboBox5.ItemHeight := 13;
      ComboBox5.TabOrder := 20;
      ComboBox5.Text := 'Active?';
      ComboBox5.Items.Add('True');
      ComboBox5.Items.Add('False');
    "SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
    -Wizzup?

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    Var Active0 : Boolean;

    Active0 := StrToBool(Combo5.Text)

    It would help to read up on SCAR's conversion method's as well

  3. #3
    Join Date
    Sep 2006
    Posts
    322
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Thanks, do you mind taking a look at what's wrong with this? (procedure Players -- Type mismatch )
    SCAR Code:
    program New;

    var
      EndInitForm : Boolean;
      frmDesign : TForm;
      Label1 : TLabel;
      Label2 : TLabel;
      Label3 : TLabel;
      Label4 : TLabel;
      Edit1 : TEdit;
      Edit2 : TEdit;
      ComboBox1 : TComboBox;
      Edit3 : TEdit;
      Edit4 : TEdit;
      ComboBox2 : TComboBox;
      Edit5 : TEdit;
      Edit6 : TEdit;
      ComboBox3 : TComboBox;
      Edit7 : TEdit;
      Edit8 : TEdit;
      ComboBox4 : TComboBox;
      ComboBox5 : TComboBox;
      ComboBox6 : TComboBox;
      ComboBox7 : TComboBox;
      ComboBox8 : TComboBox;
      Button1 : TButton;
      UsernameA, PasswordA : String;
      UsernameB, PasswordB : String;
      UsernameC, PasswordC : String;
      UsernameD, PasswordD : String;
      ActiveA : Boolean;
      ActiveB : Boolean;
      ActiveC : Boolean;
      ActiveD : Boolean;
     
    procedure InitFormOnClose(Sender : TObject; var Action : TCloseAction);
    begin
      if (not(frmDesign.ModalResult = 1)) then
        EndInitForm := True;
    end;

    procedure ButtonClick(sender: TObject);
    begin
      frmDesign.ModalResult:= mrOk;
    end;

    procedure InitForm;
    begin
      frmDesign := CreateForm;
      frmDesign.OnClose := @InitFormOnClose;
      frmDesign.Position := poScreenCenter;
      frmDesign.FormStyle := fsStayOnTop;
      frmDesign.Width := 601;
      frmDesign.Height := 240;
      frmDesign.Caption := 'PowerMiner - by uncfan1119            Villavu.com';
      frmDesign.Color := clBtnFace;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -11;
      frmDesign.Font.Name := 'MS Sans Serif';
      frmDesign.Font.Style := [];
      frmDesign.PixelsPerInch := 96;
      Label1 := TLabel.Create(frmDesign);
      Label1.Parent := frmDesign;
      Label1.Left := 96;
      Label1.Top := 8;
      Label1.Width := 44;
      Label1.Height := 13;
      Label1.Caption := 'Player [0]';
      Label2 := TLabel.Create(frmDesign);
      Label2.Parent := frmDesign;
      Label2.Left := 360;
      Label2.Top := 8;
      Label2.Width := 44;
      Label2.Height := 13;
      Label2.Caption := 'Player [1]';
      Label3 := TLabel.Create(frmDesign);
      Label3.Parent := frmDesign;
      Label3.Left := 96;
      Label3.Top := 96;
      Label3.Width := 44;
      Label3.Height := 13;
      Label3.Caption := 'Player [2]';
      Label4 := TLabel.Create(frmDesign);
      Label4.Parent := frmDesign;
      Label4.Left := 360;
      Label4.Top := 96;
      Label4.Width := 44;
      Label4.Height := 13;
      Label4.Caption := 'Player [3]';
      Edit1 := TEdit.Create(frmDesign);
      Edit1.Parent := frmDesign;
      Edit1.Left := 64;
      Edit1.Top := 32;
      Edit1.Width := 121;
      Edit1.Height := 21;
      Edit1.TabOrder := 8;
      Edit1.Text := 'Username';
      Edit2 := TEdit.Create(frmDesign);
      Edit2.Parent := frmDesign;
      Edit2.Left := 64;
      Edit2.Top := 64;
      Edit2.Width := 121;
      Edit2.Height := 21;
      Edit2.TabOrder := 9;
      Edit2.Text := 'Password';
      ComboBox1 := TComboBox.Create(frmDesign);
      ComboBox1.Parent := frmDesign;
      ComboBox1.Left := 200;
      ComboBox1.Top := 32;
      ComboBox1.Width := 65;
      ComboBox1.Height := 21;
      ComboBox1.ItemHeight := 13;
      ComboBox1.TabOrder := 10;
      ComboBox1.Text := 'Ore';
      ComboBox1.Items.Add('Copper');
      ComboBox1.Items.Add('Tin');
      ComboBox1.Items.Add('Both');
      Edit3 := TEdit.Create(frmDesign);
      Edit3.Parent := frmDesign;
      Edit3.Left := 328;
      Edit3.Top := 32;
      Edit3.Width := 121;
      Edit3.Height := 21;
      Edit3.TabOrder := 11;
      Edit3.Text := 'Username';
      Edit4 := TEdit.Create(frmDesign);
      Edit4.Parent := frmDesign;
      Edit4.Left := 328;
      Edit4.Top := 64;
      Edit4.Width := 121;
      Edit4.Height := 21;
      Edit4.TabOrder := 12;
      Edit4.Text := 'Password';
      ComboBox2 := TComboBox.Create(frmDesign);
      ComboBox2.Parent := frmDesign;
      ComboBox2.Left := 464;
      ComboBox2.Top := 32;
      ComboBox2.Width := 65;
      ComboBox2.Height := 21;
      ComboBox2.ItemHeight := 13;
      ComboBox2.TabOrder := 13;
      ComboBox2.Text := 'Ore';
      ComboBox2.Items.Add('Copper');
      ComboBox2.Items.Add('Tin');
      ComboBox2.Items.Add('Both');
      Edit5 := TEdit.Create(frmDesign);
      Edit5.Parent := frmDesign;
      Edit5.Left := 64;
      Edit5.Top := 120;
      Edit5.Width := 121;
      Edit5.Height := 21;
      Edit5.TabOrder := 14;
      Edit5.Text := 'Username';
      Edit6 := TEdit.Create(frmDesign);
      Edit6.Parent := frmDesign;
      Edit6.Left := 64;
      Edit6.Top := 152;
      Edit6.Width := 121;
      Edit6.Height := 21;
      Edit6.TabOrder := 15;
      Edit6.Text := 'Password';
      ComboBox3 := TComboBox.Create(frmDesign);
      ComboBox3.Parent := frmDesign;
      ComboBox3.Left := 200;
      ComboBox3.Top := 120;
      ComboBox3.Width := 65;
      ComboBox3.Height := 21;
      ComboBox3.ItemHeight := 13;
      ComboBox3.TabOrder := 16;
      ComboBox3.Text := 'Ore';
      ComboBox3.Items.Add('Copper');
      ComboBox3.Items.Add('Tin');
      ComboBox3.Items.Add('Both');
      Edit7 := TEdit.Create(frmDesign);
      Edit7.Parent := frmDesign;
      Edit7.Left := 328;
      Edit7.Top := 120;
      Edit7.Width := 121;
      Edit7.Height := 21;
      Edit7.TabOrder := 17;
      Edit7.Text := 'Username';
      Edit8 := TEdit.Create(frmDesign);
      Edit8.Parent := frmDesign;
      Edit8.Left := 328;
      Edit8.Top := 152;
      Edit8.Width := 121;
      Edit8.Height := 21;
      Edit8.TabOrder := 18;
      Edit8.Text := 'Password';
      ComboBox4 := TComboBox.Create(frmDesign);
      ComboBox4.Parent := frmDesign;
      ComboBox4.Left := 464;
      ComboBox4.Top := 120;
      ComboBox4.Width := 65;
      ComboBox4.Height := 21;
      ComboBox4.ItemHeight := 13;
      ComboBox4.TabOrder := 19;
      ComboBox4.Text := 'Ore';
      ComboBox4.Items.Add('Copper');
      ComboBox4.Items.Add('Tin');
      ComboBox4.Items.Add('Both');
      ComboBox5 := TComboBox.Create(frmDesign);
      ComboBox5.Parent := frmDesign;
      ComboBox5.Left := 464;
      ComboBox5.Top := 64;
      ComboBox5.Width := 65;
      ComboBox5.Height := 21;
      ComboBox5.ItemHeight := 13;
      ComboBox5.TabOrder := 20;
      ComboBox5.Text := 'Active?';
      ComboBox5.Items.Add('True');
      ComboBox5.Items.Add('False');
      ComboBox6 := TComboBox.Create(frmDesign);
      ComboBox6.Parent := frmDesign;
      ComboBox6.Left := 200;
      ComboBox6.Top := 152;
      ComboBox6.Width := 65;
      ComboBox6.Height := 21;
      ComboBox6.ItemHeight := 13;
      ComboBox6.TabOrder := 21;
      ComboBox6.Text := 'Active?';
      ComboBox6.Items.Add('True');
      ComboBox6.Items.Add('False');
      ComboBox7 := TComboBox.Create(frmDesign);
      ComboBox7.Parent := frmDesign;
      ComboBox7.Left := 200;
      ComboBox7.Top := 64;
      ComboBox7.Width := 65;
      ComboBox7.Height := 21;
      ComboBox7.ItemHeight := 13;
      ComboBox7.TabOrder := 22;
      ComboBox7.Text := 'Active?';
      ComboBox7.Items.Add('True');
      ComboBox7.Items.Add('False');
      ComboBox8 := TComboBox.Create(frmDesign);
      ComboBox8.Parent := frmDesign;
      ComboBox8.Left := 464;
      ComboBox8.Top := 152;
      ComboBox8.Width := 65;
      ComboBox8.Height := 21;
      ComboBox8.ItemHeight := 13;
      ComboBox8.TabOrder := 23;
      ComboBox8.Text := 'Active?';
      ComboBox8.Items.Add('True');
      ComboBox8.Items.Add('False');
      Button1 := TButton.Create(frmDesign);
      Button1.OnClick := @ButtonClick;
      Button1.Parent := frmDesign;
      Button1.Left := 264;
      Button1.Top := 182;
      Button1.Width := 65;
      Button1.Height := 25;
      Button1.Caption := 'Start';
      Button1.TabOrder := 24;
    end;

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

    procedure ShowInitFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowInitFormModal;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('ShowInitFormModal', v);
    end;

    procedure MainInitForm;
    begin
      SafeInitForm;
      SafeShowInitFormModal;
      FreeForm(frmDesign);
    end;

    procedure Players;
    begin
      UsernameA := Edit1.Text;
      PasswordA := Edit2.Text;
      ActiveA   := StrToBool(ComboBox5.Text)
      UsernameB := Edit3.Text;
      PasswordB := Edit4.Text;
      ActiveB   := StrToBool(ComboBox6.Text)
      UsernameC := Edit5.Text;
      PasswordC := Edit6.Text;
      ActiveC   := StrToBool(ComboBox7.Text)
      UsernameD := Edit7.Text;
      PasswordD := Edit8.Text;
      ActiveD   := StrToBool(ComboBox8.Text)
      ClearDebug;
      WriteLn('Accounts:');
      WriteLn(' ');
      WriteLn('Username = ' + UsernameA + 'Password = ' + PasswordA + 'Active = ' +ActiveA);
      WriteLn('Username = ' + UsernameB + 'Password = ' + PasswordB + 'Active = ' +ActiveB);
      WriteLn('Username = ' + UsernameC + 'Password = ' + PasswordC + 'Active = ' +ActiveC);
      WriteLn('Username = ' + UsernameD + 'Password = ' + PasswordD + 'Active = ' +ActiveD);
    end;

    begin
      ClearDebug;
      MainInitForm;
      if (EndInitForm) then
        TerminateScript;
      Players;
    end.
    "SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
    -Wizzup?

  4. #4
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    You need to +BoolToStr(ActiveA)+, in:
    SCAR Code:
    'Active = ' +ActiveA

    And, so on

  5. #5
    Join Date
    Sep 2006
    Posts
    322
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Thanks! +Rep (Edit: Your rep is disabled! Oh well)

    But, now I get a
    Code:
    [Runtime Error] : Exception: Access violation at address 00000000. Read of address 00000000 in line 287
    "SRL is the best SCAR community in the World, with the most talented programmers: adjust your volume."
    -Wizzup?

  6. #6
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You are freeing your form before calling on Players; This means all the data entered in your text boxes has been cleared, and you are trying to assign a null value to your variables. Thus causing an Access Violation.

    You can fix this by calling on Players in this procedure:

    SCAR Code:
    procedure MainInitForm;
    begin
      SafeInitForm;
      SafeShowInitFormModal;
      Players;  // Call Players
      FreeForm(frmDesign);  // Before freeing your form.
    end;

  7. #7
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Check boxes are better for active players:

    Player[0].Active := CheckBox1.Checked;

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
  •