1. So i've managed with some help to write and retrieve "info" from data file.
    BUT i dont know how to:
    1. Clear all the data file.
    2. Remove a single line (for example the written earlier steamid)

    Thanks for any help.
     
  2. Wulf

    Wulf Community Admin

    For Lua:

    datatable = nil

    datatable[steamId] = nil
     
  3. Forgot to mention.. that i need c# example

    I will check the lua ones and like "convert" them to c#
    Nah.. still no luck. But i will wait for C# ex.
     
  4. Wulf

    Wulf Community Admin

    It's pretty much the same, just nullify it.
     
  5. Are you using MySQL/SQLite or just a JSON file?
     
  6. Json file
     
  7. I don't know how you are storing an information. But i can show you my example.
    I have HashSet of objects.
    Code:
    class StoredData
    {
        public HashSet<Player> Players = new HashSet<Player>();    public StoredData() {}
    }class Player
    {
        public ulong Id;
        public int   Count = 0;    public Player() {}   public Player(ulong id)
       {
          Id = id;
       }
    }
    When plugin is loaded I'm loading my JSON.
    Code:
    StoredData data = Interface.GetMod().DataFileSystem.ReadObject<StoredData>("myData");
    When I want to delete data from file I'm do this.
    Code:
    foreach (Player p in data.Players)
    {
        if (p.Id == "whateverID_1209843")
        {
            data.Players.Remove(p);
        }
    }
    Then I'm saving data in file.
    Code:
    Interface.GetMod().DataFileSystem.WriteObject("myData", data);
     
    Last edited by a moderator: Jul 12, 2015