Results 1 to 5 of 5

Thread: crazy form problem

  1. #1
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default crazy form problem

    alright i have my own multiplayer-form that i've spent a while on, and i'm running into a problem loading players..the problem is, that it won't load them it saves fine and you can see by pressing the load player button, it just won't load

    EDIT: you have to save the script first, or it won't save/load properly

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
      Logs, Knife, Axe, CboxDTM, LC, SC, LB, TD, TA, Tree, Tinderbox, Longbow: integer;
      frmDesign : TForm;
      PageControl1 : TPageControl;
      Tabs : Array of TTabSheet;
      Label1, Label2, Label3, Label4 : array of TLabel;
      Label5, Label6 : Tlabel;
      Edit1, Edit2, Edit3, Edit4 : array of TEdit;
      Edit5, Edit6: TEdit;
      Button4 : array of TButton;
      CheckBox1 : array of TCheckBox;
      ComboBox1, ComboBox2 : array of TComboBox;
      Button1, Button2, Button3 : TButton;
      Menu : array of TMenuItem;
      Menu1 : TPopUpMenu;

    Const
      Rundirection = 'n';


    Procedure FormStuff; forward;
    Procedure DeclarePlayers; forward;
    Procedure SaveSettings(Sender : Tobject); forward;

    Procedure PopUpBox(sender : Tobject);
    var x,y,t: integer;
    begin
      GetmousePos(x,y);
      Menu1.Popup(x,y);
    end;

    Procedure AddPlayer(sender : Tobject);
    var t : integer;
    begin
      inc(howmanyplayers);

      SetArrayLength(Tabs, Howmanyplayers);
      SetArrayLength(Label1, Howmanyplayers);
      SetArraylength(Edit1, Howmanyplayers);
      SetArraylength(Edit2, Howmanyplayers);
      SetArraylength(Edit3, Howmanyplayers);
      SetArraylength(Edit4, Howmanyplayers);
      SetArrayLength(label2, Howmanyplayers);
      SetArrayLength(label3, Howmanyplayers);
      SetArrayLength(label4, Howmanyplayers);
      SetArraylength(CheckBox1, Howmanyplayers);
      SetArrayLength(ComboBox1, Howmanyplayers);
      SetArraylength(ComboBox2, Howmanyplayers);
      SetArrayLength(Button4, Howmanyplayers);

      t := howmanyplayers - 1;

      Tabs[t] := TTabSheet.Create(frmDesign);
      Tabs[t].PageControl := PageControl1;
      Tabs[t].Caption := 'Player ' + inttostr(howmanyplayers);
     
      Button4[t] := TButton.Create(frmdesign);
      Button4[t].Parent := Tabs[t];
      Button4[t].Left := 168;
      Button4[t].Top := 235;
      Button4[t].Width := 83;
      Button4[t].Height := 25;
      Button4[t].Caption := 'Save Player';
      Button4[t].TabOrder := 7;
      Button4[t].OnClick := @savesettings;

      Label1[t] := TLabel.Create(frmdesign);
      Label1[t].Parent := Tabs[t];
      Label1[t].Left := 128;
      Label1[t].Top := 144;
      Label1[t].Width := 92;
      Label1[t].Height := 13;
      Label1[t].Caption := 'Before Logging Out';

      Edit1[t] := TEdit.Create(frmdesign);
      Edit1[t].Parent := tabs[t];
      Edit1[t].Left := 64;
      Edit1[t].Top := 32;
      Edit1[t].Width := 89;
      Edit1[t].Height := 21;
      Edit1[t].TabOrder := 0;
      Edit1[t].Text := 'Name';

      Label2[t] := TLabel.Create(frmdesign);
      Label2[t].Parent := Tabs[t];
      Label2[t].Left := 160;
      Label2[t].Top := 32;
      Label2[t].Width := 33;
      Label2[t].Height := 13;
      Label2[t].Caption := 'Name';

      Label3[t] := TLabel.Create(frmdesign);
      Label3[t].Parent := Tabs[t];
      Label3[t].Left := 160;
      Label3[t].Top := 72;
      Label3[t].Width := 46;
      Label3[t].Height := 13;
      Label3[t].Caption := 'Password';

      Label4[t] := TLabel.Create(frmDesign);
      Label4[t].Parent := Tabs[t];
      Label4[t].Left := 128;
      Label4[t].Top := 112;
      Label4[t].Width := 22;
      Label4[t].Height := 13;
      Label4[t].Caption := 'Nick';

      Edit2[t] := TEdit.Create(frmdesign);
      Edit2[t].Parent := tabs[t];
      Edit2[t].Left := 64;
      Edit2[t].Top := 72;
      Edit2[t].Width := 89;
      Edit2[t].Height := 21;
      Edit2[t].TabOrder := 1;
      Edit2[t].Text := 'Password';

      Edit3[t] := TEdit.Create(frmdesign);
      Edit3[t].Parent := tabs[t];
      Edit3[t].Left := 64;
      Edit3[t].Top := 112;
      Edit3[t].Width := 57;
      Edit3[t].Height := 21;
      Edit3[t].TabOrder := 2;
      Edit3[t].Text := 'Nick';

      CheckBox1[t] := TCheckbox.Create(frmdesign);
      CheckBox1[t].Parent := tabs[t];
      CheckBox1[t].Left := 88;
      CheckBox1[t].Top := 240;
      CheckBox1[t].Width := 81;
      CheckBox1[t].Height := 25;
      CheckBox1[t].Caption := '  Active?';
      CheckBox1[t].Checked := True;
      CheckBox1[t].TabOrder := 3;
      CheckBox1[t].TabStop := True;

      Edit4[t] := TEdit.Create(frmdesign);
      Edit4[t].Parent := tabs[t];
      Edit4[t].Left := 64;
      Edit4[t].Top := 144;
      Edit4[t].Width := 57;
      Edit4[t].Height := 21;
      Edit4[t].TabOrder := 4;
      Edit4[t].Text := 'Loads';

      ComboBox1[t] := TComboBox.Create(frmdesign);
      ComboBox1[t].Parent := tabs[t];
      ComboBox1[t].Left := 64;
      ComboBox1[t].Top := 176;
      ComboBox1[t].Width := 145;
      ComboBox1[t].Height := 21;
      ComboBox1[t].ItemHeight := 13;
      ComboBox1[t].TabOrder := 5;
      ComboBox1[t].Text := 'Type of Tree';
      ComboBox1[t].Items.Add('Tree');
      ComboBox1[t].Items.Add('Oak');
      ComboBox1[t].Items.Add('Willow');
      ComboBox1[t].Items.Add('Yew');

      ComboBox2[t] := TComboBox.Create(frmdesign);
      ComboBox2[t].Parent := tabs[t];
      ComboBox2[t].Left := 64;
      ComboBox2[t].Top := 208;
      ComboBox2[t].Width := 145;
      ComboBox2[t].Height := 21;
      ComboBox2[t].ItemHeight := 13;
      ComboBox2[t].TabOrder := 6;
      ComboBox2[t].Text := 'Action on Logs';
      ComboBox2[t].Items.Add('Fletch');
      ComboBox2[t].Items.Add('Burn');
      ComboBox2[t].Items.Add('Drop');
     
      PageControl1.ActivePageIndex := t;
    end;

    Procedure StartButton(sender : Tobject);
    begin
      FrmDesign.modalresult := mrOk;
    end;

    Procedure Loadplayer(sender : Tobject);
    var
      b : integer;
      Thing : string;
    begin
      b := PageControl1.ActivePageIndex;
      Edit1[b].Text := ReadINI(thing,'Name',ScriptPath + 'Power.ini');
      Edit2[b].Text := ReadINI(thing,'Nick',ScriptPath + 'Power.ini');
      Edit3[b].Text := ReadINI(thing,'Password',ScriptPath + 'Power.ini');
      Edit4[b].Text := ReadINI(thing,'Loads',ScriptPath + 'Power.ini');
      Combobox1[b].Text := ReadINI(thing,'Tree',ScriptPath + 'Power.ini');
      Combobox2[b].Text := ReadINI(thing,'Action',ScriptPath + 'Power.ini');
      CheckBox1[b].Checked := StrToBoolDef(ReadINI(thing,'Active',ScriptPath + 'Power.ini'),True);
    end;

    Procedure Form;
    var
      p,l,t: integer;
      Thing : string;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 296;
      frmDesign.Top := 169;
      frmDesign.Width := 439;
      frmDesign.Height := 325;
      frmDesign.Caption := 'Power! by Drizzt';
      frmDesign.Color := clBtnFace;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -11;
      frmDesign.Font.Name := 'MS Sans Serif';
      frmDesign.Font.Style := [];
      frmDesign.Visible := False;
      frmDesign.PixelsPerInch := 96;

      PageControl1 := TPageControl.Create(frmDesign);
      PageControl1.Parent := frmDesign;
      PageControl1.Left := 0;
      PageControl1.Top := 0;
      PageControl1.Width := 273;
      PageControl1.Height := 289;
      PageControl1.TabOrder := 0;

      SetArrayLength(Tabs, 1);
      SetArrayLength(Label1, 1);
      SetArraylength(Edit1, 1);
      SetArraylength(Edit2, 1);
      SetArraylength(Edit3, 1);
      SetArraylength(Edit4, 1);
      SetArrayLength(label2, 1);
      SetArrayLength(label3, 1);
      SetArrayLength(label4, 1);
      SetArraylength(CheckBox1, 1);
      SetArrayLength(ComboBox1, 1);
      SetArraylength(ComboBox2, 1);
      SetArrayLength(Button4, 1);
     
      Howmanyplayers := 1;
      t := Howmanyplayers - 1

      Tabs[t] := TTabSheet.Create(frmDesign);
      Tabs[t].PageControl := PageControl1;
      Tabs[t].Caption := 'Player ' + inttostr(howmanyplayers);

      Label1[t] := TLabel.Create(frmdesign);
      Label1[t].Parent := Tabs[t];
      Label1[t].Left := 128;
      Label1[t].Top := 144;
      Label1[t].Width := 92;
      Label1[t].Height := 13;
      Label1[t].Caption := 'Before Logging Out';

      Edit1[t] := TEdit.Create(frmdesign);
      Edit1[t].Parent := tabs[t];
      Edit1[t].Left := 64;
      Edit1[t].Top := 32;
      Edit1[t].Width := 89;
      Edit1[t].Height := 21;
      Edit1[t].TabOrder := 0;
      Edit1[t].Text := 'Name';
     
      Label2[t] := TLabel.Create(frmdesign);
      Label2[t].Parent := Tabs[t];
      Label2[t].Left := 160;
      Label2[t].Top := 32;
      Label2[t].Width := 33;
      Label2[t].Height := 13;
      Label2[t].Caption := 'Name';

      Label3[t] := TLabel.Create(frmdesign);
      Label3[t].Parent := Tabs[t];
      Label3[t].Left := 160;
      Label3[t].Top := 72;
      Label3[t].Width := 46;
      Label3[t].Height := 13;
      Label3[t].Caption := 'Password';

      Label4[t] := TLabel.Create(frmDesign);
      Label4[t].Parent := Tabs[t];
      Label4[t].Left := 128;
      Label4[t].Top := 112;
      Label4[t].Width := 22;
      Label4[t].Height := 13;
      Label4[t].Caption := 'Nick';

      Edit2[t] := TEdit.Create(frmdesign);
      Edit2[t].Parent := tabs[t];
      Edit2[t].Left := 64;
      Edit2[t].Top := 72;
      Edit2[t].Width := 89;
      Edit2[t].Height := 21;
      Edit2[t].TabOrder := 1;
      Edit2[t].Text := 'Password';

      Edit3[t] := TEdit.Create(frmdesign);
      Edit3[t].Parent := tabs[t];
      Edit3[t].Left := 64;
      Edit3[t].Top := 112;
      Edit3[t].Width := 57;
      Edit3[t].Height := 21;
      Edit3[t].TabOrder := 2;
      Edit3[t].Text := 'Nick';
     
      Button4[t] := TButton.Create(frmdesign);
      Button4[t].Parent := Tabs[t];
      Button4[t].Left := 168;
      Button4[t].Top := 235;
      Button4[t].Width := 83;
      Button4[t].Height := 25;
      Button4[t].Caption := 'Save Player';
      Button4[t].TabOrder := 7;

      CheckBox1[t] := TCheckBox.Create(frmdesign);
      CheckBox1[t].Parent := tabs[t];
      CheckBox1[t].Left := 88;
      CheckBox1[t].Top := 240;
      CheckBox1[t].Width := 81;
      CheckBox1[t].Height := 25;
      CheckBox1[t].Caption := '  Active?';
      CheckBox1[t].Checked := True;
      CheckBox1[t].TabOrder := 3;
      CheckBox1[t].TabStop := True;

      Edit4[t] := TEdit.Create(frmdesign);
      Edit4[t].Parent := tabs[t];
      Edit4[t].Left := 64;
      Edit4[t].Top := 144;
      Edit4[t].Width := 57;
      Edit4[t].Height := 21;
      Edit4[t].TabOrder := 4;
      Edit4[t].Text := 'Loads';

      ComboBox1[t] := TComboBox.Create(frmdesign);
      ComboBox1[t].Parent := tabs[t];
      ComboBox1[t].Left := 64;
      ComboBox1[t].Top := 176;
      ComboBox1[t].Width := 145;
      ComboBox1[t].Height := 21;
      ComboBox1[t].ItemHeight := 13;
      ComboBox1[t].TabOrder := 5;
      ComboBox1[t].Text := 'Type of Tree';
      ComboBox1[t].Items.Add('Tree');
      ComboBox1[t].Items.Add('Oak');
      ComboBox1[t].Items.Add('Willow');
      ComboBox1[t].Items.Add('Yew');

      ComboBox2[t] := TComboBox.Create(frmdesign);
      ComboBox2[t].Parent := tabs[t];
      ComboBox2[t].Left := 64;
      ComboBox2[t].Top := 208;
      ComboBox2[t].Width := 145;
      ComboBox2[t].Height := 21;
      ComboBox2[t].ItemHeight := 13;
      ComboBox2[t].TabOrder := 6;
      ComboBox2[t].Text := 'Action on Logs';
      ComboBox2[t].Items.Add('Fletch');
      ComboBox2[t].Items.Add('Burn');
      ComboBox2[t].Items.Add('Drop');
     
      Menu1 := Tpopupmenu.create(frmDesign);
      p := strtointdef(ReadINI('Players','Howmany',ScriptPath + 'Power.ini'),0);
      SetArrayLength(Menu,p);
      for t := 0 to p - 1 do
      begin
        thing := 'Player' + inttostr(t);
        Menu[t] := TMenuItem.Create(frmDesign);
        Menu[t].Caption := ReadINI(thing,'Name',ScriptPath + 'Power.ini');
        Menu[t].OnClick := @loadplayer;
        Menu1.Items.Add(Menu[t]);
      end;

      Button1 := TButton.Create(frmDesign);
      Button1.Parent := frmDesign;
      Button1.Left := 296;
      Button1.Top := 239;
      Button1.Width := 81;
      Button1.Height := 25;
      Button1.Caption := 'Start';
      Button1.TabOrder := 9;
      Button1.onclick  := @StartButton;

      Button2 := TButton.Create(frmDesign);
      Button2.Parent := frmDesign;
      Button2.Left := 288;
      Button2.Top := 183;
      Button2.Width := 97;
      Button2.Height := 25;
      Button2.Caption := 'Add Player';
      Button2.TabOrder := 10;
      Button2.OnClick := @Addplayer;
     
      Button3 := TButton.Create(frmDesign);
      Button3.Parent := frmDesign;
      Button3.Left := 288;
      Button3.Top := 127;
      Button3.Width := 97;
      Button3.Height := 25;
      Button3.Caption := 'Load Player';
      Button3.TabOrder := 13;
      Button3.OnClick := @PopUpBox;
     
      Label5 := TLabel.Create(frmDesign);
      Label5.Parent := frmDesign;
      Label5.Left := 288;
      Label5.Top := 48;
      Label5.Width := 97;
      Label5.Height := 13;
      Label5.Alignment := taCenter;
      Label5.Caption := 'SRL ID';

      Label6 := TLabel.Create(frmDesign);
      Label6.Parent := frmDesign;
      Label6.Left := 288;
      Label6.Top := 96;
      Label6.Width := 97;
      Label6.Height := 13;
      Label6.Alignment := taCenter;
      Label6.Caption := 'SRL Password';
     
      Edit5 := TEdit.Create(frmDesign);
      Edit5.Parent := frmDesign;
      Edit5.Left := 288;
      Edit5.Top := 72;
      Edit5.Width := 97;
      Edit5.Height := 21;
      Edit5.TabOrder := 3;
      Edit5.Text := ReadINI('Stats','ID',Scriptpath + 'power.ini');

      Edit6 := TEdit.Create(frmDesign);
      Edit6.Parent := frmDesign;
      Edit6.Left := 288;
      Edit6.Top := 24;
      Edit6.Width := 97;
      Edit6.Height := 21;
      Edit6.TabOrder := 4;
      Edit6.Text := ReadINI('Stats','Password',Scriptpath + 'power.ini');

      Pagecontrol1.Activepageindex := 0;
    end;

    Procedure DeclarePlayers;
    var p : integer;
    begin
      NumberOfplayers(howmanyplayers);
      Currentplayer := 0

      for p := 0 to Howmanyplayers - 1 do
      begin
        Players[p].Name := Edit1[p].text; //username
        Players[p].Pass := Edit2[p].text; //password
        Players[p].Nick := Edit3[p].text; //3-4 letters from your username
        Players[p].Integers[0] := StrToIntdef(Edit4[p].text,1); //loads per logout
        Players[p].Strings[1] := Combobox1[p].text; //Tree, Willow, Yew, Etc.
        Players[p].Strings[0] := Combobox2[p].text; //What to do? Ex.'Fletch','Burn','Drop'
        Players[p].Active := CheckBox1[p].checked;
      end;
    end;

    Procedure SafeInitForm;
    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 SaveStats;
    begin
      WriteINI('Stats','Password',Edit6.text,ScriptPath + 'Power.ini');
      WriteINI('Stats','ID',Edit5.text,ScriptPath + 'Power.ini');
    end;

    Procedure SaveSettings(sender : TObject);
    var
      v, p, d : integer;
      thing : string;
    begin
      DeclarePlayers;
      p := strtointdef(ReadINI('Players','Howmany',ScriptPath + 'Power.ini'),0)
      d := PageControl1.ActivePageIndex;
      thing := 'Player'+ inttostr(p);
      WriteINI(thing,'Name',Players[d].name,ScriptPath + 'Power.ini');
      WriteINI(thing,'Nick',Players[d].nick,ScriptPath + 'Power.ini');
      WriteINI(thing,'Password',Players[d].pass,ScriptPath + 'Power.ini');
      WriteINI(thing,'Loads',inttostr(Players[d].Integers[0]),ScriptPath + 'Power.ini');
      WriteINI(thing,'Tree',Players[d].Strings[1],ScriptPath + 'Power.ini');
      WriteINI(thing,'Action',Players[d].Strings[0],ScriptPath + 'Power.ini');
      WriteINI(thing,'Active',BooltoStr(Players[d].Active),ScriptPath + 'Power.ini');
      WriteINI('Players','Howmany', inttostr(p + 1),ScriptPath + 'Power.ini');
    end;

    Procedure FormStuff;
    begin
      safeinitform;
      SafeShowFormModal;
      DeclarePlayers;
      SaveStats;
    end;

    begin
      SetupSRL;
      FormStuff;
    end.
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

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

    Default

    You don't define 'thing' in LoadPlayer, so it tries to load from the '' section, which will have nothing so it is blank. You have to make it so that it sends the players name that you want to laod to it or use where it stores that and use that, so 'thing' has 'jude' or 'te3h1337ch4r' or whatever the name is Though I must warn you, you save the settings as player0 rather than the name of the char, so it may get difficult.
    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
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    well if i save the section as the player name i can't load it, and i tried defining thing, but i can't because it like, doesnt like to load global vars that have been set

    EDIT: i figured it out, it works now
    EDIT: EDIT: no, turns out i didn't figure it out
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  4. #4
    Join Date
    Jan 2008
    Location
    U.S.A
    Posts
    313
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Don't Wanna Spam Or Anything
    but I Put in Smart It loaded and ran
    also put ActivateClient; above
    saveinitform;

    It Ran Until I minimized scar and entered information in the form

    Ill keep trying later but im tired right now
    Will test most scripts, offering members account to certain scripters! PM Me.
    Also need helping making a powerminer, Pst/Aim me!

  5. #5
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by goldrush655 View Post
    Don't Wanna Spam Or Anything
    but I Put in Smart It loaded and ran
    also put ActivateClient; above
    saveinitform;

    It Ran Until I minimized scar and entered information in the form

    Ill keep trying later but im tired right now
    i got the problem figured out, my problem wasn't with it running, it was with it saving & loading players. but thanks anyway.
    also, you can see the full thing in action at "power! beta by drizzt" in hybrid scripts section jr. mems
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Form Problem
    By Rulerofall in forum OSR Help
    Replies: 1
    Last Post: 12-27-2007, 01:14 AM
  2. Form Problem
    By Macho Man67 in forum OSR Help
    Replies: 3
    Last Post: 11-15-2007, 04:04 AM
  3. Advanced Form Problem
    By samoates1112 in forum OSR Help
    Replies: 14
    Last Post: 05-14-2007, 02:34 PM

Posting Permissions

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