using Newtonsoft.Json; using Network; using Newtonsoft.Json.Linq; using Oxide.Core; using Oxide.Core.Configuration; using Oxide.Core.Libraries.Covalence; using Oxide.Core.Libraries; using Oxide.Core.Plugins; using Oxide.Game.Rust.Cui; using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using UnityEngine; using Facepunch.Models; using System.Collections.Specialized; using System.Text.RegularExpressions; using Rust; namespace Oxide.Plugins { [Info("ZPunisher", "Zeeuss", "0.1.0")] [Description("Utility to punish players with ease")] public class ZPunisher : RustPlugin { #region Init void Init() { string permUse = "zpunisher.use"; permission.RegisterPermission(permUse, this); AddCovalenceCommand("zpunisher.freeze", "freezeCommand", permUse); AddCovalenceCommand("zpunisher.unfreeze", "unfreezeCommand", permUse); AddCovalenceCommand("zpunisher.lag", "lagCommand", permUse); AddCovalenceCommand("zpunisher.stoplag", "stopLagCommand", permUse); AddCovalenceCommand("zpunisher.stop", "stopAllCommand", permUse); AddCovalenceCommand("zpunisher.kill", "killCommand", permUse); AddCovalenceCommand("zpunisher.rocket", "rocketCommand", permUse); AddCovalenceCommand("zpunisher.stoprocket", "stopRocketCommand", permUse); AddCovalenceCommand("zpunisher.ignite", "igniteCmd", permUse); AddCovalenceCommand("zpunisher.extinguish", "extinguishCmd", permUse); AddCovalenceCommand("zpunisher", "zpunisherGui", permUse); AddCovalenceCommand("zpunisher.close", "zpunisherCloseGui", permUse); AddCovalenceCommand("zpunisher.page.next", "NextPageCommand", permUse); AddCovalenceCommand("zpunisher.page.prev", "PrevPageCommand", permUse); AddCovalenceCommand("customTPCmd", "customTPCommand", permUse); } #endregion #region Fields private int currentPage = 0; string cuiParent = "zpunisher.main.cui"; string pickMenu = "zpunisher.pickmenu.cui"; #endregion #region Localization protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["noPlayer"] = "There's not such a player", ["stopAllSyntax"] = "Syntax: /zpunisher.stop player", ["stoppedAll"] = "Stopped all effects on: {0}", ["freezeSyntax"] = "Syntax: /zpunisher.freeze player", ["startFreeze"] = "Starting to freeze: {0}", ["unfreezeSyntax"] = "Syntax: /zpunisher.unfreeze player", ["stoppedFreezing"] = "Stopped freezing: {0}", ["lagSyntax"] = "Syntax: /zpunisher.lag player", ["startLag"] = "Starting to lag: {0}", ["stopLagSyntax"] = "Syntax: /zpunisher.stoplag player", ["stoppedLag"] = "Stopped lagging: {0}", ["killSyntax"] = "Syntax: /zpunisher.kill player", ["killMsg"] = "You have killed: {0}", ["rocketSyntax"] = "Syntax: /zpunisher.rocket player", ["startRocket"] = "Started rocketing: {0}", ["stopRocketSyntax"] = "Syntax: /zpunisher.stoprocket player", ["stopRocket"] = "Stopped rocketing: {0}", ["igniteSyntax"] = "Syntax: /zpunisher.ignite player", ["startIgnite"] = "Ignited: {0}", ["extSyntax"] = "Syntax: /zpunisher.extinguish player", ["startExt"] = "Poured water on: {0}", ["infoTitle"] = "Target's Info:", ["infoName"] = "Name: {0}", ["infoID"] = "ID: {0}", ["infoIP"] = "IP Address: {0}", ["infoPing"] = "Ping: {0}ms", ["infoStatusAlive"] = "Status: Alive", ["infoStatusDead"] = "Status: Dead", ["infoPos"] = "XYZ Position: {0},{1},{2}", ["infoTPBttn"] = "TP", ["infoRefresh"] = "Refresh", ["choosePl"] = "Choose a player:", ["dsc"] = "..........Description..........", ["freezer"] = "Freezer", ["freezerDsc"] = "Once you execute this command on the player he won't be able to move untill you stop the effect", ["enable"] = "Enable", ["disable"] = "Disable", ["kill"] = "Kill", ["lagger"] = "Lagger", ["lagDsc"] = "Once you execute this command on the player his game will start lagging soon untill he won't be able to do anything/untill his game crashes", ["lagPS"] = "P.S. If you enable this on yourself you must disable it via console - zpunisher.stoplag {Your nick}", ["rocketer"] = "Rocketboy", ["rocketerDsc"] = "Once you execute this command on the player an hv rockets are gonna start spawning in him", ["ignite"] = "Ignite", ["pw"] = "Pour Water", ["killTitle"] = "Simple Kill", ["killDsc"] = "Once you execute this command on the player he will die", ["igniterTitle"] = "Igniter", ["igniterDsc"] = "Once you execute this command a fire will spawn on a player and will follow it untill it disappears", ["stopAllEffects"] = "Stop All Effects!", ["previous"] = "Previous", ["Next"] = "Next" }, this); } #endregion #region Unload void Unload() { ServerMgr.Instance.StopAllCoroutines(); foreach (var player in BasePlayer.activePlayerList) { if (player.HasComponent()) { var ply = player.GetComponent(); GameObject.Destroy(ply); } if (player.HasComponent()) { var plyLag = player.GetComponent(); GameObject.Destroy(plyLag); } if(player.HasComponent()) { var plyRocket = player.GetComponent(); GameObject.Destroy(plyRocket); } CuiHelper.DestroyUi(player, "lagg_ui"); CuiHelper.DestroyUi(player, "zpunisher.finalParent"); } } void OnPlayerDisconnected(BasePlayer player, string reason) { if (player.HasComponent()) { var ply = player.GetComponent(); GameObject.Destroy(ply); } if (player.HasComponent()) { var plyLag = player.GetComponent(); GameObject.Destroy(plyLag); } if (player.HasComponent()) { var plyRocket = player.GetComponent(); GameObject.Destroy(plyRocket); } CuiHelper.DestroyUi(player, "lagg_ui"); } #endregion #region Final GUI etc... void finalPunishGui(IPlayer player, BasePlayer target) { BasePlayer bPlayer = BasePlayer.Find(player.Id); CuiHelper.DestroyUi(bPlayer, cuiParent); CuiElementContainer finalMenu = finalPunishMenu(bPlayer, target); CuiHelper.AddUi(bPlayer, finalMenu); } CuiElementContainer finalPunishMenu(BasePlayer player, BasePlayer target) { var elements = new CuiElementContainer(); IPlayer iTarget = covalence.Players.FindPlayer(target.UserIDString); AddCuiPanel(elements, true, "0 0 0 0.7", "0 0", "1 1", null, null, "Hud", "zpunisher.finalParent"); AddCuiButton(elements, "zpunisher.close", "0.639 0.086 0.086 1", "0.95 0.95", "0.995 0.99", null, null, "x", "0 0 0 1", 15, TextAnchor.MiddleCenter, "zpunisher.finalParent", "zpunisher.closebttn.cui"); // For Target's info..... AddCuiPanel(elements, true, "0 0 0 0.94", "0.01 0.535", "0.15 0.94", null, null, "zpunisher.finalParent", "zpunisher.infoPanel"); AddCuiLabel(elements, "0 0", "1 0.99", null, null, $"{lang.GetMessage("infoTitle", this, player.UserIDString)}", "1 1 1 1", 14, TextAnchor.UpperCenter, "zpunisher.infoPanel", "zpunisher.infoPanel.infoLabel"); AddCuiLabel(elements, "0.02 0.89", "1 0.94", null, null, $"{String.Format(lang.GetMessage("infoName", this, player.UserIDString), target.displayName)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.name"); AddCuiLabel(elements, "0.02 0.835", "1 0.885", null, null, $"{String.Format(lang.GetMessage("infoID", this, player.UserIDString), target.UserIDString)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.userid"); AddCuiLabel(elements, "0.02 0.78", "1 0.83", null, null, $"{String.Format(lang.GetMessage("infoIP", this, player.UserIDString), iTarget.Address)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.address"); AddCuiLabel(elements, "0.02 0.725", "1 0.775", null, null, $"{String.Format(lang.GetMessage("infoPing", this, player.UserIDString), iTarget.Ping)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.ping"); if (target.IsAlive()) { AddCuiLabel(elements, "0.02 0.67", "1 0.72", null, null, $"{lang.GetMessage("infoStatusAlive", this, player.UserIDString)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.status"); } else { AddCuiLabel(elements, "0.02 0.67", "1 0.72", null, null, $"{lang.GetMessage("infoStatusDead", this, player.UserIDString)}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.status"); } AddCuiLabel(elements, "0.02 0.615", "1 0.665", null, null, $"{String.Format(lang.GetMessage("infoPos", this, player.UserIDString), Math.Round((decimal)target.transform.position.x), Math.Round((decimal)target.transform.position.y), Math.Round((decimal)target.transform.position.z))}", null, 12, TextAnchor.MiddleLeft, "zpunisher.infoPanel", "zpunisher.infoPanel.xyz"); AddCuiButton(elements, $"customTPCmd {target.UserIDString}", "0.639 0.086 0.086 1", "0.8 0.615", "0.99 0.665", null, null, $"{lang.GetMessage("infoTPBttn", this, player.UserIDString)}", null, 12, TextAnchor.MiddleCenter, "zpunisher.infoPanel", "zpunisher.infoPanel.xyz.bttn"); AddCuiButton(elements, $"zpunisher {target.UserIDString}", "0.569 0.569 0.569 0.8", "0.01 0.53", "0.99 0.6", null, null, $"{lang.GetMessage("infoRefresh", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.infoPanel", "zpunisher.infoPanel.refresh"); //.................... AddCuiPanel(elements, true, "0 0 0 0.94", "0.155 0.11", "0.995 0.94", null, null, "zpunisher.finalParent", "zpunisher.hud"); // Freeze feature........... AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.01 0.51", "0.21 0.99", null, null, "zpunisher.hud", "zpunisher.freeze.hud"); AddCuiFadedLabel(elements, 1.3f, "0 0", "1 1", null, null, $"{lang.GetMessage("freezer", this, player.UserIDString)}", null, 25, TextAnchor.UpperCenter, "zpunisher.freeze.hud", "zpunisher.freeze.hud.label"); AddCuiFadedLabel(elements, 1.3f, "0.01 0.8", "0.99 0.9", null, null, $"{lang.GetMessage("dsc", this, player.UserIDString)}", null, 14, TextAnchor.MiddleCenter, "zpunisher.freeze.hud", "zpunisher.freeze.dsc"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.5", "0.85 0.79", null, null, $"{lang.GetMessage("freezerDsc", this, player.UserIDString)}", null, 13, TextAnchor.UpperLeft, "zpunisher.freeze.hud", "zpunisher.freeze.dsc.full"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.freeze {target.UserIDString}", "0.639 0.086 0.086 1", "0.15 0.39", "0.85 0.48", null, null, $"{lang.GetMessage("enable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.freeze.hud", "zpunisher.freeze.run"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.unfreeze {target.UserIDString}", "0.125 0.541 0.176 1", "0.15 0.26", "0.85 0.35", null, null, $"{lang.GetMessage("disable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.freeze.hud", "zpunisher.freeze.stop"); //.......................... // Lag feature.............. AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.24 0.51", "0.44 0.99", null, null, "zpunisher.hud", "zpunisher.lag.hud"); AddCuiFadedLabel(elements, 1.3f, "0 0", "1 1", null, null, $"{lang.GetMessage("lagger", this, player.UserIDString)}", null, 25, TextAnchor.UpperCenter, "zpunisher.lag.hud", "zpunisher.lag.hud.label"); AddCuiFadedLabel(elements, 1.3f, "0.01 0.8", "0.99 0.9", null, null, $"{lang.GetMessage("dsc", this, player.UserIDString)}", null, 14, TextAnchor.MiddleCenter, "zpunisher.lag.hud", "zpunisher.lag.dsc"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.5", "0.85 0.79", null, null, $"{lang.GetMessage("lagDsc", this, player.UserIDString)}", null, 13, TextAnchor.UpperLeft, "zpunisher.lag.hud", "zpunisher.lag.dsc.full"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.lag {target.UserIDString}", "0.639 0.086 0.086 1", "0.15 0.39", "0.85 0.48", null, null, $"{lang.GetMessage("enable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.lag.hud", "zpunisher.lag.run"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.stoplag {target.UserIDString}", "0.125 0.541 0.176 1", "0.15 0.26", "0.85 0.35", null, null, $"{lang.GetMessage("disable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.lag.hud", "zpunisher.lag.stop"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.1", "0.85 0.24", null, null, $"{lang.GetMessage("lagPS", this, player.UserIDString)}", "0.51 0.027 0 1", 10, TextAnchor.UpperLeft, "zpunisher.lag.hud", "zpunisher.lag.ps"); // ......................... // Rocket feature........... AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.47 0.51", "0.67 0.99", null, null, "zpunisher.hud", "zpunisher.rocket.hud"); AddCuiFadedLabel(elements, 1.3f, "0 0", "1 1", null, null, $"{lang.GetMessage("rocketer", this, player.UserIDString)}", null, 25, TextAnchor.UpperCenter, "zpunisher.rocket.hud", "zpunisher.rocket.hud.label"); AddCuiFadedLabel(elements, 1.3f, "0.01 0.8", "0.99 0.9", null, null, $"{lang.GetMessage("dsc", this, player.UserIDString)}", null, 14, TextAnchor.MiddleCenter, "zpunisher.rocket.hud", "zpunisher.rocket.dsc"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.5", "0.85 0.79", null, null, $"{lang.GetMessage("rocketerDsc", this, player.UserIDString)}", null, 13, TextAnchor.UpperLeft, "zpunisher.rocket.hud", "zpunisher.rocket.dsc.full"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.rocket {target.UserIDString}", "0.639 0.086 0.086 1", "0.15 0.39", "0.85 0.48", null, null, $"{lang.GetMessage("enable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.rocket.hud", "zpunisher.rocket.run"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.stoprocket {target.UserIDString}", "0.125 0.541 0.176 1", "0.15 0.26", "0.85 0.35", null, null, $"{lang.GetMessage("disable", this, player.UserIDString)}", null, 13, TextAnchor.MiddleCenter, "zpunisher.rocket.hud", "zpunisher.rocket.stop"); // .......................... // Kill feature.............. AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.70 0.51", "0.90 0.99", null, null, "zpunisher.hud", "zpunisher.kill.hud"); AddCuiFadedLabel(elements, 1.3f, "0 0", "1 1", null, null, $"{lang.GetMessage("killTitle", this, player.UserIDString)}", null, 25, TextAnchor.UpperCenter, "zpunisher.kill.hud", "zpunisher.kill.hud.label"); AddCuiFadedLabel(elements, 1.3f, "0.01 0.8", "0.99 0.9", null, null, $"{lang.GetMessage("dsc", this, player.UserIDString)}", null, 14, TextAnchor.MiddleCenter, "zpunisher.kill.hud", "zpunisher.kill.dsc"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.5", "0.85 0.79", null, null, $"{lang.GetMessage("killDsc", this, player.UserIDString)}", null, 13, TextAnchor.UpperLeft, "zpunisher.kill.hud", "zpunisher.kill.dsc.full"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.kill {target.UserIDString}", "0.639 0.086 0.086 1", "0.15 0.26", "0.85 0.48", null, null, $"{lang.GetMessage("kill", this, player.UserIDString)}", null, 15, TextAnchor.MiddleCenter, "zpunisher.kill.hud", "zpunisher.kill.run"); // .......................... // Ignite feature............ AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.01 0.01", "0.21 0.49", null, null, "zpunisher.hud", "zpunisher.ignite.hud"); AddCuiFadedLabel(elements, 1.3f, "0 0", "1 1", null, null, $"{lang.GetMessage("igniterTitle", this, player.UserIDString)}", null, 25, TextAnchor.UpperCenter, "zpunisher.ignite.hud", "zpunisher.ignite.hud.label"); AddCuiFadedLabel(elements, 1.3f, "0.01 0.8", "0.99 0.9", null, null, $"{lang.GetMessage("dsc", this, player.UserIDString)}", null, 14, TextAnchor.MiddleCenter, "zpunisher.ignite.hud", "zpunisher.ignite.dsc"); AddCuiFadedLabel(elements, 1.3f, "0.15 0.5", "0.85 0.79", null, null, $"{lang.GetMessage("igniterDsc", this, player.UserIDString)}", null, 13, TextAnchor.UpperLeft, "zpunisher.ignite.hud", "zpunisher.ignite.dsc.full"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.ignite {target.UserIDString}", "0.639 0.086 0.086 1", "0.15 0.39", "0.85 0.48", null, null, $"{lang.GetMessage("ignite", this, player.UserIDString)}", null, 15, TextAnchor.MiddleCenter, "zpunisher.ignite.hud", "zpunisher.ignite.run"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.extinguish {target.UserIDString}", "0.125 0.541 0.176 1", "0.15 0.26", "0.85 0.35", null, null, $"{lang.GetMessage("pw", this, player.UserIDString)}", null, 15, TextAnchor.MiddleCenter, "zpunisher.ignite.hud", "zpunisher.ignite.stop"); // .......................... // Stop All feature.......... AddCuiFadedPanel(elements, 1.3f, true, "0 0 0 0.94", "0.01 0.11", "0.15 0.518", null, null, "zpunisher.finalParent", "zpunisher.stopPanel"); AddCuiFadedButton(elements, 1.3f, 1.3f, $"zpunisher.stop {target.UserIDString}", "0.639 0.086 0.086 1", "0.05 0.05", "0.95 0.95", null, null, $"{lang.GetMessage("stopAllEffects", this, player.UserIDString)}", null, 35, TextAnchor.MiddleCenter, "zpunisher.stopPanel", "zpunisher.stopPanel.bttn"); // .......................... return elements; } void customTPCommand(IPlayer player, string command, string[] args) { BasePlayer bplayer = BasePlayer.Find(player.Id); BasePlayer target = BasePlayer.Find(args[0]); if (target == null) return; Server.Command($"teleport {bplayer.UserIDString} {target.UserIDString}"); } void zpunisherGui(IPlayer player, string command, string[] args) { if(args.Length > 0) { var target = BasePlayer.Find(args[0]); if (target != null) { finalPunishGui(player, target); return; } } BasePlayer ply = BasePlayer.Find(player.Id); CuiHelper.DestroyUi(ply, cuiParent); CuiElementContainer menu = mainCui(player); List onlinePlayers = BasePlayer.activePlayerList.ToList(); int numPlayersDisplayed = 0; int playersPerPage = 20; int numColumns = 5; int numRows = playersPerPage / numColumns; int startIndex = currentPage * playersPerPage; float startY = 0.85f; // Starting Y position for the first line float startX = 0.15f; // Spacing from the left edge float buttonHeight = 0.13f; // Height of each button float lineHeight = 0.18f; // Spacing between lines float buttonWidth = 0.12f; // Custom width of each button float fadeIn = 0f; float fadeInIncrease = 0.12f; int numPlayers = onlinePlayers.Count; int numPages = numPlayers / playersPerPage + (numPlayers % playersPerPage == 0 ? 0 : 1); for (int row = 0; row < numRows; row++) { for (int col = 0; col < numColumns; col++) { fadeIn += fadeInIncrease; int index = startIndex + (row * numColumns) + col; if (index < onlinePlayers.Count) { float xPos = startX + col * (buttonWidth + 0.02f); float yPos = startY - (row * lineHeight + buttonHeight); AddCuiFadedButton(menu, fadeIn, fadeIn, $"zpunisher {onlinePlayers[index].UserIDString}", "0.18 0.18 0.18 0.6", $"{xPos} {yPos}", $"{xPos + buttonWidth} {yPos + buttonHeight}", null, null, $"Select:\n{onlinePlayers[index].displayName}", "1 1 1 1", 12, TextAnchor.UpperCenter, pickMenu, $"zpunisher.player.{index}"); AddCuiFadedLabel(menu, fadeIn, "0 0.1", "1 1", null, null, $"{onlinePlayers[index].UserIDString}", "1 1 1 1", 9, TextAnchor.LowerCenter, $"zpunisher.player.{index}", $"zpunisher.player.label.{index}"); } } } if (startIndex > 0) { AddCuiButton(menu, $"zpunisher.page.prev", "0.29 0.267 0.267 0.94", "0.1 0.05", "0.2 0.1", null, null, $"{lang.GetMessage("previous", this, player.Id)}", "1 1 1 1", 13, TextAnchor.MiddleCenter, pickMenu, "zpunisher.prevbutton"); } if (startIndex + numPlayersDisplayed < onlinePlayers.Count && currentPage < numPages - 1) { AddCuiButton(menu, $"zpunisher.page.next", "0.29 0.267 0.267 0.94", "0.8 0.05", "0.9 0.1", null, null, $"{lang.GetMessage("next", this, player.Id)}", "1 1 1 1", 13, TextAnchor.MiddleCenter, pickMenu, "zpunisher.nextbutton"); } CuiHelper.AddUi(ply, menu); } private void NextPageCommand(IPlayer player, string command, string[] args) { currentPage++; zpunisherGui(player, command, args); } private void PrevPageCommand(IPlayer player, string command, string[] args) { currentPage--; if (currentPage < 0) { currentPage = 0; } zpunisherGui(player, command, args); } void zpunisherCloseGui(IPlayer player, string command, string[] args) { BasePlayer ply = BasePlayer.Find(player.Id); CuiHelper.DestroyUi(ply, cuiParent); CuiHelper.DestroyUi(ply, "zpunisher.finalParent"); } CuiElementContainer mainCui(IPlayer player) { var elements = new CuiElementContainer(); AddCuiPanel(elements, true, "0 0 0 0.6", "0.2 0.2", "0.8 0.8", null, null, "Hud", cuiParent); AddCuiPanel(elements, true, "0 0 0 0.98", "0.005 0.01", "0.995 0.99", null, null, cuiParent, pickMenu); AddCuiLabel(elements, "0 0.8", "0.9 1", null, null, $"{lang.GetMessage("choosePl", this, player.Id)}", null, 20, TextAnchor.MiddleCenter, pickMenu, "zpunisher.chooselabel.cui"); AddCuiButton(elements, "zpunisher.close", "0.639 0.086 0.086 1", "0.95 0.95", "0.99 0.99", null, null, "x", "0 0 0 1", 15, TextAnchor.MiddleCenter, pickMenu, "zpunisher.closebttn.cui"); return elements; } #endregion #region Stop All void stopAllCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("stopAllSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ServerMgr.Instance.StopCoroutine(FreezePlayer(ply)); FreezeHandler target = ply.gameObject.GetComponent(); GameObject.Destroy(target); if(ply.HasComponent()) { var plyLag = ply.GetComponent(); GameObject.Destroy(plyLag); } if(ply.HasComponent()) { var plyRocket = ply.GetComponent(); GameObject.Destroy(plyRocket); } var iTarget = covalence.Players.FindPlayer(ply.UserIDString); extinguishCmd(iTarget, command, args); CuiHelper.DestroyUi(ply, "lagg_ui"); player.Message(String.Format(lang.GetMessage("stoppedAll", this, player.Id), ply.displayName)); } #endregion #region Freeze void freezeCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("freezeSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } player.Message(String.Format(lang.GetMessage("startFreeze", this, player.Id), ply.displayName)); ply.gameObject.AddComponent(); var target = ply.gameObject.GetComponent(); target.targetPos = ply.transform.position; ServerMgr.Instance.StartCoroutine(FreezePlayer(ply)); } void unfreezeCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("unfreezeSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ServerMgr.Instance.StopCoroutine(FreezePlayer(ply)); FreezeHandler target = ply.gameObject.GetComponent(); GameObject.Destroy(target); player.Message(String.Format(lang.GetMessage("stoppedFreezing", this, player.Id), ply.displayName)); } private IEnumerator FreezePlayer(BasePlayer player) { while (player.HasComponent()) { if (player.transform.position != player.GetComponent().targetPos) { player.Teleport(player.GetComponent().targetPos); } yield return new WaitForSeconds(0.2f); } } public class FreezeHandler : MonoBehaviour { public Vector3 targetPos { get; set; } } #endregion #region Lag Player CuiElementContainer baseForLag() { var elements = new CuiElementContainer(); AddCuiPanel(elements, false, "0 0 0 0", "0 0", "1 1", null, null, "Hud", "lagg_ui"); return elements; } void lagCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("lagSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } player.Message(String.Format(lang.GetMessage("startLag", this, player.Id), ply.displayName)); ply.gameObject.AddComponent(); CuiElementContainer baseForit = baseForLag(); CuiHelper.AddUi(ply, baseForit); ServerMgr.Instance.StartCoroutine(ContinuousCUIRoutine(ply)); } void stopLagCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("stopLagSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ServerMgr.Instance.StopCoroutine(ContinuousCUIRoutine(ply)); lagHandler target = ply.gameObject.GetComponent(); CuiHelper.DestroyUi(ply, "lagg_ui"); GameObject.Destroy(target); player.Message(String.Format(lang.GetMessage("stoppedLag", this, player.Id), ply.displayName)); } private IEnumerator ContinuousCUIRoutine(BasePlayer player) { int i = 0; while (player.HasComponent()) { CuiElementContainer panel = CreateCUIPanel($"lag_{i}", $"lags_{i}", $"lagz_{i}"); CuiHelper.AddUi(player, panel); i++; yield return new WaitForSeconds(0.001f); } } private CuiElementContainer CreateCUIPanel(string name, string nameA, string nameB) { var elements = new CuiElementContainer(); AddCuiPanel(elements, false, "0 0 0 0", "0 0", "1 1", null, null, "lagg_ui", name); AddCuiPanel(elements, false, "0 0 0 0", "0.2 0.2", "0.7 0.7", null, null, "lagg_ui", nameA); //AddCuiButton(elements, null, "0 0 0 0", "0 0", "1 1", null, null, "", "0 0 0 0", 20, TextAnchor.MiddleCenter, "lagg_ui", nameB); return elements; } public class lagHandler : MonoBehaviour { } #endregion #region Kill Player void killCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("killSyntax", this, player.Id)); return; } IPlayer ply = covalence.Players.FindPlayer(args[0]); if(ply == null || !ply.IsConnected) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ply.Kill(); player.Message(String.Format(lang.GetMessage("killMsg", this, player.Id), ply.Name)); } #endregion #region Rocket Player void rocketCommand(IPlayer player, string command, string[] args) { if(args.Length < 1 || args == null) { player.Message(lang.GetMessage("rocketSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if(ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ply.gameObject.AddComponent(); ServerMgr.Instance.StartCoroutine(rocketPlayer(ply)); player.Message(String.Format(lang.GetMessage("startRocket", this, player.Id), ply.displayName)); } void stopRocketCommand(IPlayer player, string command, string[] args) { if (args.Length < 1 || args == null) { player.Message(lang.GetMessage("stopRocketSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } ServerMgr.Instance.StopCoroutine(rocketPlayer(ply)); rocketHandler target = ply.GetComponent(); GameObject.Destroy(target); player.Message(String.Format(lang.GetMessage("stopRocket", this, player.Id), ply.displayName)); } private IEnumerator rocketPlayer(BasePlayer player) { while(player.HasComponent()) { var ent = GameManager.server.CreateEntity("assets/prefabs/ammo/rocket/rocket_hv.prefab"); Vector3 pos = player.transform.position; pos.y += 0.1f; ent.transform.position = pos; ent.Spawn(); yield return new WaitForSeconds(0.2f); } } public class rocketHandler : MonoBehaviour { } #endregion #region Ignite Player void igniteCmd(IPlayer player, string command, string[] args) { if (args.Length < 1 || args == null) { player.Message(lang.GetMessage("igniteSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } var fire = GameManager.server.CreateEntity("assets/bundled/prefabs/fireball_small_molotov.prefab"); fire.transform.position = ply.transform.position; fire.Spawn(); player.Message(String.Format(lang.GetMessage("startIgnite", this, player.Id), ply.displayName)); ServerMgr.Instance.StartCoroutine(setTargetOnFire(ply, fire)); } void extinguishCmd(IPlayer player, string command, string[] args) { if (args.Length < 1 || args == null) { player.Message(lang.GetMessage("extSyntax", this, player.Id)); return; } BasePlayer ply = BasePlayer.Find(args[0]); if (ply == null) { player.Message(lang.GetMessage("noPlayer", this, player.Id)); return; } timer.Repeat(0.1f, 5, () => { var water = GameManager.server.CreateEntity("assets/prefabs/weapons/waterbucket/waterball.prefab"); water.transform.position = ply.transform.position; water.Spawn(); }); player.Message(String.Format(lang.GetMessage("startExt", this, player.Id), ply.displayName)); } private IEnumerator setTargetOnFire(BasePlayer target, BaseEntity fire) { while(target != null && fire != null) { fire.transform.position = target.transform.position; yield return new WaitForSeconds(0.1f); } } #endregion #region Helpers public static void AddCuiPanel(CuiElementContainer container, bool cursor, string color, string amin, string amax, string omin, string omax, string parent, string name) { container.Add(new CuiPanel { CursorEnabled = cursor, Image = { Color = color }, RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax } }, parent, name, name); } public static void AddCuiFadedPanel(CuiElementContainer container, float fadeIn, bool cursor, string color, string amin, string amax, string omin, string omax, string parent, string name) { container.Add(new CuiPanel { CursorEnabled = cursor, Image = { Color = color, FadeIn = fadeIn }, RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax } }, parent, name, name); } public static void AddCuiButton(CuiElementContainer container, string command, string color, string amin, string amax, string omin, string omax, string text, string textColor, int fontsize, TextAnchor anchor, string parent, string name) { container.Add(new CuiButton { Button = { Color = color, Command = command }, RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax }, Text = { Text = text, Color = textColor, FontSize = fontsize, Align = anchor } }, parent, name); } public static void AddCuiFadedButton(CuiElementContainer container, float fadeIn, float txtFade, string command, string color, string amin, string amax, string omin, string omax, string text, string textColor, int fontsize, TextAnchor anchor, string parent, string name) { container.Add(new CuiButton { Button = { Color = color, Command = command, FadeIn = fadeIn }, RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax }, Text = { Text = text, Color = textColor, FontSize = fontsize, Align = anchor, FadeIn = txtFade } }, parent, name); } public static void AddCuiLabel(CuiElementContainer container, string amin, string amax, string omin, string omax, string text, string color, int fontSize, TextAnchor anchor, string parent, string name) { container.Add(new CuiLabel { RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax }, Text = { Text = text, Color = color, FontSize = fontSize, Align = anchor }, }, parent, name); } public static void AddCuiFadedLabel(CuiElementContainer container, float fadeIn, string amin, string amax, string omin, string omax, string text, string color, int fontSize, TextAnchor anchor, string parent, string name) { container.Add(new CuiLabel { RectTransform = { AnchorMin = amin, AnchorMax = amax, OffsetMin = omin, OffsetMax = omax }, Text = { Text = text, Color = color, FontSize = fontSize, Align = anchor, FadeIn = fadeIn, }, }, parent, name); } #endregion } }