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
C#Code:{ "Entries": [ 123456789987654 : "127.0.0.1" ] }
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"); }
Creating dictionary from data file?
Discussion in 'Rust Development' started by Crushed, Feb 28, 2018.
-
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();
-
Wulf Community Admin
-
-
Wulf Community Admin
-
-
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
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