1. Well im kinda stuck even cause im still struggling with things like Arrays, Lists or dictionaries.
    Even tho, what im trying seems kinda relatively simple :

    I would just need a dictionary <ulong,string> to use for some verification stuff.
    I did already wrote the code and use it, but having every code and value within the method itself looks just messy and is inconvenient for everyone thats using it.

    And as i , so far, wrote all the time all the code within the plugin, and never really setup configs for my stuff, im stuck on it ...

    What it somehow should look like and what i got so far :


    --Example--
    Json
    Code:
    {
      "Entries": [
        123456789987654 :    "127.0.0.1"
    ]
    }
    
    C#
    Code:
    class StoredData
            {
                public Dictionary<ulong, string> Entries = new Dictionary<ulong, string>();            public StoredData()
                {
                }
            }
            StoredData storedData;        void Loaded()
            {
                storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>("PluginName");
            }
     
  2. Code:
    // System.Collections.Generic and Oxide.Core, written without an IDE, but should work correctly.
    // If it's data that doesn't necessarily change very quickly, set this to true when you change data, otherwise omit the variable.
    private Dictionary<ulong, string> _playerData = new Dictionary<ulong, string>();private bool _dataChanged;private void SaveData()
    {
        if (!_dataChanged)
        {
            return;
        }    Interface.Oxide.DataFileSystem.WriteObject($"{Name}Data", _playerData);
        _dataChanged = false;
    }private void Init() => _playerData = Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, string>>($"{Name}Data");private void OnServerSave() => SaveData();private void Unload() => SaveData();
     
  3. Wulf

    Wulf Community Admin

    I'd suggest using Name, not $"{Name}Data" as adding the Data is redundant.
     
  4. I disagree, I still think the file should contain Data, as it describes the contents. Personal preference, it's just like prefixing variables with "this" for clarification.
     
  5. Wulf

    Wulf Community Admin

    Perhaps, just thought that being under oxide/data made it clarified enough; though I understand your point.
     
  6. You'd think it would be clear enough, but the same people who post a thread every time there's a Rust update and Oxide is broken are the ones who are going to be confusing the data and config files, even in obviously different directories. ;)
     
  7. In general true. Speaking of my question here, that what i want to build is only for me anyway.
    I was cleaning up some own code stuff in plugins for the wipe and thought it would just be nice to have it use the datafiles instead of a messy, code-filled plugin. Not only for the sake of being nice and clean, but also to even learn it a bit more to use it :p

    Edit :

    I finished writing that now, works nice.
    And a question came to mind.
    I never saw that, on a plugin, but is it possible to use like a "live" data version?
    I mean, so that you can edit and save the datafile and it gets used without reloading.
    The only thing that i could think of would be a webrequest....
     
    Last edited by a moderator: Mar 1, 2018