using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Libraries.Covalence; using UnityEngine; using System; namespace Oxide.Plugins { [Info("EffectTimer", "Kaho", "1.0.1")] [Description("Plays an effect to all players on the server when triggered by an RCON command")] public class EffectTimer : RustPlugin { private Timer effectTimer; private void Init() { permission.RegisterPermission("effecttimer.use", this); AddCovalenceCommand("effecttimer", "cmdEffectTimer"); } private void cmdEffectTimer(IPlayer player, string command, string[] args) { if (!player.HasPermission("effecttimer.use")) { player.Reply("You don't have permission to use this command."); return; } if (args.Length < 2) { player.Reply("Usage: effecttimer length broadcast text"); return; } float length; if (!float.TryParse(args[0], out length)) { player.Reply("Invalid Timer length"); return; } string message = string.Join(" ", args, 1, args.Length - 1); foreach (var basePlayer in BasePlayer.activePlayerList) { Alert(basePlayer.transform.position, basePlayer.Connection, message); } CreateBroadcastTipAll(message, length); Puts($"Effect and GameTip played by {player.Name}!"); } private void Alert(Vector3 position, Network.Connection connection, string message) { var effect = new Effect(); effect.Init(Effect.Type.Generic, position, Vector3.zero); effect.pooledString = "assets/bundled/prefabs/fx/invite_notice.prefab"; EffectNetwork.Send(effect, connection); } private void Alert(BasePlayer player, string message) => Alert(player.transform.position, player.Connection, message); private void CreateBroadcastTip(string text, BasePlayer player, float length = 30f) { if (player == null) return; player.SendConsoleCommand("gametip.hidegametip"); player.SendConsoleCommand("gametip.showgametip", text); timer.Once(length, () => player?.SendConsoleCommand("gametip.hidegametip")); } private void CreateBroadcastTipAll(string text, float length = 30f) { foreach (BasePlayer player in BasePlayer.activePlayerList) CreateBroadcastTip(text, player, length); } private void Unload() { if (effectTimer != null && !effectTimer.Destroyed) { effectTimer.Destroy(); } } } }