Results 1 to 8 of 8

Thread: MultiPlayer Form Help/BrainStorm!

  1. #1
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Lightbulb MultiPlayer Form Help/BrainStorm!

    K... so the code below is basically outlined from MasterKill's "THE big form tutorial" on how to add a player to a listbox and if said player is clicked on in the list box it will load the saved settings of that player WHILE IN THE SAME INSTANCE so once the form is closed it will no longer remember that player or that players data. You now know my problem ha

    My first question is how can i save and index a player and their info into a Data File when an Add Player button is clicked on. even if they dont enter data in one of the fields

    My second question is how can i load ALL of the players and their info into the list box from the Data File when a Load Players button is clicked

    My third question is when a Delete Player button is clicked on how can u remove that player and their info from the Data File without messing up the index


    ideas/help/examples!?!?
    Thanks

    Simba Code:
    Procedure LoadFP(WhatPlayer: Integer; SaveCurrentInfo: Boolean);
    Var
      I: Integer;
    Begin
    If SaveCurrentInfo Then
      Begin
        FP[CurFP].Name := Edits[0].Text;
        FP[CurFP].Pass := Edits[1].Text;
        FP[CurFP].Nick := Edits[2].Text;
        FP[CurFP].Pin := Edits[3].Text;
        FP[CurFP].NPC := ComboBoxes[0].Text;
        FP[CurFP].Health := ComboBoxes[1].Text;
        FP[CurFP].Food := ComboBoxes[2].Text;

      End;

      ListPlayers.Clear;
      For I := 0 To High(FP) Do
      If (FP[I].Name = '') Then
        ListPlayers.Items.Add(IntToStr(I) + ': ?')
      Else
        ListPlayers.Items.Add(IntToStr(I) + ': ' + FP[I].Name);

      CurFP := WhatPlayer;
      ListPlayers.ItemIndex := CurFP;
      Edits[0].Text := FP[CurFP].Name;
      Edits[1].Text := FP[CurFP].Pass;
      Edits[2].Text := FP[CurFP].Nick;
      Edits[3].Text := FP[CurFP].Pin;
      ComboBoxes[0].Text := FP[CurFP].NPC;
      ComboBoxes[1].Text := FP[CurFP].Health;
      ComboBoxes[2].Text := FP[CurFP].Food;

      Buttons[3].Enabled := (GetArrayLength(FP) > 1); //this prevents the listbox from being empty, always 1 player in it

    End;

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  2. #2
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Not played with new simba/ srl-6 much yet but doesn't it have a new player manager added which does this a lot more secure now as it encrypts passwords ect ect.

    Worth a good look.
    Previously Known or not Known as CRU1Z1N.
    If you want to succeed you should strike out on new paths, rather than travel the worn paths of accepted success.(John D. Rockefeller)

  3. #3
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    thanks, ill check it out when i update simba. ive been trying to figure this out on and off for a few months now so im determined to get it :P lol

    ive got the first part down and done (thanks to the help of Kevin)

    currently stuck on the second part with this (thanks to riwu for the file help)

    How can i make it so this code takes the Name of each File in the folder, reads it, and adds the 'Name' of that file to the ListPlayers box? Ive tried assigning variables to all the form fields and attempted to make arrays but i kept getting type mismatch errors and idk ha. Currently the PlayerSettingsFile just goes to the Folder, so its not finding/reading any files

    any help or tuts please?
    Simba Code:
    procedure LoadFormFields;
    var
      PlayerSettingsFileNumber, i: integer;
    begin

      PlayerSettingsFile := AppPath + 'ibot11s PS File\'; //how can i add the name of the ith player in the File
      writeln(GetFiles(PlayerSettingsFile, 'ini'));
      writeln(Length(GetFiles(PlayerSettingsFIle, 'ini')));

      PlayerSettingsFileNumber := Length(GetFiles(PlayerSettingsFile, 'ini'));
      writeln(PlayerSettingsFileNumber);

      if(not FileExists(PlayerSettingsFile))then
      begin
        writeLn('File not found');
        Exit;
      end else

      //for i := 0 to High(PlayerSettingsFileNumber) do
      Edits[0].Text:= ReadINI('Settings', 'Name', PlayerSettingsFile);
      Edits[1].Text:= ReadINI('Settings', 'Pass', PlayerSettingsFile);
      Edits[2].Text:= ReadINI('Settings', 'Nick', PlayerSettingsFile);
      Edits[3].Text:= ReadINI('Settings', 'Pin', PlayerSettingsFile);
      ComboBoxes[0].Text:= ReadINI('Settings', 'NPC', PlayerSettingsFile);
      ComboBoxes[1].Text:= ReadINI('Settings', 'Health', PlayerSettingsFile);
      ComboBoxes[2].Text:= ReadINI('Settings', 'Food', PlayerSettingsFile);

      ListPlayers.Clear;
      ListPlayers.Items.Add(IntToStr(i) + ': ' + Edits[0].Text);

    end;

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  4. #4
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    My second question is how can i load ALL of the players and their info into the list box from the Data File when a Load Players button is clicked

    My third question is when a Delete Player button is clicked on how can u remove that player and their info from the Data File without messing up the index
    2)So, is this an empty list box prior to load players button being clicked, and then we're simply populating this one box with the options; or are we populating every form value for every single player?

    3)You can't. When you delete the player, you'll have to manually change the index to a value lower if that was the current or a previous player name. Also, either way, you will need to reload the available list.

    Edit: as for the more recent post involving adding multiple available files to load from I do this in my slayer script:
    Simba Code:
    files:= GetFiles(AppPath, 'ini'); //TStringArray
      for i:=0 to high(files) do
      begin
        comboBoxes[2].Items.Add(files[i]);
      end;

  5. #5
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Kevin View Post
    2)So, is this an empty list box prior to load players button being clicked, and then we're simply populating this one box with the options; or are we populating every form value for every single player?

    3)You can't. When you delete the player, you'll have to manually change the index to a value lower if that was the current or a previous player name. Also, either way, you will need to reload the available list.

    Edit: as for the more recent post involving adding multiple available files to load from I do this in my slayer script:
    Simba Code:
    files:= GetFiles(AppPath, 'ini'); //TStringArray
      for i:=0 to high(files) do
      begin
        comboBoxes[2].Items.Add(files[i]);
      end;
    musta missed it in ur script, i tried putting everything in a array, i didnt think of just that- thanks.

    i want the list box to be populated upon the form opening or a Load Players button clicked. When a player is clicked on in the list box that player will be loaded into all of the Form fields

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  6. #6
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    I accidentally read this at a bad time. re-ping me with quote/mention and I also did exactly what you want in the slayer script with LoadForm (the pinging will get me to add the code later, or you can find it yourself )

  7. #7
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by Kevin View Post
    I accidentally read this at a bad time. re-ping me with quote/mention and I also did exactly what you want in the slayer script with LoadForm (the pinging will get me to add the code later, or you can find it yourself )
    ill see if i can read through it again in the mean time and ask any questions when you post it, you had a lot of stuff you were saving and loading and things going on inbetween. thanks man

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  8. #8
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Thanks for the quote to remind me about this lol
    Simba Code:
    //The check if a settings file is already around, and if so, load those settings into our form
    procedure LoadForm(Sender: TObject);
    var
      equipmentList: TStringArray;
      i: integer;
    begin
      SaveFileName:= AppPath + comboBoxes[2].ITEMS[comboBoxes[2].ITEMINDEX];//Read's the combo box that contains the file name options (players) and sets it as the designated load from file
      if(not FileExists(SaveFileName))then
        Exit;//don't load something that doesn't exist
      try//fill in all the text and whatnot boxes with the values saved in the file.
        textBoxes[0].Caption:= ReadINI('Settings', 'PlayerName', SaveFileName);
        textBoxes[1].Caption:= ReadINI('Settings', 'PlayerPassword', SaveFileName);
        textBoxes[2].Caption:= ReadINI('Settings', 'PlayerPin', SaveFileName);
        textBoxes[3].Caption:= ReadINI('Settings', 'HealthToRun', SaveFileName);
        textBoxes[4].Caption:= ReadINI('Settings', 'HealthToEat', SaveFileName);
        textBoxes[5].Caption:= ReadINI('Settings', 'FoodString', SaveFileName);
        textBoxes[6].Caption:= ReadINI('Settings', 'BreakLengthMin', SaveFileName);
        textBoxes[7].Caption:= ReadINI('Settings', 'BreakLengthMax', SaveFileName);
        textBoxes[8].Caption:= ReadINI('Settings', 'TimeTillBreakMin', SaveFileName);
        textBoxes[9].Caption:= ReadINI('Settings', 'TimeTillBreakMax', SaveFileName);
        textBoxes[10].Caption:= ReadINI('Settings', 'UltimateSlot', SaveFileName);
        textBoxes[11].Caption:= ReadINI('Settings', 'ThresholdSlot', SaveFileName);
        textBoxes[12].Caption:= ReadINI('Settings', 'MaxPlayers', SaveFileName);
        textBoxes[13].Caption:= ReadINI('Settings', 'FoodQuantity', SaveFileName);
        comboBoxes[0].ItemIndex:= StrToInt(ReadINI('Settings', 'TotalXPBar', SaveFileName));
        comboBoxes[1].ItemIndex:= StrToInt(ReadINI('Settings', 'SlayerXPBar', SaveFileName));
        checkBoxes[0].Checked:= StrToBool(ReadINI('Settings', 'ImplementBreaks', SaveFileName));
        checkBoxes[1].Checked:= StrToBool(ReadINI('Settings', 'AFKBreaks', SaveFileName));
        checkBoxes[2].Checked:= StrToBool(ReadINI('Settings', 'SmartProggy', SaveFileName));
        checkBoxes[3].Checked:= StrToBool(ReadINI('Settings', 'TextProggy', SaveFileName));
        checkBoxes[4].Checked:= StrToBool(ReadINI('Settings', 'SmartDebug', SaveFileName));
        checkBoxes[5].Checked:= StrToBool(ReadINI('Settings', 'ObjectDebug', SaveFileName));
        checkBoxes[6].Checked:= StrToBool(ReadINI('Settings', 'TextDebug', SaveFileName));
        checkBoxes[7].Checked:= StrToBool(ReadINI('Settings', 'LootEffigies', SaveFileName));
        checkBoxes[8].Checked:= StrToBool(ReadINI('Settings', 'LootSpecialBones', SaveFileName));
        checkBoxes[9].Checked:= StrToBool(ReadINI('Settings', 'LootCharms', SaveFileName));
        checkBoxes[10].Checked:= StrToBool(ReadINI('Settings', 'LootStuff', SaveFileName));
        checkBoxes[11].Checked:= StrToBool(ReadINI('Settings', 'UsePotions', SaveFileName));
      except
        WriteLn('The file you chose to load has an error in it!');
      end;
    end;

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
  •