using Oxide.Core.Libraries.Covalence; using Oxide.Core.Plugins; using System.Collections.Generic; namespace Oxide.Plugins { [Info("SimpleStatusDemo", "mr01sam", "1.2.0")] [Description("Allows plugins to add custom status displays for the UI.")] partial class SimpleStatusDemo : CovalencePlugin { [PluginReference] private readonly Plugin ImageLibrary; [PluginReference] private readonly Plugin SimpleStatus; public static SimpleStatusDemo PLUGIN; private void OnServerInitialized() { PLUGIN = this; ImageLibrary.Call("AddImage", "https://i.ibb.co/HdvFyvS/star1c.png", "star", 0UL); // EXAMPLE: SimpleStatus.CallHook("CreateStatus", , , ); // TIP: The properties that you can set can be found on the plugin page. // TIP: The icon can be either an asset sprite or an image library PNG. In this example we are using sprites for title1 and title2 while using a image library PNG for title3. SimpleStatus.CallHook("CreateStatus", this, "status1", new Dictionary { ["color"] = "0.77255 0.23922 0.15686 1", ["title"] = "title1", ["titleColor"] = "0.91373 0.77647 0.75686 1", ["text"] = "text1", ["textColor"] = "0.91373 0.77647 0.75686 1", ["icon"] = "assets/icons/home.png", ["iconColor"] = "0.91373 0.77647 0.75686 1" }); SimpleStatus.CallHook("CreateStatus", this, "status2", new Dictionary { ["color"] = "0.35490 0.40980 0.24510 1", ["title"] = "title2", ["titleColor"] = "0.69804 0.83137 0.46667 1", ["text"] = "text2", ["textColor"] = "0.69804 0.83137 0.46667 1", ["icon"] = "assets/icons/info.png", ["iconColor"] = "0.69804 0.83137 0.46667 1" }); SimpleStatus.CallHook("CreateStatus", this, "status3", new Dictionary { ["color"] = "0.08627 0.25490 0.38431 1", ["title"] = "title3", ["titleColor"] = "0.25490 0.61176 0.86275 1", ["text"] = "text3", ["textColor"] = "0.25490 0.61176 0.86275 1", ["icon"] = "star", ["iconColor"] = "0.25490 0.61176 0.86275 1" }); // EXAMPLE: This is an example of how to create a progress status, notice the progress and progressColor properties are set. SimpleStatus.CallHook("CreateStatus", this, "status4", new Dictionary { ["color"] = "0.3 0.3 0.3 1", ["title"] = "0%", ["titleColor"] = "1 1 1 0.8", ["icon"] = "assets/icons/gear.png", ["iconColor"] = "1 1 1 0.8", ["progress"] = 0f, // It is important to set the starting value if you plan for this status to be a progress bar! ["progressColor"] = "0.5 0.3 0.6 0.9", ["rank"] = -1 // TIP: The rank property can determine where in the status list this status will appear among the other custom statuses. Lower numbers come first. }); // EXAMPLE: This is an example of a status with a counter, this is automatic if the text is null and it has a duration SimpleStatus.CallHook("CreateStatus", this, "status5", new Dictionary { ["color"] = "0.3 0.3 0.3 1", ["title"] = "Timer", ["titleColor"] = "1 1 1 0.8", ["icon"] = "assets/icons/stopwatch.png", ["iconColor"] = "1 1 1 0.8", ["text"] = null }); } [Command("show")] private void CmdShow(IPlayer player, string command, string[] args) { int duration = int.MaxValue; if (args.Length > 0) { int.TryParse(args[0], out duration); } var basePlayer = player.Object as BasePlayer; // EXAMPLE: SimpleStatus.CallHook("SetStatus", , , , ); // TIP: If you want the status to have no duration (be infinite) pass the duration as max value int otherwise, // pass the number of seconds you want it to appear for. SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status3", duration); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status2", duration); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status1", duration); } [Command("change")] private void CmdChange(IPlayer player, string command, string[] args) { var basePlayer = player.Object as BasePlayer; // EXAMPLE: SimpleStatus.CallHook("SetStatusProperty", , , ); // TIP: You can set multiple properties at once with this method. See documentation for the keys for each // property. SimpleStatus.CallHook("SetStatusProperty", basePlayer.UserIDString, "status3", new Dictionary { ["color"] = "1 0 0 0.5", ["title"] = "changes", ["titleColor"] = GetRandomColor() }); } [Command("hide")] private void CmdHide(IPlayer player, string command, string[] args) { var basePlayer = player.Object as BasePlayer; // TIP: To remove a status from a player, set the duration to 0. SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status5", 0); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status4", 0); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status3", 0); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status2", 0); SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status1", 0); } [Command("timer")] private void CmdTimer(IPlayer player, string command, string[] args) { var basePlayer = player.Object as BasePlayer; SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status5", 5); } private float testProgress = 0f; [Command("loader")] private void CmdLoader(IPlayer player, string command, string[] args) { // EXAMPLE: This shows you how you can set progress for a progress status. var basePlayer = player.Object as BasePlayer; if (testProgress >= 1f) { testProgress = 0f; } SimpleStatus.CallHook("SetStatus", basePlayer.UserIDString, "status4", int.MaxValue); timer.Repeat(0.1f, 20, () => { testProgress += 0.05f; SimpleStatus.CallHook("SetStatusProperty", basePlayer.UserIDString, "status4", new Dictionary { ["progress"] = testProgress, ["title"] = $"{testProgress * 100f:F0}%" }); }); } private string GetRandomColor() => $"{UnityEngine.Random.Range(0f, 1f)} {UnityEngine.Random.Range(0f, 1f)} {UnityEngine.Random.Range(0f, 1f)} 1"; protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["title1"] = "Simple", ["title2"] = "Status", ["title3"] = "Rocks!", ["text1"] = "Make", ["text2"] = "Custom", ["text3"] = "Statuses", ["changes"] = "Changes!" }, this); } } }