C#:
using System;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System.Collections;
using System.Linq;
using Random = UnityEngine.Random;
using Oxide.Core.Libraries.Covalence;
namespace Oxide.Plugins {
[Info("MultiEvents", "Mevent#4546", "1.34.0")]
public class MultiEvents : RustPlugin {
#region Fields
[PluginReference]
private Plugin Duel, ImageLibrary;
private const string Layer = "UI.MultiEvents";
private int time;
private BasePlayer winner = null;
private BasePlayer runner = null;
private List<string> Winners = new List<string>();
private bool hasStarted;
private string nowEvent = null;
private Dictionary<BasePlayer, float> PlayersTop = new Dictionary<BasePlayer, float>();
private List<LootContainer> LookingLoot = new List<LootContainer>();
private static MultiEvents instance;
private static Vector3 EventPosition;
private static FoundationDrop cEvent = null;
private MonumentInfo beginning_mission = null;
private MonumentInfo end_mission = null;
private Dictionary<int, RadZone> RadiationZones = new Dictionary<int, RadZone>();
private static readonly int playerLayer = LayerMask.GetMask("Player (Server)");
private Action aStartEvent = null;
private Action EventRepeating = null;
private Action DestroyAction = null;
public enum ItemTypes {
Item, Command
}
#endregion
#region Config
private static Configuration config;
private class Configuration {
[JsonProperty("Использовать автоматический запуск ивентов?")]
public bool useTimer = true;
[JsonProperty("Задержка между эвентами")]
public int Delay = 3600;
[JsonProperty("Отклонение от стандартного времени (рандомное время)")]
public int RandomTime = 900;
[JsonProperty("Максимальная длина никнейма")]
public int NameLenght = 16;
[JsonProperty("Эвенты доступные для игроков", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> EnabledEvents = new List<string> {
"KingMountain", "CollectionResources", "HuntAnimal", "HelicopterPet", "LookingLoot", "SpecialCargo", "FoundationDrop"
}
;
[JsonProperty("Право на запуск ивента")]
public string perm_admin = "multievents.admin";
[JsonProperty("Команда открытия склада")]
public string cmdStorage = "storage";
[JsonProperty("Включить оповещение о получении награды?")]
public bool EnableRewardAlert = true;
[JsonProperty("Настройка эвента ЛЮБИМЧИК ВЕРТОЛЁТА")]
public EventSettings HelicopterPet = new EventSettings {
MinPlayers = 4, TimeDelay = 300, ImageUrl = "https://i.imgur.com/owDanC1.png", ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
,
}
;
[JsonProperty("Настройка эвента ОХОТА НА ЖИВОТНЫХ")]
public HuntAnimalSettings HuntAnimal = new HuntAnimalSettings {
MinPlayers = 4, TimeDelay = 300, ImageUrl = "https://i.imgur.com/9gTw3kN.png", chicken = 1, wolf = 4, boar = 4, deer = 4, horse = 4, bear = 10, ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
, new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
, new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
,
}
;
[JsonProperty("Настройка эвента КОРОЛЬ ГОРЫ")]
public KingMountainSettings KingMountain = new KingMountainSettings {
checkDuels = true, checkHotair = true, checkMinicopter = true, checkScrapheli = true, checkBuilding = true, MinPlayers = 4, TimeDelay = 300, ImageUrl = "https://i.imgur.com/dLWgxg7.png", ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
}
,
}
;
[JsonProperty("Настройка эвента СБОР РЕСУРСОВ")]
public CollectionResourcesSettings CollectionResources = new CollectionResourcesSettings() {
MinPlayers = 4, TimeDelay = 300, ImageUrl = "https://i.imgur.com/FggJeaH.png", ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, BlockItems = new List<string> {
"jackhammer", "chainsaw"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
, new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
, new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
,
}
;
[JsonProperty("Настройка эвента В ПОИСКАХ ЛУТА")]
public LookingLootSettings LookingLoot = new LookingLootSettings {
MinPlayers = 4, TimeDelay = 300, ImageUrl = "https://i.imgur.com/4ZOIs33.png", Barrels = new List<string> {
"assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-1.prefab", "assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-2.prefab", "assets/bundled/prefabs/radtown/loot_barrel_1.prefab", "assets/bundled/prefabs/radtown/loot_barrel_2.prefab", "assets/bundled/prefabs/radtown/oil_barrel.prefab"
}
, ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
,
}
;
[JsonProperty("Настройка эвента ДОСТАВКА ОСОБОГО ГРУЗА")]
public SpecialCargoSettings SpecialCargo = new SpecialCargoSettings {
tpBlock = true, MarkerName = "ОСОБЫЙ ГРУЗ", MinPlayers = 4, TimeDelay = 1800, ImageUrl = "https://i.imgur.com/Dp9bMSl.png", timeNewRunner = 6, timeStart = 4, blockMonuments = new List<string> {
"oilrig", "cave", "power_sub"
}
, ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
,
}
;
[JsonProperty("Настройка эвента ПАДАЮЩИЕ ПЛАТФОРМЫ")]
public FoundationDropSettings FoundationDrop = new FoundationDropSettings {
loot = new List<Loot> {
new Loot {
itemenabled = true, cashenabled = true, items = new List<List<Items>> {
new List<Items> {
new Items {
Type = ItemTypes.Item, Item = new ItemConfClass {
ShortName = "autoturret", SkinID = 0, minAmount = 1, maxAmount = 1
}
, DisplayName = string.Empty, Command = string.Empty, ImageURL = string.Empty
}
, new Items {
Type = ItemTypes.Command, Item = new ItemConfClass {
SkinID = 0, ShortName = string.Empty, minAmount = 1, maxAmount = 1
}
, Command = "addgroup %steamid% vip 1d", DisplayName = "VIP на 1 день", ImageURL = "https://i.imgur.com/GuJUyLH.png"
}
}
}
, cash = new Cash {
function = "Deposit", plugin = "Economics", amount = 400,
}
}
,
}
, MinPlayers = 4, TimeDelay = 1800, ImageUrl = "https://i.imgur.com/B4DCBs2.png", ArenaSize = 10, DelayDestroy = 5f, WaitTime = 60, IntensityRadiation = 10f, DisableDefaultRadiation = false, ui = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -305", oMax = "-5 -5"
}
, infoUI = new Interface {
color = "0.024 0.016 0.17 0.7", oMin = "-225 -100", oMax = "-5 -5"
}
, commands = new List<string> {
"bp", "backpack", "skin", "skinbox", "rec", "tpa", "tpr", "sethome", "home", "kit", "remove"
}
}
;
}
public class Interface {
[JsonProperty("Цвет фона")]
public string color;
[JsonProperty("Offset Min")]
public string oMin;
[JsonProperty("Offset Max")]
public string oMax;
}
public class EventSettings {
[JsonProperty("Настройка интерфейса ивента")]
public Interface ui;
[JsonProperty("Сколько игроков требуется для начала эвента?")]
public int MinPlayers;
[JsonProperty("Время продолжительности эвента (в секундах)")]
public int TimeDelay;
[JsonProperty("Ссылка на картинку")]
public string ImageUrl;
[JsonProperty("Настройка приза для победителя", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<Loot> loot;
}
public class HuntAnimalSettings : EventSettings {
[JsonProperty("Сколько очков даётся за курицу?")]
public int chicken;
[JsonProperty("Сколько очков даётся за волка?")]
public int wolf;
[JsonProperty("Сколько очков даётся за кабана?")]
public int boar;
[JsonProperty("Сколько очков даётся за оленя?")]
public int deer;
[JsonProperty("Сколько очков даётся за лошадь?")]
public int horse;
[JsonProperty("Сколько очков даётся за медведя?")]
public int bear;
}
public class CollectionResourcesSettings : EventSettings {
[JsonProperty("Список предметов, добыча при помощи которых не учитывается")]
public List<string> BlockItems;
}
public class KingMountainSettings : EventSettings {
[JsonProperty("Блокировать людей на дуэдли (Duels)")]
public bool checkDuels;
[JsonProperty("Блокировать людей в миникоптере")]
public bool checkMinicopter;
[JsonProperty("Блокировать людей в скрап вертолёте")]
public bool checkScrapheli;
[JsonProperty("Блокировать людей в воздушномшаре")]
public bool checkHotair;
[JsonProperty("Блокировать людей в билде (когда игрок авторизован в шкафу)")]
public bool checkBuilding;
}
public class LookingLootSettings : EventSettings {
[JsonProperty("Лутание каких бочек считаются в эвенте?", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> Barrels;
}
public class SpecialCargoSettings : EventSettings {
[JsonProperty("Время показа уведомления о запуске ивента")]
public float timeStart;
[JsonProperty("Время показа уведомления об объявлении бегущего")]
public float timeNewRunner;
[JsonProperty("Название маркера для карты")]
public string MarkerName;
[JsonProperty("Блокировать телепортацию для бегущего?")]
public bool tpBlock;
[JsonProperty("Запрещённые монументы для игры", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> blockMonuments;
}
public class FoundationDropSettings : EventSettings {
[JsonProperty("Настройка интерфейса с информацией о количестве игроков и блоков")]
public Interface infoUI;
[JsonProperty("Размер арены в квадратах")]
public int ArenaSize;
[JsonProperty("Интвервал между удалениями блоков")]
public float DelayDestroy;
[JsonProperty("Время ожидания игроков с момента объявления ивента")]
public int WaitTime;
[JsonProperty("Интенсивность созданой радиации")]
public float IntensityRadiation;
[JsonProperty("Отключить стандартную радиацию на РТ (Это нужно в случае если у Вас отключена радиация, плагин включит её обратно но уберёт на РТ)")]
public bool DisableDefaultRadiation;
[JsonProperty("Заблокированные команды", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<string> commands;
}
public class Loot {
[JsonProperty("Выдавать предмет?")]
public bool itemenabled;
[JsonProperty("Выдавать баланс?")]
public bool cashenabled;
[JsonProperty("Настройка предмета", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<List<Items>> items;
[JsonProperty("Настройка баланса")]
public Cash cash;
}
public class ItemConfClass : ItemClass {
[JsonProperty(PropertyName = "Минимальное количество предмета")]
public int minAmount;
[JsonProperty(PropertyName = "Максимальное количество предмета")]
public int maxAmount;
}
public class Items {
[JsonProperty(PropertyName = "Тип предмета")]
[JsonConverter(typeof(StringEnumConverter))]
public ItemTypes Type;
[JsonProperty(PropertyName = "Предмет")]
public ItemConfClass Item;
[JsonProperty(PropertyName = "Команда")]
public string Command;
[JsonProperty(PropertyName = "Отображаемое имя (если ковычки - дефолт из игры)")]
public string DisplayName;
[JsonProperty(PropertyName = "Картинка (если пусто - по шортнейму)")]
public string ImageURL;
public DataItem ToDataItem() {
return new DataItem {
Type = Type, item = new ItemClass {
ShortName = Item.ShortName, SkinID = Item.SkinID
}
, Command = Command, DisplayName = DisplayName, Amount = Type == ItemTypes.Item ? UnityEngine.Random.Range(Item.minAmount, Item.maxAmount) : 1, ImageURL = ImageURL
}
;
}
}
public class Cash {
[JsonProperty("Название функции для вызова")]
public string function;
[JsonProperty("Название плагина")]
public string plugin;
[JsonProperty("Количество денег")]
public int amount;
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) throw new Exception();
SaveConfig();
}
catch {
PrintError("Your configuration file contains an error. Using default configuration values.");
LoadDefaultConfig();
}
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultConfig() => config = new Configuration();
#endregion
#region Data
private static PluginData _data;
private void SaveData() => Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject(Name, _data);
private void LoadData() {
try {
_data = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<PluginData>(Name);
}
catch (Exception e) {
PrintError(e.ToString());
}
if (_data == null) _data = new PluginData();
}
private class PluginData {
[JsonProperty(PropertyName = "Players Data", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public Dictionary<ulong, List<DataItem>> PlayersData = new Dictionary<ulong, List<DataItem>>();
}
public class DataItem {
[JsonProperty(PropertyName = "Тип предмета")]
public ItemTypes Type;
[JsonProperty(PropertyName = "Предмет")]
public ItemClass item;
[JsonProperty(PropertyName = "Команда")]
public string Command;
[JsonProperty(PropertyName = "Отображаемое имя (если ковычки - дефолт из игры)")]
public string DisplayName;
[JsonProperty(PropertyName = "Количество")]
public int Amount;
[JsonProperty(PropertyName = "Картинка (если пусто - по шортнейму)")]
public string ImageURL;
public Item ToItem() {
var newItem = ItemManager.CreateByName(item.ShortName, Amount, item.SkinID);
if (newItem == null) {
instance?.PrintError($"Error creating item with shortname '{item.ShortName}'");
return null;
}
if (!string.IsNullOrEmpty(DisplayName)) newItem.name = DisplayName;
return newItem;
}
public void GiveCmd(BasePlayer player) {
string command = Command.Replace("\n", "|").Replace("%steamid%", player.UserIDString, StringComparison.OrdinalIgnoreCase).Replace("%username%", player.displayName, StringComparison.OrdinalIgnoreCase);
instance?.Server.Command(command);
}
}
public class ItemClass {
[JsonProperty(PropertyName = "Короткое название предмета")]
public string ShortName;
[JsonProperty(PropertyName = "Skin ID предмета")]
public ulong SkinID;
}
#endregion
#region Initialization
private void OnServerInitialized() {
LoadData();
PrintWarning(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
PrintWarning($" {Name} v{Version} loading");
if (!ImageLibrary) {
PrintError(" Install plugin: 'ImageLibrary'");
Core.Interface.Oxide.UnloadPlugin(Title);
return;
}
PrintWarning($" Plugin loaded - OK");
PrintWarning(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
if (config.useTimer) {
aStartEvent = () => StartEvent(config.EnabledEvents.GetRandom());
InvokeHandler.Instance.InvokeRandomized(aStartEvent, config.Delay, config.Delay, config.RandomTime);
}
cmd.AddChatCommand(config.cmdStorage, this, nameof(CmdChatOpenStorage));
if (!permission.PermissionExists(config.perm_admin, this)) permission.RegisterPermission(config.perm_admin, this);
#region ImageLibrary
ImageLibrary.Call("AddImage", config.CollectionResources.ImageUrl, "CollectionResources");
ImageLibrary.Call("AddImage", config.FoundationDrop.ImageUrl, "FoundationDrop");
ImageLibrary.Call("AddImage", config.HelicopterPet.ImageUrl, "HelicopterPet");
ImageLibrary.Call("AddImage", config.HuntAnimal.ImageUrl, "HuntAnimal");
ImageLibrary.Call("AddImage", config.KingMountain.ImageUrl, "KingMountain");
ImageLibrary.Call("AddImage", config.LookingLoot.ImageUrl, "LookingLoot");
ImageLibrary.Call("AddImage", config.SpecialCargo.ImageUrl, "SpecialCargo");
ImageLibrary.Call("AddImage", "https://i.imgur.com/Okt1BMH.png", "ME_Background_image");
ImageLibrary.Call("AddImage", "https://i.imgur.com/DpLldC8.png", "ME_Logo_image");
foreach(var img in config.CollectionResources.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.FoundationDrop.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.HelicopterPet.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.HuntAnimal.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.KingMountain.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.LookingLoot.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach (var img in config.SpecialCargo.loot.SelectMany(p => p.items).SelectMany(p => p)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
foreach(var img in _data.PlayersData.SelectMany(p => p.Value)) {
if (!string.IsNullOrEmpty(img.ImageURL)) ImageLibrary.Call("AddImage", img.ImageURL, img.ImageURL);
}
#endregion
#region FoundationDrop
var entityList = BaseNetworkable.serverEntities.entityList.Values;
for (var i = 0; i < entityList.Count; i++) {
var entity = entityList[i] as BuildingBlock;
if (entity == null || entity.IsDestroyed || entity.OwnerID != 98596) continue;
entity.Kill();
}
#endregion
instance = this;
}
private void Init() {
Unsubscribe(nameof(OnCollectiblePickup));
Unsubscribe(nameof(OnGrowableGather));
Unsubscribe(nameof(OnDispenserBonus));
Unsubscribe(nameof(OnDispenserGather));
Unsubscribe(nameof(OnEntityDeath));
Unsubscribe(nameof(OnLootEntity));
Unsubscribe(nameof(OnPlayerDeath));
Unsubscribe(nameof(OnEntityKill));
Unsubscribe(nameof(ClearTeleport));
Unsubscribe(nameof(FoundationDrop));
Unsubscribe(nameof(OnPlayerDisconnected));
Unsubscribe(nameof(DropFoundation));
Unsubscribe(nameof(Downgrader));
Unsubscribe(nameof(HeliPet));
Unsubscribe(nameof(SCmarker));
Unsubscribe(nameof(OnUserCommand));
Unsubscribe(nameof(OnServerCommand));
Unsubscribe(nameof(OnPlayerLand));
Unsubscribe(nameof(OnRunPlayerMetabolism));
Unsubscribe(nameof(CanTeleport));
}
private void OnServerSave() => SaveData();
private void Unload() {
SaveData();
if (aStartEvent != null) InvokeHandler.Instance.CancelInvoke(aStartEvent);
if (hasStarted) {
try {
DestroyEvent(nowEvent);
}
catch (NullReferenceException) {
for (int i = 0; i < BasePlayer.activePlayerList.Count; i++) {
var player = BasePlayer.activePlayerList[i];
CuiHelper.DestroyUi(player, Layer);
CuiHelper.DestroyUi(player, Layer + ".Notification");
CuiHelper.DestroyUi(player, Layer + ".SpecialCargo");
CuiHelper.DestroyUi(player, Layer + ".FoundationDrop.Play");
}
for (int i = 0; i < BaseNetworkable.serverEntities.entityList.Values.Count; i++) {
var entity = BaseNetworkable.serverEntities.entityList.Values[i] as BuildingBlock;
if (entity == null || entity.IsDestroyed || entity.OwnerID != 98596) continue;
entity.Kill();
}
foreach (var downgrade in UnityEngine.Object.FindObjectsOfType<Downgrader>()) downgrade?.Kill();
foreach (var marker in UnityEngine.Object.FindObjectsOfType<SCmarker>()) marker?.Kill();
foreach (var radZone in UnityEngine.Object.FindObjectsOfType<RadZone>()) radZone?.Kill();
}
}
instance = null;
cEvent = null;
config = null;
_data = null;
}
#endregion
#region Functions
private void StartEvent(string type, BasePlayer target = null) {
if (hasStarted || !string.IsNullOrEmpty(nowEvent)) DestroyEvent(nowEvent);
nowEvent = type;
if (EventRepeating != null && InvokeHandler.Instance.IsInvoking(EventRepeating)) {
InvokeHandler.Instance.CancelInvoke(EventRepeating);
}
if (DestroyAction != null && InvokeHandler.Instance.IsInvoking(DestroyAction)) {
InvokeHandler.Instance.CancelInvoke(DestroyAction);
}
DestroyAction = () => DestroyEvent(nowEvent);
PlayersTop = new Dictionary<BasePlayer, float>();
switch (type) {
case "KingMountain" : {
if (BasePlayer.activePlayerList.Count < config.KingMountain.MinPlayers && target == null) return;
for (int i = 0; i < BasePlayer.activePlayerList.Count; i++) TopUI(BasePlayer.activePlayerList[i], "all", GetMessage(type, BasePlayer.activePlayerList[i].UserIDString), oMin : config.KingMountain.ui.oMin, oMax : config.KingMountain.ui.oMax, color : config.KingMountain.ui.color);
time = config.KingMountain.TimeDelay;
EventRepeating = () => {
var list = PlayersTop.OrderByDescending(p => p.Value).Take(8).ToList();
foreach (var player in BasePlayer.activePlayerList) {
TopUI(player, "refresh", list : list);
if (player.GetMounted() || player.IsFlying || config.KingMountain.checkBuilding && player.IsBuildingAuthed() || config.KingMountain.checkDuels && IsDuelPlayer(player) || config.KingMountain.checkScrapheli && player.GetComponentInParent<ScrapTransportHelicopter>() != null || config.KingMountain.checkMinicopter && player.GetComponentInParent<MiniCopter>() != null || config.KingMountain.checkHotair && player.GetComponentInParent<HotAirBalloon>() != null) continue;
if (!PlayersTop.ContainsKey(player)) PlayersTop.Add(player, player.transform.position.y);
else PlayersTop[player] = player.transform.position.y;
}
time--;
}
;
InvokeHandler
// ... [Code preview truncated due to length. Full source in attached file] ...