Results 1 to 7 of 7

Thread: Saving a player array [form]

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Saving a player array [form]

    Hey
    Looking through tuts and scripts and the srl player form didn't really help me too much on this... Sooooo, how would I go about saving a player array with these values:

    Players[cp].Name
    Players[cp].Pass
    Players[cp].Nick
    Players[cp].Pin
    Players[cp].Active
    Players[cp].strings[0]
    Players[cp].strings[1]
    Players[cp].strings[2]
    Players[cp].strings[3]
    Players[cp].Booleans[0]
    Players[cp].Booleans[1]
    Players[cp].Booleans[2]
    Players[cp].Booleans[3]
    Players[cp].Integers[0]
    Players[cp].Integers[1]
    Players[cp].Integers[2]

    I really know nothing about saving/opening except that you need to use .ini files, which I know nothing about either... thanks a lot in advance... btw, I would really appreciate an explanation.
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Create a file with the scar createfile(use F1 in scar)
    Loop through those players[c] then WriteINI('Section','Players' + IntToStr(I), "Value")
    Should work.
    ~Hermen

  3. #3
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    erm, there is no create file function...
    There is nothing right in my left brain and there is nothing left in my right brain.

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    WriteFileString with an empty string creates a file.

  5. #5
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    WriteFileString(FileNum: Integer; s: string): Boolean;

    What does FileNum mean? :S
    There is nothing right in my left brain and there is nothing left in my right brain.

  6. #6
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The file handle.

    You can set it with OpenFile or RewriteFile.

    Also:

    SCAR Code:
    procedure WritePlayerToINI(PlayerNum : integer; Filename : string);
    var
      i : integer;
    begin
      WriteINI('Player' + IntToStr(PlayerNum), 'Name', Players[PlayerNum].Name, Filename);
      WriteINI('Player' + IntToStr(PlayerNum), 'Pass', Players[PlayerNum].Pass, Filename);
      WriteINI('Player' + IntToStr(PlayerNum), 'Nick', Players[PlayerNum].Nick, Filename);
      WriteINI('Player' + IntToStr(PlayerNum), 'Pin', Players[PlayerNum].Pin, Filename);
      WriteINI('Player' + IntToStr(PlayerNum), 'Active', BoolToStr(Players[PlayerNum].Active), Filename);
      for i := 0 to 3 do
        WriteINI('Player' + IntToStr(PlayerNum), 'Strings' + IntToStr(i), Players[PlayerNum].Strings[i], Filename);
      for i := 0 to 3 do
        WriteINI('Player' + IntToStr(PlayerNum), 'Booleans' + IntToStr(i), BoolToStr(Players[PlayerNum].Booleans[i]), Filename);
      for i := 0 to 2 do
        WriteINI('Player' + IntToStr(PlayerNum), 'Integers' + IntToStr(i), IntToStr(Players[PlayerNum].Integers[i]), Filename);
    end;
    Last edited by Da 0wner; 07-04-2009 at 05:30 AM.

  7. #7
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks a million Da Owner, finally I understood that part
    There is nothing right in my left brain and there is nothing left in my right brain.

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
  •