C#:
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("Run Server Settings", "WOLF#4002", "1.0.0")]
[Description("")]
class RUNCommands : RustPlugin
{
class Com
{
[JsonProperty("COMMANDS")]
public Dictionary<string, string> comma;
}
private class Configuration
{
[JsonProperty("SETTINGS COMMANDS")]
public Com Comm;
public static Configuration Generate()
{
return new Configuration
{
Comm = new Com
{
comma = new Dictionary<string, string>
{
{"weather.fog 0", "туман || fog"},
{"weather.rain 0", "дождь || rain"},
{"weather.wind 9", "ветер || wind"},
} ,
}
};
}
}
private static Configuration Settings = null;
protected override void LoadConfig()
{
base.LoadConfig();
try
{
Settings = Config.ReadObject<Configuration>();
}
catch
{
PrintWarning($"Error reading config, creating one new config!");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void LoadDefaultConfig() => Settings = Configuration.Generate();
protected override void SaveConfig() => Config.WriteObject(Settings);
private void OnServerInitialized()
{
foreach (var u in Settings.Comm.comma)
{
PrintWarning($"{u.Value}");
rust.RunServerCommand($"{u.Key}");
}
}
}
}