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.
Clearing and removing data from table? C#
Discussion in 'Rust Development' started by PaiN, Jul 12, 2015.
-
Wulf Community Admin
For Lua:
datatable = nil
datatable[steamId] = nil -
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. -
Wulf Community Admin
It's pretty much the same, just nullify it. -
Are you using MySQL/SQLite or just a JSON file?
-
Json file
-
I don't know how you are storing an information. But i can show you my example.
I have HashSet of objects.
When plugin is loaded I'm loading my JSON.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 I want to delete data from file I'm do this.Code:StoredData data = Interface.GetMod().DataFileSystem.ReadObject<StoredData>("myData");
Then I'm saving data in file.Code:foreach (Player p in data.Players) { if (p.Id == "whateverID_1209843") { data.Players.Remove(p); } }
Code:Interface.GetMod().DataFileSystem.WriteObject("myData", data);Last edited by a moderator: Jul 12, 2015
