Иконка ресурса

FREE Hud : 3.3.4 3.3.4

Нет прав для скачивания
C#:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using UnityEngine.UI;
namespace Oxide.Plugins {
    [Info("Hud", "ahigao", "3.3.4")]
    internal class Hud : RustPlugin {
#region Static
        private const string PERM_STREAMER = "hud.streamer";
        private Timer InfoMessageUpdate;
        private int EnableEventsCount, EventsPosStartPosX;
        private Vector3 largeOilRigPosition, smallOilRigPosition;
        [PluginReference]
        private Plugin Economics, ServerRewards;
        private enum States {
            Full, Events, Hide, Close
        }
#region ConfigAutoReplace
        private void ReplaceOldImages() {
            var linkReplace = new Dictionary<string, string> {
                ["https://www.dropbox.com/scl/fi/9j4fv475el3gfbq9wvoox/logo.png?rlkey=rq710tuayr8syuk54fljluqqa&dl=1"]
                = "https://i.ibb.co/3F3566J/logo.png", ["https://www.dropbox.com/scl/fi/weax6ug55o0u4f87bhchs/active.png?rlkey=lbpuhpqs7tutpgv1i4t3b1107&dl=1"] = "https://i.ibb.co/7vG49W1/active.png", ["https://www.dropbox.com/scl/fi/3d76i9rg4i34zprgekr3j/sleep.png?rlkey=s57ehdeoc16h58ace6s5yuhcl&dl=1"] = "https://i.ibb.co/2q5mzmC/sleep.png", ["https://www.dropbox.com/scl/fi/aneas55vx6pnrwmg8bh1z/line.png?rlkey=kwmlqihaopckijm98ta0qn9p2&dl=1"] = "https://i.ibb.co/Cm65TY9/line.png", ["https://www.dropbox.com/scl/fi/ypbnnbs07i2t322x1pu4c/command.png?rlkey=a693i43bn70wiy2p0v0216uw7&dl=1"] = "https://i.ibb.co/6Z5SCrW/command.png", ["https://www.dropbox.com/scl/fi/i7531lubr8jy62w6zugkt/bradley.png?rlkey=fpnpmqndjgt63hamyrd0jzyc2&dl=1"] = "https://i.ibb.co/X8xVTjc/bradley.png", ["https://www.dropbox.com/scl/fi/140cku9l167y8i778br2i/heli.png?rlkey=25wxs16n0s9dk8uea7bn0p7sd&dl=1"] = "https://i.ibb.co/m6wwkhH/heli.png", ["https://www.dropbox.com/scl/fi/a0cuylwwtrwqrxr933jpd/ch47.png?rlkey=w9rv4ap58hmr3fwtkp4et4dn1&dl=1"] = "https://i.ibb.co/CVCPVpN/ch47.png", ["https://www.dropbox.com/scl/fi/lt4b833tybzzyas7bxst0/cargo.png?rlkey=i0xn03ctyz93a4rbybol2x5c2&dl=1"] = "https://i.ibb.co/QmT6MFX/cargo.png", ["https://www.dropbox.com/scl/fi/udt3221xk7yk2zwqdd7id/airdrop.png?rlkey=7642d4ye3n63rby8nz0ej9ayr&dl=1"] = "https://i.ibb.co/580XRGw/airdrop.png", ["https://www.dropbox.com/scl/fi/s2ovq1yo8umvkn213cno0/convoy.png?rlkey=9mxlg4ypbypk5be59b57qgck3&dl=1"] = "https://i.ibb.co/qRyD0DY/convoy.png", ["https://www.dropbox.com/scl/fi/tlys9ulw51i74fpm6oec0/sputnik.png?rlkey=oe27iqf5ali445c90mgmcilea&dl=1"] = "https://i.ibb.co/9Tkb44Z/sputnik.png", ["https://www.dropbox.com/scl/fi/d78jg4yrer0vqdspkxpg2/train.png?rlkey=9m4xll5wv6qrr0u2kb3pd2o4z&dl=1"] = "https://i.ibb.co/3v3JcQ8/train.png", ["https://www.dropbox.com/scl/fi/3qzyayoa4dxog2t8gyvzw/harbor.png?rlkey=v7jnpk8tyngwywvhbgrfhk5a4&dl=1"] = "https://i.ibb.co/P91x3zR/harbor.png",
            }
            ;
            _config.MainSetup.Logo = Replace(_config.MainSetup.Logo);
            _config.MainSetup.SleepPlayersAppearance.Icon = Replace(_config.MainSetup.SleepPlayersAppearance.Icon);
            _config.MainSetup.QueuePlayersAppearance.Icon = Replace(_config.MainSetup.QueuePlayersAppearance.Icon);
            _config.MainSetup.ActivePlayersAppearance.Icon = Replace(_config.MainSetup.ActivePlayersAppearance.Icon);
            foreach (var check in _config.MainSetup.AdditionalMenu.Commands) {
                check.Icon = Replace(check.Icon);
                check.Image = Replace(check.Image);
            }
            foreach (var check in _config.BaseEvents) check.Icon = Replace(check.Icon);
            foreach (var check in _config.CustomEvents) check.Icon = Replace(check.Icon);
            SaveConfig();
            return;
            string Replace(string url) {
                var newString = url;
                foreach (var check in linkReplace) newString = newString.Replace(check.Key, check.Value);
                return newString;
            }
        }
#endregion
#region Classes
        private class Configuration {
            [JsonIgnore]
            public string JSON;
            [JsonProperty("Auto reload [If you change the config and save the file the plugin will reload itself]")]
            public bool AutoReload = false;
            [JsonProperty(PropertyName = "Other images")]
            public OtherImages Images = new OtherImages();
            [JsonProperty("Main setup")]
            public MainSetup MainSetup = new MainSetup {
                IsOverall = false, Size = 80, Logo = "https://i.ibb.co/3F3566J/logo.png", EventsBGOpacity = 80, BGOpacity = 60, Position = new Postition {
                    Align = "TopLeft", LeftOffSet = 40, TopOffSet = 25,
                }
                , ServerName = "Your Server Name", ActivePlayersAppearance = new ActiveAppearance {
                    Color = "#fff", Icon = "https://i.ibb.co/7vG49W1/active.png", IsEnable = true, IsAdminsCount = false,
                }
                , SleepPlayersAppearance = new BaseAppearance {
                    Color = "#fff", Icon = "https://i.ibb.co/2q5mzmC/sleep.png", IsEnable = true,
                }
                , QueuePlayersAppearance = new BaseAppearance {
                    Color = "#fff", Icon = "https://i.ibb.co/Cm65TY9/line.png", IsEnable = true,
                }
                , Time = new TimeAppearance {
                    IsAutomaticDetection = true, IsAmPm = false, Color = "#fff", IsEnable = true,
                }
                , PlayerPosition = new PlayerPositionAppearance {
                    IsGrid = true, Color = "cyan", IsEnable = true,
                }
                , Economy = new EconomyAppearance() {
                    Currency = "$", Plugin = "ServerRewards", Color = "#10ff10", IsEnable = false,
                }
                , InfoMessages = new InfoMessage {
                    UpdateInterval = 60, Align = "BottomCenter", Width = 260, OffsetTB = 0, OffsetR = 0, OutlineColor = "#000", IsOverall = true, IsEnable = true, Messages = new List<string> {
                        "Welcome to Your Server Name", "Good luck"
                    }
                }
                , AdditionalMenu = new AdditionalMenu {
                    AutoCloseTime = 60, AutoCloseCommand = true, ButtonColor = "yellow", CommandsOpacity = 100, IsEnable = true, Commands = new List<CommandAppearance> {
                        new CommandAppearance {
                            Command = "chat.say Hello there", Icon = "https://i.ibb.co/7vG49W1/active.png", Image = "https://i.ibb.co/6Z5SCrW/command.png", Text = "Say Something", OutlineColor = "#000", IsConsole = true,
                        }
                        , new CommandAppearance {
                            Command = "/shop", Icon = "", Image = "https://i.ibb.co/6Z5SCrW/command.png", Text = "Say Something", OutlineColor = "#000", IsConsole = false,
                        }
                        ,
                    }
                    ,
                }
            }
            ;
            [JsonProperty("Base Events", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<BaseEventsAppearance> BaseEvents = new List<BaseEventsAppearance> {
                new BaseEventsAppearance {
                    Name = "Bradley", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/X8xVTjc/bradley.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "PatrolHeli", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/m6wwkhH/heli.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "CH47", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/CVCPVpN/ch47.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "Cargo", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/QmT6MFX/cargo.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "AirDrop", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/580XRGw/airdrop.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "HarborCargoArrive", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/qysRW6X/harborevent2.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "SmallOilRig", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/cbDJj7r/harborevent3.png", IsEnable = true,
                }
                , new BaseEventsAppearance {
                    Name = "LargeOilRig", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/QPGXQHr/harborevent2.png", IsEnable = true,
                }
            }
            ;
            [JsonProperty("Custom Events", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<CustomEventsAppearance> CustomEvents = new List<CustomEventsAppearance> {
                new CustomEventsAppearance {
                    Name = "Convoy", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/qRyD0DY/convoy.png", IsEnable = false, OnEventStart = new List<string> {
                        "OnConvoyStart"
                    }
                    , OnEventEnd = new List<string> {
                        "OnConvoyStop"
                    }
                }
                , new CustomEventsAppearance {
                    Name = "Sputnik", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/9Tkb44Z/sputnik.png", IsEnable = false, OnEventStart = new List<string> {
                        "OnSputnikEventStart"
                    }
                    , OnEventEnd = new List<string> {
                        "OnSputnikEventStop"
                    }
                }
                , new CustomEventsAppearance {
                    Name = "ArmoredTrain", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/3v3JcQ8/train.png", IsEnable = false, OnEventStart = new List<string> {
                        "OnArmoredTrainEventStart"
                    }
                    , OnEventEnd = new List<string> {
                        "OnArmoredTrainEventStop"
                    }
                }
                , new CustomEventsAppearance {
                    Name = "Harbor", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/P91x3zR/harbor.png", IsEnable = false, OnEventStart = new List<string> {
                        "OnHarborEventStart"
                    }
                    , OnEventEnd = new List<string> {
                        "OnHarborEventEnd"
                    }
                }
                ,
            }
            ;
            public BaseEventsAppearance GetEventByName(string name) {
                foreach (var check in BaseEvents) if (string.Equals(check.Name, name, StringComparison.CurrentCultureIgnoreCase)) return check;
                foreach (var check in CustomEvents) if (string.Equals(check.Name, name, StringComparison.CurrentCultureIgnoreCase)) return check;
                return null;
            }
        }
        private class OtherImages {
            [JsonProperty(PropertyName = "Backgound Main")]
            public string Background = "https://i.ibb.co/Zf9GxqZ/background.png";
            [JsonProperty(PropertyName = "Backgound Events")]
            public string Events = "https://i.ibb.co/1fk9m74/events.png";
            [JsonProperty(PropertyName = "Lip")]
            public string Lip = "https://i.ibb.co/10Gg3j5/lip.png";
            [JsonProperty(PropertyName = "Drop menu")]
            public string DropMenu = "https://i.ibb.co/vqPQ3nv/dropmenu.png";
            [JsonProperty(PropertyName = "Close drop menu")]
            public string CloseDropMenu = "https://i.ibb.co/PwyWzwH/closedropmenu.png";
        }
        private class Data {
            [JsonProperty("Players' state hud", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, States> PlayersState = new Dictionary<string, States>();
            [JsonProperty(PropertyName = "First Run")]
            public bool FirstRun = true;
        }
        private class Postition {
            [JsonProperty("Align [TopLeft | TopRight | BottomLeft | BottomRight")]
            public string Align;
            [JsonProperty("Left | Right - offset")]
            public int LeftOffSet;
            [JsonProperty("Top | Bottom - offset")]
            public int TopOffSet;
        }
        private class MainSetup {
            [JsonProperty("Overall layer [you will see the hud in your inventory]")]
            public bool IsOverall;
            [JsonProperty("Show only active events")]
            public bool OnlyActive;
            [JsonProperty("Size ALL [0% - inf]")]
            public int Size;
            [JsonProperty("Logo [HUD interact button]")]
            public string Logo;
            [JsonProperty("Background opacity [0% - 100%]")]
            public int EventsBGOpacity;
            [JsonProperty("Events background opacity [0% - 100%]")]
            public int BGOpacity;
            [JsonProperty("Position")]
            public Postition Position;
            [JsonProperty("Server name")]
            public string ServerName;
            [JsonProperty("Active players")]
            public ActiveAppearance ActivePlayersAppearance;
            [JsonProperty("Sleep players")]
            public BaseAppearance SleepPlayersAppearance;
            [JsonProperty("Queue players")]
            public BaseAppearance QueuePlayersAppearance;
            [JsonProperty("Time")]
            public TimeAppearance Time = new TimeAppearance();
            [JsonProperty("Player position [hide permisson - hud.streamer]")]
            public PlayerPositionAppearance PlayerPosition = new PlayerPositionAppearance();
            [JsonProperty("Economy plugin [Economics | ServerRewards]")]
            public EconomyAppearance Economy = new EconomyAppearance();
            [JsonProperty("Info messages")]
            public InfoMessage InfoMessages = new InfoMessage();
            [JsonProperty("Additional menu")]
            public AdditionalMenu AdditionalMenu = new AdditionalMenu();
        }
        private class EconomyAppearance {
            [JsonProperty("Currency")]
            public string Currency;
            [JsonProperty("Value color")]
            public string Color;
            [JsonProperty("Enable")]
            public bool IsEnable;
            [JsonProperty("Which plugin use [ServerRewards | Economics]")]
            public string Plugin;
        }
        private class TimeAppearance {
            [JsonProperty("Use automatic detection of the time format for each player")]
            public bool IsAutomaticDetection;
            [JsonProperty("Use AM/PM format [If you use this turn off automatic detection]")]
            public bool IsAmPm;
            [JsonProperty("Value color")]
            public string Color;
            [JsonProperty("Enable")]
            public bool IsEnable;
        }
        private class BaseAppearance {
            [JsonProperty("Icon")]
            public string Icon;
            [JsonProperty("Color")]
            public string Color;
            [JsonProperty("Enable")]
            public bool IsEnable;
        }
        private class ActiveAppearance : BaseAppearance {
            [JsonProperty("Count admins")]
            public bool IsAdminsCount;
        }
        private class BaseEventsAppearance : BaseAppearance {
            [JsonIgnore]
            public bool isActive;
            [JsonProperty("Name")]
            public string Name;
            [JsonProperty("Active color")]
            public string ActiveColor;
        }
        private class CustomEventsAppearance : BaseEventsAppearance {
            [JsonProperty("Hook OnEventStart", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> OnEventStart;
            [JsonProperty("Hook OnEventStop", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> OnEventEnd;
        }
        private class AdditionalMenu {
            [JsonProperty("Auto close timer [seconds | 0 - disable]")]
            public int AutoCloseTime;
            [JsonProperty("Auto close after command use")]
            public bool AutoCloseCommand;
            [JsonProperty("Open/Close button color")]
            public string ButtonColor;
            [JsonProperty("Commands background opacity [0% - 100%]")]
            public int CommandsOpacity;
            [JsonProperty("Enable")]
            public bool IsEnable;
            [JsonProperty("Commands", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<CommandAppearance> Commands = new List<CommandAppearance>();
        }
        private class CommandAppearance {
            [JsonProperty("Background image")]
            public string Image;
            [JsonProperty("Icon [optional]")]
            public string Icon;
            [JsonProperty("Command")]
            public string Command;
            [JsonProperty("Permission to see")]
            public string PermissionToSee;
            [JsonProperty("Text")]
            public string Text;
            [JsonProperty("Outline color")]
            public string OutlineColor;
            [JsonProperty("Is Console")]
            public bool IsConsole;
        }
        private class InfoMessage {
            [JsonProperty("Update interval [in seconds]")]
            public int UpdateInterval;
            [JsonProperty("Align [BottomCenter | TopCenter | TopRight]")]
            public string Align;
            [JsonProperty("Width [in px]")]
            public int Width;
            [JsonProperty("Offset [top | bottom]")]
            public int OffsetTB;
            [JsonProperty("Offset [Center]")]
            public int OffsetR;
            [JsonProperty("Use Outline")]
            public bool UseOutline = true;
            [JsonProperty("Outline color")]
            public string OutlineColor;
            [JsonProperty("Overall [you will see messages in your invenotory]")]
            public bool IsOverall;
            [JsonProperty("Enable")]
            public bool IsEnable;
            [JsonProperty("Messages", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> Messages = new List<string>();
        }
        private class PlayerPositionAppearance {
            [JsonProperty("Enable")]
            public bool IsEnable;
            [JsonProperty("true - grid | false - x,z coordinates")]
            public bool IsGrid;
            [JsonProperty("Color")]
            public string Color;
        }
#endregion
#endregion
#region OxideHooks
        private void OnServerInitialized() {
            if (_config.AutoReload) ServerMgr.Instance.StartCoroutine(ConfigCheck());
            if (_config.GetEventByName("HarborCargoArrive") == null) {
                _config.BaseEvents.Add(new BaseEventsAppearance {
                    Name = "HarborCargoArrive", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/qysRW6X/harborevent2.png", IsEnable = true,
                }
                );
            }
            if (_config.GetEventByName("SmallOilRig") == null) {
                _config.BaseEvents.Add(new BaseEventsAppearance {
                    Name = "SmallOilRig", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/cbDJj7r/harborevent3.png", IsEnable = true,
                }
                );
            }
            if (_config.GetEventByName("LargeOilRig") == null) {
                _config.BaseEvents.Add(new BaseEventsAppearance {
                    Name = "LargeOilRig", Color = "#fff", ActiveColor = "#10ff10", Icon = "https://i.ibb.co/QPGXQHr/harborevent2.png", IsEnable = true,
                }
                );
            }
            LoadImages();
            LoadData();
            foreach (var check in _config.MainSetup.AdditionalMenu.Commands) {
                if (string.IsNullOrEmpty(check.PermissionToSee)) continue;
                permission.RegisterPermission(check.PermissionToSee, this);
            }
            FillCustomHooks();
            foreach (MonumentInfo monument in TerrainMeta.Path.Monuments) {
                if (monument.name == "assets/bundled/prefabs/autospawn/monument/offshore/oilrig_1.prefab") largeOilRigPosition = monument.transform.position;
                else if (monument.name == "assets/bundled/prefabs/autospawn/monument/offshore/oilrig_2.prefab") smallOilRigPosition = monument.transform.position;
            }
            EventsInit();
            if (_data.FirstRun) timer.In(5, () => {
                _data.FirstRun = false;
                Interface.Oxide.ReloadPlugin("ImageLibrary");
                Interface.Oxide.ReloadPlugin("Hud");
            }
            );
            permission.RegisterPermission(PERM_STREAMER, this);
            UI.Size = _config.MainSetup.Size / 100f;
            if (!_config.MainSetup.QueuePlayersAppearance.IsEnable) Unsubscribe(nameof(OnConnectionQueue));
            if (!_config.MainSetup.SleepPlayersAppearance.IsEnable) {
                Unsubscribe(nameof(OnPlayerSleep));
                Unsubscribe(nameof(OnPlayerSleepEnded));
            }
            foreach (var player in BasePlayer.activePlayerList) OnPlayerConnected(player);
            if (_config.MainSetup.InfoMessages.IsEnable) InfoMessageUpdate = timer.Every(_config.MainSetup.InfoMessages.UpdateInterval, () => {
                foreach (var check in BasePlayer.activePlayerList) ShowUIMessagesInfo(check);
            }
            );
            ServerMgr.Instance.StartCoroutine(InfoUpdate());
            timer.Once(60f, () => {
                var isUpdateNeeded = false;
                foreach (var item in AddedImages) if (!uint.TryParse(GetImage(item), out var resultCrc) || (FileStorage.server.Get(resultCrc, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID) == null)) {
                    AddImage(item);
                    isUpdateNeeded = true;
                }
                if (isUpdateNeeded) foreach (var player in BasePlayer.activePlayerList) OnPlayerConnected(player);
            }
            );
        }
        private void Unload() {
            SaveData();
            UI.DestroyToAll(".bg");
            UI.DestroyToAll(".bg.Messages.bg");
            UI.DestroyToAll(".bgSettings");
        }
        private void OnPlayerConnected(BasePlayer player) {
            if (player == null) return;
            _data.PlayersState.TryAdd(player.UserIDString, States.Full);
            ShowUIBG(player);
            NextTick(() => ShowUIPlayersCounts());
        }
        private void OnConnectionQueue(Network.Connection connection) => NextTick(() => ShowUIPlayersCounts());
        private void OnPlayerSleep(BasePlayer player) => NextTick(() => ShowUIPlayersCounts());
        private void OnPlayerDisconnected(BasePlayer player) => NextTick(() => ShowUIPlayersCounts());
        private void OnPlayerSleepEnded(BasePlayer player) => NextTick(() => ShowUIPlayersCounts());
#region EVENTS
        private void OnEntitySpawned(BradleyAPC entity) => EventTouch(entity);
        private void OnEntityKill(BradleyAPC entity) => EventTouch(entity);
        private void OnEntitySpawned(PatrolHelicopter entity) => EventTouch(entity);
        private void OnEntityKill(PatrolHelicopter entity) => EventTouch(entity);
        private void OnEntitySpawned(CH47Helicopter entity) => EventTouch(entity);
        private void OnEntityKill(CH47Helicopter entity) => EventTouch(entity);
        private void OnEntitySpawned(CargoShip entity) => EventTouch(entity);
        private void OnEntityKill(CargoShip entity) => EventTouch(entity);
        private void OnEntitySpawned(SupplyDrop entity) => EventTouch(entity);
        private void OnEntityKill(SupplyDrop entity) => EventTouch(entity);
        private void OnCargoShipHarborArrived(CargoShip entity) {
            _config.GetEventByName("HarborCargoArrive").isActive = true;
            NextTick(() => {
                _config.GetEventByName("Cargo").isActive = BaseNetworkable.serverEntities.OfType<CargoShip>().Any(x => !x.IsShipDocked);
                ShowUIEvents();
            }
            );
        }
        private void OnCargoShipHarborLeave(CargoShip entity) {
            _config.GetEventByName("HarborCargoArrive").isActive = false;
            NextTick(() => {
                _config.GetEventByName("Cargo").isActive = BaseNetworkable.serverEntities.OfType<CargoShip>().Any(x => !x.IsShipDocked);
                ShowUIEvents();
            }
            );
        }
        private void OnCrateHack(HackableLockedCrate crate) {
            if (crate is null || (!IsSmallOilRig(crate.transform.position) && !IsLargeOilRig(crate.transform.position))) return;
            _config.GetEventByName(IsSmallOilRig(crate.transform.position) ? "SmallOilRig" : "LargeOilRig").isActive = true;
            ShowUIEvents();
        }
        private void OnCrateHackEnd(HackableLockedCrate crate) {
            if (crate is null || (!IsSmallOilRig(crate.transform.position) && !IsLargeOilRig(crate.transform.position))) return;
            _config.GetEventByName(IsSmallOilRig(crate.transform.position) ? "SmallOilRig" : "LargeOilRig").isActive = false;
            ShowUIEvents();
        }
        private void OnEntityKill(HackableLockedCrate crate) {
            if (crate is null || (!IsSmallOilRig(crate.transform.position) && !IsLargeOilRig(crate.transform.position))) return;
            _config.GetEventByName(IsSmallOilRig(crate.transform.position) ? "SmallOilRig" : "LargeOilRig").isActive = false;
            ShowUIEvents();
        }
        private void EventTouch(BaseEntity entity) => NextTick(() => {
            if (entity?.OwnerID != 0) return;
            if (entity is BradleyAPC) _config.GetEventByName("Bradley").isActive = BaseNetworkable.serverEntities.OfType<BradleyAPC>().Any();
            else if (entity is PatrolHelicopter) _config.GetEventByName("PatrolHeli").isActive = BaseNetworkable.serverEntities.OfType<PatrolHelicopter>().Any();
            else if (entity is CH47Helicopter) _config.GetEventByName("CH47").isActive = BaseNetworkable.serverEntities.OfType<CH47Helicopter>().Any();
            else if (entity is CargoShip) _config.GetEventByName("Cargo").isActive = BaseNetworkable.serverEntities.OfType<CargoShip>().Any();
            else if (entity is SupplyDrop) _config.GetEventByName("AirDrop").isActive = BaseNetworkable.serverEntities.OfType<SupplyDrop>().Any();
            else return;
            ShowUIEvents();
        }
        );
#endregion
#endregion
#region Commands
        [ConsoleCommand("UI_H")]
        private void cmdConsoleUI_H(ConsoleSystem.Arg arg) {
            if (!arg.HasArgs()) return;
            var player = arg.Player();
            switch (arg.GetString(0)) {
                case "CHANGESTATE" : var state = _data.PlayersState[player.UserIDString];
                if (Interface.CallHook("CanHudChangeState", player, state.ToString(), (state == States.Full ? States.Events : state == States.Events ? States.Hide : States.Full).ToString()) != null) return;
                _data.PlayersState[player.UserIDString] = state == States.Full ? States.Events : state == States.Events ? States.Hide : States.Full;
                ShowUIMain(player);
                break;
                case "CHANGEADMENUSTATE" : ShowUIAdditionalMenu(player, !arg.GetBool(1));
                if (!arg.GetBool(1) && _config.MainSetup.AdditionalMenu.AutoCloseTime > 0) timer.Once(_config.MainSetup.AdditionalMenu.AutoCloseTime, () => ShowUIAdditionalMenu(player));
                break;
                case "USECOMMAND" : player.SendConsoleCommand(arg.GetBool(1) ? $"{string.Join(" ", arg.Args.Skip(2))}" : $"chat.say \"{string.Join(" ", arg.Args.Skip(2))}\"");
                if (_config.MainSetup.AdditionalMenu.AutoCloseCommand) ShowUIAdditionalMenu(player);
                break;
                case "s" : BaseAppearance ap = null;
                switch (arg.GetString(1)) {
                    case "io" : _config.MainSetup.IsOverall = !_config.MainSetup.IsOverall;
                    ShowUISettings(player);
                    break;
                    case "oa" : _config.MainSetup.OnlyActive = !_config.MainSetup.OnlyActive;
                    CalculateEventsWidth();
                    ShowUISettings(player);
                    break;
                    case "size" : _config.MainSetup.Size = arg.GetInt(2);
                    UI.Size = _config.MainSetup.Size / 100f;
                    ShowUISettings(player);
                    break;
                    case "logo" : _config.MainSetup.Logo = arg.GetString(2);
                    AddImage(_config.MainSetup.Logo);
                    ShowUISettings(player);
                    break;
                    case "eventsbgop" : _config.MainSetup.EventsBGOpacity = arg.GetInt(2);
                    ShowUISettings(player);
                    break;
                    case "bgop" : _config.MainSetup.BGOpacity = arg.GetInt(2);
                    ShowUISettings(player);
                    break;
                    case "posalign" : _config.MainSetup.Position.Align = arg.GetString(2);
                    ShowUISettings(player);
                    break;
                    case "posleft" : _config.MainSetup.Position.LeftOffSet = arg.GetInt(2);
                    ShowUISettings(player);
                    break;
                    case "postop" : _config.MainSetup.Position.TopOffSet = arg.GetInt(2);
                    ShowUISettings(player);
                    break;
                    case "name" : _config.MainSetup.ServerName = string.Join(" ", arg.Args.Skip(2));
                    ShowUISettings(player);
                    break;
                    case "activeopen" : OpenActivePlayersConfiguration(player);
                    break;
                    case "sleepopen" : ap = _config.MainSetup.SleepPlayersAppearance;
                    OpenPlayersConfiguration(player, "Sleep players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s senable", "UI_H s sicon ", "UI_H s scolor ");
                    break;
                    case "queueopen" : ap = _config.MainSetup.QueuePlayersAppearance;
                    OpenPlayersConfiguration(player, "Queue players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s qenable", "UI_H s qicon ", "UI_H s qcolor ");
                    break;
                    case "aenable" : ap = _config.MainSetup.ActivePlayersAppearance;
                    ap.IsEnable = !ap.IsEnable;
                    OpenActivePlayersConfiguration(player);
                    break;
                    case "aadminscount" : var activePlayers = _config.MainSetup.ActivePlayersAppearance;
                    activePlayers.IsAdminsCount = !activePlayers.IsAdminsCount;
                    OpenActivePlayersConfiguration(player);
                    break;
                    case "aicon" : _config.MainSetup.ActivePlayersAppearance.Icon = arg.GetString(2);
                    AddImage(ap.Icon);
                    OpenActivePlayersConfiguration(player);
                    break;
                    case "acolor" : _config.MainSetup.ActivePlayersAppearance.Color = arg.GetString(2);
                    OpenActivePlayersConfiguration(player);
                    break;
                    case "senable" : ap = _config.MainSetup.SleepPlayersAppearance;
                    ap.IsEnable = !ap.IsEnable;
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s senable", "UI_H s sicon ", "UI_H s scolor ");
                    break;
                    case "sicon" : ap = _config.MainSetup.SleepPlayersAppearance;
                    ap.Icon = arg.GetString(2);
                    AddImage(ap.Icon);
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s senable", "UI_H s sicon ", "UI_H s scolor ");
                    break;
                    case "scolor" : ap = _config.MainSetup.SleepPlayersAppearance;
                    ap.Color = arg.GetString(2);
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s senable", "UI_H s sicon ", "UI_H s scolor ");
                    break;
                    case "qenable" : ap = _config.MainSetup.QueuePlayersAppearance;
                    ap.IsEnable = !ap.IsEnable;
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s qenable", "UI_H s qicon ", "UI_H s qcolor ");
                    break;
                    case "qicon" : ap = _config.MainSetup.QueuePlayersAppearance;
                    ap.Icon = arg.GetString(2);
                    AddImage(ap.Icon);
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s qenable", "UI_H s qicon ", "UI_H s qcolor ");
                    break;
                    case "qcolor" : ap = _config.MainSetup.QueuePlayersAppearance;
                    ap.Color = arg.GetString(2);
                    OpenPlayersConfiguration(player, "Active players", ap.IsEnable, ap.Icon, ap.Color, "UI_H s qenable", "UI_H s qicon ", "UI_H s qcolor ");
                    break;
                    case "timeopen" : OpenClockConfiguration(player);
                    break;
                    case "playerposopen" : OpenPlayerPositionConfiguration(player);
                    break;
                    case "economyopen" : OpenEconomyConfiguration(player);
                    break;
                    case "tautodetect" : _config.MainSetup.Time.IsAutomaticDetection = !_config.MainSetup.Time.IsAutomaticDetection;
                    OpenClockConfiguration(player);
                    break;
                    case "tisam" : _config.MainSetup.Time.IsAmPm = !_config.MainSetup.Time.IsAmPm;
                    OpenClockConfiguration(player);
                    break;
                    case "tcolor" : _config.MainSetup.Time.Color = arg.GetString(2);
                    OpenClockConfiguration(player);
                    break;
                    case "tenable" : _config.MainSetup.Time.IsEnable = !_config.MainSetup.Time.IsEnable;
                    OpenClockConfiguration(player);
                    break;
                    case "ppisgrid" : _config.MainSetup.PlayerPosition.IsGrid = !_config.MainSetup.PlayerPosition.IsGrid;
                    OpenPlayerPositionConfiguration(player);
                    break;
                    case "ppcolor" : _config.MainSetup.PlayerPosition.Color = arg.GetString(2);
                    OpenPlayerPositionConfiguration(player);
                    break;
                    case "ppenabled" : _config.MainSetup.PlayerPosition.IsEnable = !_config.MainSetup.PlayerPosition.IsEnable;
                    OpenPlayerPositionConfiguration(player);
                    break;
                    case "ecurrency" : _config.MainSetup.Economy.Currency = arg.GetString(2);
                    OpenEconomyConfiguration(player);
                    break;
                    case "eplugin" : _config.MainSetup.Economy.Plugin = arg.GetString(2);
                    OpenEconomyConfiguration(player);
                    break;
                    case "ecolor" : _config.MainSetup.Economy.Color = arg.GetString(2);
                    OpenEconomyConfiguration(player);
                    break;
                    case "eenable" : _config.MainSetup.Economy.IsEnable = !_config.MainSetup.Economy.IsEnable;
                    OpenEconomyConfiguration(player);
                    break;
                    case "openinfo" : OpenInfoMessagesConfiguration(player);
                    break;
                    case "ienable" : _config.MainSetup.InfoMessages.IsEnable = !_config.MainSetup.InfoMessages.IsEnable;
                    if (_config.MainSetup.InfoMessages.IsEnable) {
                        InfoMessageUpdate?.Destroy();
                        InfoMessageUpdate = timer.Every(_config.MainSetup.InfoMessages.UpdateInterval, () => {
                            foreach (var check in BasePlayer.activePlayerList) ShowUIMessagesInfo(check);
                        }
                        );
                    }
                    else {
                        InfoMessageUpdate?.Destroy();
                        UI.DestroyToAll(UI.Layer + ".Messages.bg");
                    }
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "ioverall" : _config.MainSetup.InfoMessages.IsOverall = !_config.MainSetup.InfoMessages.IsOverall;
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "iuseoutline" : _config.MainSetup.InfoMessages.UseOutline = !_config.MainSetup.InfoMessages.UseOutline;
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "iupdateint" : _config.MainSetup.InfoMessages.UpdateInterval = arg.GetInt(2);
                    if (_config.MainSetup.InfoMessages.IsEnable) {
                        InfoMessageUpdate?.Destroy();
                        InfoMessageUpdate = timer.Every(_config.MainSetup.InfoMessages.UpdateInterval, () => {
                            foreach (var check in BasePlayer.activePlayerList) ShowUIMessagesInfo(check);
                        }
                        );
                    }
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "ialign" : _config.MainSetup.InfoMessages.Align = arg.GetString(2);
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "iwidth" : _config.MainSetup.InfoMessages.Width = arg.GetInt(2);
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "itboff" : _config.MainSetup.InfoMessages.OffsetTB = arg.GetInt(2);
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "iroff" : _config.MainSetup.InfoMessages.OffsetR = arg.GetInt(2);
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "ioutlinecolor" : _config.MainSetup.InfoMessages.OutlineColor = arg.GetString(2);
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "imremove" : _config.MainSetup.InfoMessages.Messages.RemoveAt(arg.GetInt(2));
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "imadd" : _config.MainSetup.InfoMessages.Messages.Add(string.Join(" ", arg.Args.Skip(2)));
                    OpenInfoMessagesConfiguration(player);
                    break;
                    case "amenable" : _config.MainSetup.AdditionalMenu.IsEnable = !_config.MainSetup.AdditionalMenu.IsEnable;
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amautoclose" : _config.MainSetup.AdditionalMenu.AutoCloseCommand = !_config.MainSetup.AdditionalMenu.AutoCloseCommand;
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amclosetimer" : _config.MainSetup.AdditionalMenu.AutoCloseTime = arg.GetInt(2);
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amopacity" : _config.MainSetup.AdditionalMenu.CommandsOpacity = arg.GetInt(2);
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amcolor" : _config.MainSetup.AdditionalMenu.ButtonColor = arg.GetString(2);
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amopen" : OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amcreatenew" : _config.MainSetup.AdditionalMenu.Commands.Add(new CommandAppearance {
                        Text = "Nex Example", Command = "chat.say Hello there", Icon = "https://www.dropbox.com/scl/fi/weax6ug55o0u4f87bhchs/active.png?rlkey=lbpuhpqs7tutpgv1i4t3b1107&dl=1", Image = "https://www.dropbox.com/scl/fi/ypbnnbs07i2t322x1pu4c/command.png?rlkey=a693i43bn70wiy2p0v0216uw7&dl=1", IsConsole = true, OutlineColor = "#000", PermissionToSee = "",
                    }
                    );
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "amedit" : OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "ceventhookedit" : OpenEventHookList(player, arg.GetInt(2), arg.GetInt(3));
                    break;
                    case "amebtext" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Text = string.Join(" ", arg.Args.Skip(3));
                    OpenAdditionalMenuConfiguration(player);
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "amebcommand" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Command = string.Join(" ", arg.Args.Skip(3));
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "ameboutlinecolor" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].OutlineColor = arg.GetString(3);
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "amebicon" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Icon = arg.GetString(3);
                    AddImage(_config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Icon);
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "amebimage" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Image = arg.GetString(3);
                    AddImage(_config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].Image);
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "amebisconsole" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].IsConsole = !_config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].IsConsole;
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "apermtosee" : _config.MainSetup.AdditionalMenu.Commands[arg.GetInt(2)].PermissionToSee = arg.GetString(3);
                    OpenAdditionalMenuButtonConfiguration(player, arg.GetInt(2));
                    break;
                    case "ambdelete" : _config.MainSetup.AdditionalMenu.Commands.RemoveAt(arg.GetInt(2));
                    OpenAdditionalMenuConfiguration(player);
                    break;
                    case "beopen" : OpenBaseEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "beenable" : _config.BaseEvents[arg.GetInt(2)].IsEnable = !_config.BaseEvents[arg.GetInt(2)].IsEnable;
                    CalculateEventsWidth();
                    OpenBaseEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "beicon" : _config.BaseEvents[arg.GetInt(2)].Icon = arg.GetString(3);
                    AddImage(_config.BaseEvents[arg.GetInt(2)].Icon);
                    ShowUISettings(player);
                    OpenBaseEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "beacolor" : _config.BaseEvents[arg.GetInt(2)].ActiveColor = arg.GetString(3);
                    OpenBaseEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "becolor" : _config.BaseEvents[arg.GetInt(2)].Color = arg.GetString(3);
                    OpenBaseEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "ceopen" : OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "ceenable" : _config.CustomEvents[arg.GetInt(2)].IsEnable = !_config.CustomEvents[arg.GetInt(2)].IsEnable;
                    CalculateEventsWidth();
                    OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "cename" : _config.CustomEvents[arg.GetInt(2)].Name = arg.GetString(3);
                    OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "ceicon" : _config.CustomEvents[arg.GetInt(2)].Icon = arg.GetString(3);
                    AddImage(_config.CustomEvents[arg.GetInt(2)].Icon);
                    OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "ceactivecolor" : _config.CustomEvents[arg.GetInt(2)].ActiveColor = arg.GetString(3);
                    OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "cecolor" : _config.CustomEvents[arg.GetInt(2)].Color = arg.GetString(3);
                    OpenCustomEventConfiguration(player, arg.GetInt(2));
                    break;
                    case "cedelete" : _config.CustomEvents.RemoveAt(arg.GetInt(2));
                    CalculateEventsWidth();
                    ShowUISettings(player);
                    break;
                    case "ceventhooksstartrem" : _config.CustomEvents[arg.GetInt(2)].OnEventStart.RemoveAt(arg.GetInt(3));
                    OpenEventHookList(player, arg.GetInt(2), 1);
                    break;
                    case "ceventhooksendrem" : _config.CustomEvents[arg.GetInt(2)].OnEventEnd.RemoveAt(arg.GetInt(3));
                    OpenEventHookList(player, arg.GetInt(2), 0);
                    break;
                    case "ceventhooksaddstart" : _config.CustomEvents[arg.GetInt(2)].OnEventStart.Add(arg.GetString(3));
                    OpenEventHookList(player, arg.GetInt(2), 1);
                    break;
                    case "ceventhooksaddend" : _config.CustomEvents[arg.GetInt(2)].OnEventEnd.Add(arg.GetString(3));
                    OpenEventHookList(player, arg.GetInt(2), 0);
                    break;
                    case "ceadd" : _config.CustomEvents.Add(new CustomEventsAppearance {
                        Name = "CustomEvent", IsEnable = true, Color = "#fff", Icon = "https://www.dropbox.com/scl/fi/3qzyayoa4dxog2t8gyvzw/harbor.png?rlkey=v7jnpk8tyngwywvhbgrfhk5a4&dl=1", ActiveColor = "
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок

Другие ресурсы пользователя 15FPS

Сверху