using Oxide.Game.Rust.Cui; using UnityEngine; namespace Oxide.Plugins { [Info("Server Offline Redirect", "ChatGPT", "1.0.0")] [Description("Shows a CUI message on join and redirects players to another server.")] public class ServerOfflineRedirect : RustPlugin { private const string UIName = "ServerOfflineRedirectUI"; private const string RedirectIP = "rust.sofgame.zone"; private const int RedirectPort = 28015; void OnPlayerSleepEnded(BasePlayer player) { if (player == null || !player.IsConnected) return; timer.Once(1f, () => { if (player == null || !player.IsConnected) return; ShowUI(player); }); } void Unload() { foreach (var player in BasePlayer.activePlayerList) { DestroyUI(player); } } private void ShowUI(BasePlayer player) { DestroyUI(player); var container = new CuiElementContainer(); // Background panel container.Add(new CuiPanel { Image = { Color = "0 0 0 0.85" }, RectTransform = { AnchorMin = "0.3 0.35", AnchorMax = "0.7 0.65" }, CursorEnabled = true }, "Overlay", UIName); // Main text container.Add(new CuiLabel { Text = { Text = "Server Offline This Month While Moving House\n\nHow About Trying Our PVE Server For A Wipe", FontSize = 22, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" }, RectTransform = { AnchorMin = "0.05 0.35", AnchorMax = "0.95 0.9" } }, UIName); // Try It button container.Add(new CuiButton { Button = { Color = "0.2 0.6 0.2 1", Command = "serveroffline.tryit", Close = UIName }, RectTransform = { AnchorMin = "0.35 0.1", AnchorMax = "0.65 0.28" }, Text = { Text = "Try It", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, UIName); CuiHelper.AddUi(player, container); } private void DestroyUI(BasePlayer player) { CuiHelper.DestroyUi(player, UIName); } [ConsoleCommand("serveroffline.tryit")] private void TryItCommand(ConsoleSystem.Arg arg) { var player = arg.Player(); if (player == null || player.Connection == null) return; ConsoleNetwork.SendClientCommandImmediate( player.Connection, "nexus.redirect", new object[] { RedirectIP, RedirectPort, "" } ); } } }