using Newtonsoft.Json; namespace Oxide.Plugins { [Info("AutoNotification", "discord -> fermens#8767", "1.0.0")] [Description("Auto-alerts in chat")] class AutoNotification : RustPlugin { #region Config private PluginConfig config; protected override void LoadDefaultConfig() { config = PluginConfig.DefaultConfig(); } protected override void LoadConfig() { base.LoadConfig(); config = Config.ReadObject(); } protected override void SaveConfig() { Config.WriteObject(config); } private class PluginConfig { [JsonProperty("Message text")] public string[] messages; [JsonProperty("Message sending interval")] public float time; [JsonProperty("SteamId who sends [for avatar]")] public ulong icon; public static PluginConfig DefaultConfig() { return new PluginConfig() { messages = new string[] { "[HAXLITE] There is an info menu on the server.\n/info", "[HAXLITE] Wipe every Friday at 15:00 Moscow time\n/info", "[HAXLITE] Join us on our discord channel to stay up to date with the latest changes on the server.\nds.haxlite.ru", "[HAXLITE] There are daily free roulettes in our game store.\nrust.haxlite.ru" }, time = 300f, icon = 1 }; } } #endregion #region Main private int count; private int limit; private void OnServerInitialized() { limit = config.messages.Length; timer.Every(config.time, () => MessageME()); } private void MessageME() { if (count >= limit) count = 0; Server.Broadcast(config.messages[count], config.icon); count++; } #endregion } }