C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using UnityEngine;
using Oxide.Plugins.MonumentOwnerExtensionMethods;
using Oxide.Game.Rust.Cui;
using System.Collections;
using Oxide.Core.Libraries;
using CompanionServer.Handlers;
using Newtonsoft.Json.Linq;
namespace Oxide.Plugins {
[Info("MonumentOwner", "jtedal", "1.4.1")]
internal class MonumentOwner : RustPlugin {
private const bool En = true;
#region Config
private PluginConfig _config;
protected override void LoadDefaultConfig() {
Puts("Creating a default config...");
_config = PluginConfig.DefaultConfig();
_config.PluginVersion = Version;
SaveConfig();
Puts("Creation of the default config completed!");
}
protected override void LoadConfig() {
base.LoadConfig();
_config = Config.ReadObject<PluginConfig>();
if (_config.PluginVersion < Version) {
UpdateConfigValues();
}
}
private void UpdateConfigValues() {
Puts("Config update detected! Updating config values...");
if (_config.PluginVersion < new VersionNumber(1, 3, 4)) {
_config.LootPlayerBackpack = true;
_config.BossMonster = new BossMonsterConfig() {
StartKillingBoss = true, Damage = 300.0f, ScaleDamageBoss = 1.0f, Cooldown = 1200
}
;
_config.ScaleDamageNPC = 1.0f;
}
if (_config.PluginVersion < new VersionNumber(1, 3, 7)) {
_config.Notifications.Notification_NoDamageTarget = true;
}
_config.PluginVersion = Version;
Puts("Config update completed!");
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(_config);
public class BossMonsterConfig {
[JsonProperty(En ? "The player will immediately receive the owner status if he deals N amount of damage to the boss:" : "Игрок немедленно получит статус владельца, если нанесет N кол-во урона боссу:")]
public bool StartKillingBoss {
get;
set;
}
[JsonProperty(En ? "Amount damage:" : "Кол-во урона:")]
public float Damage {
get;
set;
}
[JsonProperty(En ? "Damage ratios (per Boss) to calculate becoming owner of the monument" : "Коэффициенты ущерба (по Боссу) для расчета, чтобы стать владельцем монумента")]
public float ScaleDamageBoss {
get;
set;
}
[JsonProperty(En ? "The time during which the player will not be able to deal damage to the boss after player has killed him:" : "Время, в течении которого игрок не сможет нанести урон босу, после того, как его убил:")]
public float Cooldown {
get;
set;
}
}
public class RulesForNoOwnerConfig {
[JsonProperty(En ? "Can a non owner enter or stay in the zone:" : "Могут ли заходить или оставаться в зоне:")]
public bool CanEnterNoOwner {
get;
set;
}
[JsonProperty(En ? "Can deal damage to NPCs if not an owner:" : "Могут ли наносить урон по NPC:")]
public bool DamageNpc {
get;
set;
}
[JsonProperty(En ? "Can deal damage to tanks if not an owner:" : "Могут ли наносить урон по танку:")]
public bool DamageTank {
get;
set;
}
[JsonProperty(En ? "Can deal damage to barrel if not an owner:" : "Могут ли наносить урон бочке:")]
public bool DamageBarrel {
get;
set;
}
[JsonProperty(En ? "Can crates be looted if not an owner:" : "Могут ли открывать крейты:")]
public bool LootCrate {
get;
set;
}
[JsonProperty(En ? "Can collectable items (diesel, cards) be pickup if not an owner:" : "Могут ли подбирать Collectable предметы (дизельки, карточки и т.д.):")]
public bool PickupCollectableItems {
get;
set;
}
[JsonProperty(En ? "Can crates be hacked if not an owner:" : "Могут ли взламывать крейты:")]
public bool HackCrate {
get;
set;
}
[JsonProperty(En ? "Can backpacks be looted if not an owner:" : "Могут ли открывать рюкзаки:")]
public bool LootBackpacks {
get;
set;
}
[JsonProperty(En ? "Can recycler be used if not an owner:" : "Могут ли использовать переработчик:")]
public bool UseRecycler {
get;
set;
}
[JsonProperty(En ? "Can NPCs target players if not an owner:" : "Могут ли NPC атаковать не владельцев монумента:")]
public bool TargetNpc {
get;
set;
}
[JsonProperty(En ? "Can tanks target players if not an owner:" : "Может ли Bradley атаковать не владельцев монумента:")]
public bool TargetBradley {
get;
set;
}
}
public class RulesBecomeOwnerConfig {
[JsonProperty(En ? "If True the player must meet ALL enabled conditions to receive Owner of the Monument status; If False the player must meet only one of the enabled conditions to receive Owner of the Monument status:" : "Укажите true, если игрок должен выполнить все включенные условия для получения статуса «Владелец монумента».Укажите false, если игрок должен выполнить одно из включенных условий для полкчения статуса «Владелец монумента».")]
public bool AllTerms {
get;
set;
}
[JsonProperty(En ? "The player must stay in the monument zone for a this amount of time [seconds] To disable this parameter set the value to [-1]:" : "Игрок должен находится определенное кол-во времени [сек.] в зоне монумента (Чтобы отключить этот параметр, укажите значение [-1] ):")]
public int TimeToGetOwner {
get;
set;
}
[JsonProperty(En ? "The player must deal this amount of damage [total damage] To disable this parameter set the value to [-1]:" : "Игрок должен нанести определенное кол-во урона (Чтобы отключить этот параметр, укажите значение [-1] ):")]
public float Damage {
get;
set;
}
[JsonProperty(En ? "The player must open the crate:" : "Игрок должен открыть крейт:")]
public bool OpenCrate {
get;
set;
}
[JsonProperty(En ? "The player must open a keycard security door:" : "Игрок должен открыть дверь ключ-картой:")]
public bool OpenDoor {
get;
set;
}
[JsonProperty(En ? "The player must start a quarry:" : "Игрок должен запустить карьер (только для маленьких карьеров на карте):")]
public bool StartQuarry {
get;
set;
}
[JsonProperty(En ? "The player must start Giant Excavator:" : "Игрок должен запустить экскаватор (только для Экскаватора):")]
public bool StartExcavator {
get;
set;
}
[JsonProperty(En ? "The player will immediately receive the status of the owner, if he starts hacking the crate:" : "Игрок немедленно получит статус владельца, если начнет взламывать крейт:")]
public bool StartHackCrate {
get;
set;
}
}
public class TimersOutsideZone {
[JsonProperty(En ? "The amount of time which the owner can leave the monument area and retain their title in seconds:" : "Время, в течение которого владелец монумента может покинуть зону монумента и сохранить титул [сек.]:")]
public int TimeExitOwner {
get;
set;
}
[JsonProperty(En ? "Warning time for owner of status expiration in seconds:" : "Время предупреждения до истечения срока действия статуса владельца [сек.]:")]
public int AlertTimeOutsideZone {
get;
set;
}
}
public class TimersInsideZone {
[JsonProperty(En ? "Timed duration which the player will retaion ownership of the monument in seconds:" : "Время, в течении которого игрок будет владельцем монумента [сек.]:")]
public int TimeOwner {
get;
set;
}
[JsonProperty(En ? "Warning time for owner of status expiration in seconds:" : "Время предупреждения до истечения статуса владельца события [сек.]:")]
public int AlertTimeInsideZone {
get;
set;
}
}
public class MonumentConfig {
[JsonProperty(En ? "Temporary rules for those inside the monument area." : "Временные правила для тех, кто внутри зоны монумента.")]
public TimersInsideZone TimersInsideZone {
get;
set;
}
[JsonProperty(En ? "Temporary rules for those who left the monument area." : "Временные правила для тех, кто вышел из зоны монумента.")]
public TimersOutsideZone TimersOutsideZone {
get;
set;
}
[JsonProperty(En ? "Cooldown timer after becoming monument owner during which the player cannot claim the title again in seconds." : "Время, в течении которого игрок не сможет стать владельцем монумента, после того как он был его владельцем [сек.]")]
public double CooldownOwner {
get;
set;
}
[JsonProperty(En ? "Rules for obtaining monument owner status." : "Правила для получения статуса «Владелец монумента».")]
public RulesBecomeOwnerConfig RulesBecomeOwner {
get;
set;
}
[JsonProperty(En ? "Monument rules if not monument owner." : "Правила для не владельцев монумента.")]
public RulesForNoOwnerConfig RulesForNoOwner {
get;
set;
}
}
public class NotificationsConfig {
[JsonProperty(En ? "You are now the monument owner for {0} seconds!" : "Вы стали владельцем монумента на {0} сек!")]
public bool Notification_YouOwnerMonument {
get;
set;
}
[JsonProperty(En ? "You have lost ownership of the monument!" : "Вы утратили статус владельца монумента!")]
public bool Notification_YouNonOwnerMonument {
get;
set;
}
[JsonProperty(En ? "You have {0} seconds left to return to the monument area and retain monument owner status." : "У вас осталось {0} сек.чтобы вернуться в зону монумента и не потерять статус владельца")]
public bool Notification_AlertTimeOutsideZone2 {
get;
set;
}
[JsonProperty(En ? "You have {0} seconds left before losing the monument owner status and being kicked from the area." : "У вас осталось {0} сек.до потери статуса владельца монумента.По окончанию, вы будете выгнаны из зоны.")]
public bool Notification_AlertTimeInsideZone {
get;
set;
}
[JsonProperty(En ? "You have entered the monument area.Fulfill all of these conditions to become the owner:" : "Вы вошли в зону монумента.Выполните эти условия, чтобы стать владельцем:")]
public bool Notification_EnteringZone1 {
get;
set;
}
[JsonProperty(En ? "You have entered the monument area.Fulfill one of these conditions to become the owner:" : "Вы вошли в зону монумента.Выполните одно из этих условия, чтобы стать владельцем:")]
public bool Notification_EnteringZone2 {
get;
set;
}
[JsonProperty(En ? " - You must be in the monument area for {0} seconds." : " - Вы должны находится в зоне монумента {0} сек.")]
public bool Notification_RuleTimeToGetZone {
get;
set;
}
[JsonProperty(En ? " - You must deal {0} damage to NPCs or Bradley." : " - Вы должны нанести {0} урона по NPC или Bradley.")]
public bool Notification_RuleDamage {
get;
set;
}
[JsonProperty(En ? " - You must open at least one crate." : " - Вы должны открыть хотя бы один ящик.")]
public bool Notification_RuleOpenCrate {
get;
set;
}
[JsonProperty(En ? " - You must open at least one keycard security door." : " - Вы должны открыть хотя бы одну дверь ключ-картой.")]
public bool Notification_RuleOpenDoor {
get;
set;
}
[JsonProperty(En ? " - You must start a quarry." : " - Вы должны запустить карьер.")]
public bool Notification_RuleStartQuarry {
get;
set;
}
[JsonProperty(En ? " - You must run Giant Excavator." : " - Вы должны запустить экскаватор.")]
public bool Notification_RuleStartExcavator {
get;
set;
}
[JsonProperty(En ? "You have left the monument bounds, in order to retain owner status, return to the monument area within {0} seconds." : "Вы вышли из зоны монумента.Чтобы не потерять статус владельца вам необходимо вернуться в зону монумента в течении {0} сек.")]
public bool Notification_AlertTimeOutsideZone1 {
get;
set;
}
[JsonProperty(En ? "You cannot hack the crate." : "Вы не можете начать взламывать ящик.")]
public bool Notification_NoHackCrateEvent {
get;
set;
}
[JsonProperty(En ? "You cannot damage NPCs." : "Вы не можете наносить урон по NPC.")]
public bool Notification_NoDamageScientist {
get;
set;
}
[JsonProperty(En ? "You cannot damage Bradley." : "Вы не можете наносить урон по Bradley.")]
public bool Notification_NoDamageTank {
get;
set;
}
[JsonProperty(En ? "You cannot damage barrel." : "Вы не можете наносить урон по бочке.")]
public bool Notification_NoDamageBarrel {
get;
set;
}
[JsonProperty(En ? "You cannot damage target." : "Вы не можете наносить урон по цели.")]
public bool Notification_NoDamageTarget {
get;
set;
}
[JsonProperty(En ? "You cannot loot this." : "Вы не можете это залутать.")]
public bool Notification_CanNotLoot {
get;
set;
}
[JsonProperty(En ? "You cannot open this." : "Вы не можете это открыть.")]
public bool Notification_CanNotOpen {
get;
set;
}
[JsonProperty(En ? "You cannot enter the monument zone." : "Вы не можете зайти в зону монумента.")]
public bool Notification_NoEnterMonument {
get;
set;
}
[JsonProperty(En ? "You cannot change the type of resource being mined." : "Вы не можете изменить тип добываемого ресурса.")]
public bool Notification_CanNotResourceSet {
get;
set;
}
[JsonProperty(En ? "Your cooldown to become a monument owner is {0} seconds." : "Ваш кулдаун на получение статуса владельца монумента на этом РТ составляет: {0} сек.")]
public bool Notification_EnteringZone3 {
get;
set;
}
[JsonProperty(En ? "You are already the owner of another monument.You can only own one monument at a time." : "Вы уже являетесь владельцем другого монумента.Одновременно можно быть владельцем только 1 монумента.")]
public bool Notification_NoEnterAnotherOwner {
get;
set;
}
}
public class PluginConfig {
[JsonProperty(En ? "Zone dimmer (0 - remove the dimmer)" : "Затемнение зоны (0 - убрать затемнение)")]
public int Darkening {
get;
set;
}
[JsonProperty(En ? "GUI text color for the Monument Owner" : "Цвет текста гуи для владельца монумента")]
public string ColorTextForOwnerPanel {
get;
set;
}
[JsonProperty(En ? "GUI text color if not monument owner" : "Цвет текста гуи для не владельца монумента")]
public string ColorTextForNoOwnerPanel {
get;
set;
}
[JsonProperty(En ? "Are administrator able to participate? [true/false]" : "Будут ли правила зоны распространяться на администратора? (Сможет ли он участвовать) [true/false]")]
public bool AdminEntry {
get;
set;
}
[JsonProperty(En ? "Damage ratios (per NPC) to calculate becoming owner of the monument (Not applicable for \"BossMonster\")" : "Коэффициенты ущерба (по NPC) для расчета, чтобы стать владельцем монумента (Не применяется для \"BossMonster\")")]
public float ScaleDamageNPC {
get;
set;
}
[JsonProperty(En ? "Damage ratios (by Bradley) to calculate becoming owner of the monument" : "Коэффициенты ущерба (по Bradley) для расчета, чтобы стать владельцем монумента")]
public float ScaleDamageBradley {
get;
set;
}
[JsonProperty(En ? "Prevent a player from entering an monument area if they are the owner of another monument? [true/false]" : "Запрещать игроку входить внутрь зоны монумента, если он является владельцем другого монумента? [true/false]")]
public bool NoEnterAnotherOwner {
get;
set;
}
[JsonProperty(En ? "Prevent a player from entering an monument area if he has a cooldown?" : "Запрещать игроку входить внутрь зоны монумента, если у него есть кулдаун? [true/false]")]
public bool NoEnterPlayerWithCooldown {
get;
set;
}
[JsonProperty(En ? "Prevent a player from dealing damage to a target if he is outside the zone and the target is inside the zone? The parameter will be taken into account only when the monument has a neutral status." : "Запрещать игроку наносить урон по цели, если он находится за пределами зоны, а цель внутри зоны? Параметр будет учитываться только тогда, когда монумент имеет нейтральный статус.[true/false]")]
public bool NoDamageOutsideZone {
get;
set;
}
[JsonProperty(En ? "Should the player be allowed to become the owner of another monument if he has fulfilled all the rules? (In this case, the owner's status on the previous monument will be lost for him or his teammate)" : "Следует ли разрешить игроку стать владельцем другого монумента, если он выполнил все правила? (При этом статус владельца на предыдущем монументе будет утерян для него или тимейта)")]
public bool CanPlayerChangeMonument {
get;
set;
}
[JsonProperty(En ? "Can the player loot his backpack if he is in the locked monument zone" : "Может ли игрок лутать свой рюкзак, если он находится в зоне занятого монумента")]
public bool LootPlayerBackpack {
get;
set;
}
[JsonProperty(En ? "Chat notifications" : "Уведомления в чате")]
public NotificationsConfig Notifications {
get;
set;
}
[JsonProperty(En ? "Settings for plugin \"BossMonster\"" : "Настройки для плагина \"BossMonster\"")]
public BossMonsterConfig BossMonster {
get;
set;
}
[JsonProperty(En ? "Configuration Version" : "Версия конфигурации")]
public VersionNumber PluginVersion {
get;
set;
}
public static PluginConfig DefaultConfig() {
return new PluginConfig() {
Darkening = 2, ColorTextForOwnerPanel = "#8cc83c", ColorTextForNoOwnerPanel = "#cd4632", AdminEntry = false, ScaleDamageNPC = 1.0f, ScaleDamageBradley = 1.0f, NoEnterAnotherOwner = false, CanPlayerChangeMonument = true, NoDamageOutsideZone = true, NoEnterPlayerWithCooldown = true, LootPlayerBackpack = true, Notifications = new NotificationsConfig() {
Notification_YouOwnerMonument = true, Notification_YouNonOwnerMonument = true, Notification_AlertTimeOutsideZone2 = true, Notification_AlertTimeInsideZone = true, Notification_EnteringZone1 = true, Notification_EnteringZone2 = true, Notification_RuleTimeToGetZone = true, Notification_RuleDamage = true, Notification_RuleOpenCrate = true, Notification_RuleOpenDoor = true, Notification_AlertTimeOutsideZone1 = true, Notification_NoHackCrateEvent = true, Notification_NoDamageScientist = true, Notification_NoDamageTank = true, Notification_NoDamageBarrel = true, Notification_CanNotLoot = true, Notification_NoEnterMonument = true, Notification_EnteringZone3 = true, Notification_NoEnterAnotherOwner = true, Notification_RuleStartQuarry = true, Notification_RuleStartExcavator = true, Notification_CanNotResourceSet = true, Notification_CanNotOpen = true, Notification_NoDamageTarget = true
}
, BossMonster = new BossMonsterConfig() {
StartKillingBoss = true, Damage = 300.0f, ScaleDamageBoss = 1.0f
}
, PluginVersion = new VersionNumber()
}
;
}
}
#endregion Config
#region Lang
protected override void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<string, string> {
["YouOwnerMonument"]
= "You have <color=#738d43>become</color> the owner of this monument for <color=#55aaff>{0} sec.</color>!", ["OwnerMonumentForAllPlayers"] = "Player <color=#738d43>{0}</color> became the owner of the <color=#738d43>{1} [{2}]</color> for <color=#55aaff>{3} sec.</color>!", ["NoOwnerMonumentForAllPlayers"] = "Player <color=#738d43>{0}</color> stopped being the owner of the <color=#738d43>{1} [{2}]</color>.Monument is <color=#55aaff>not busy</color>!", ["YouOwnerMonumentGUI"] = "You are the owner of monument.Any actions are allowed", ["YouNonOwnerMonument"] = "You have <color=#ce3f27>lost</color> the status of monument owner!", ["YouNonOwnerMonumentGUI"] = "You are not the owner of monument.Some actions are limited", ["AlertTimeOutsideZone2"] = "You have <color=#55aaff>{0} sec.</color> left to return to the monument zone and not lose owner status", ["AlertTimeInsideZone"] = "You have <color=#55aaff>{0} sec.</color> left before losing the status of monument owner.After that, you will be teleported from the zone.", ["AlertTimeOutsideZone1"] = "You have <color=#ce3f27>left</color> the monument zone.To avoid losing the owner status, you need to return to the monument zone within <color=#55aaff>{0} sec.</color>.", ["EnteringZone1"] = "You have entered the <color=#738d43>monument</color> zone.Fulfill these <color=#55aaff>conditions</color> to become the owner:", ["EnteringZone2"] = "You have entered the <color=#738d43>monument</color> zone.Fulfill one of these <color=#55aaff>conditions</color> to become the owner:", ["EnteringZone3"] = "Your cooldown for obtaining the monument owner status in this event is: <color=#55aaff>{0} sec.</color>", ["RuleTimeToGetZone"] = " - You <color=#738d43>must</color> stay in the monument zone for <color=#55aaff>{0} sec.</color>.", ["RuleDamage"] = " - You <color=#738d43>must</color> deal <color=#55aaff>{0} damage</color> to NPCs or Bradley.", ["RuleOpenCrate"] = " - You <color=#738d43>must</color> open at least <color=#55aaff>one crate</color>.", ["NoHackCrateMonument"] = "You <color=#ce3f27>cannot</color> start hacking the crate.", ["NoDamageScientist"] = "You <color=#ce3f27>cannot</color> deal damage to <color=#55aaff>NPCs</color>.", ["NoDamageTank"] = "You <color=#ce3f27>cannot</color> deal damage to <color=#55aaff>Bradley</color>.", ["NoDamageBarrel"] = "You <color=#ce3f27>cannot</color> deal damage to <color=#55aaff>barrel</color>.", ["NoDamageTarget"] = "You <color=#ce3f27>cannot</color> deal damage to <color=#55aaff>target</color> outside zone.", ["CanNotLoot"] = "You <color=#ce3f27>cannot</color> loot this.", ["CanNotOpen"] = "You <color=#ce3f27>cannot</color> open this.", ["NoEnterMonument"] = "You <color=#ce3f27>cannot</color> enter the monument zone.", ["CanNotResourceSet"] = "You <color=#ce3f27>cannot</color> change the type of harvested resource.", ["RuleOpenDoor"] = " - You <color=#738d43>must</color> open at least one door with a <color=#55aaff>keycard</color>.", ["RuleStartQuarry"] = " - You <color=#738d43>must</color> start the <color=#55aaff>quarry</color>.", ["RuleStartExcavator"] = " - You <color=#738d43>must</color> start the <color=#55aaff>excavator</color>.", ["YouDontHaveCooldown"] = "You have <color=#ce3f27>no</color> cooldown on monuments.", ["YouHaveCooldown"] = "Your <color=#ce3f27>cooldown</color>: {0}", ["NoEnterAnotherOwner"] = "You or your teammate are already the <color=#738d43>owner</color> of another monument.You can only be the owner of 1 monument at a time."
}
, this);
lang.RegisterMessages(new Dictionary<string, string> {
["YouOwnerMonument"]
= "Вы <color=#738d43>стали</color> владельцем монумента на <color=#55aaff>{0} сек.</color>!", ["OwnerMonumentForAllPlayers"] = "Игрок <color=#738d43>{0}</color> стал владельцем <color=#738d43>{1} [{2}]</color> на <color=#55aaff>{3} sec.</color>!", ["NoOwnerMonumentForAllPlayers"] = "Игрок <color=#738d43>{0}</color> перестал быть владельцем <color=#738d43>{1} [{2}]</color>.Монумент <color=#55aaff>свободен</color>!", ["YouOwnerMonumentGUI"] = "Вы являетесь владельцем РТ.Любые действия разрешены", ["YouNonOwnerMonument"] = "Вы <color=#ce3f27>утратили</color> статус владельца монумента!", ["YouNonOwnerMonumentGUI"] = "Вы не являетесь владельцем РТ.Некоторые действия ограничены", ["AlertTimeOutsideZone2"] = "У вас осталось <color=#55aaff>{0} сек.</color> чтобы вернуться в зону монумента и не потерять статус владельца", ["AlertTimeInsideZone"] = "У вас осталось <color=#55aaff>{0} сек.</color> до потери статуса владельца монумента.По окончанию, вы будете выгнаны из зоны.", ["AlertTimeOutsideZone1"] = "Вы <color=#ce3f27>вышли</color> из зоны монумента.Чтобы не потерять статус владельца вам необходимо вернуться в зону монумента в течении <color=#55aaff>{0} сек.</color>", ["EnteringZone1"] = "Вы вошли в <color=#738d43>зону</color> монумента.Выполните эти <color=#55aaff>условия</color>, чтобы стать владельцем:", ["EnteringZone2"] = "Вы вошли в <color=#738d43>зону</color> монумента.Выполните одно из этих <color=#55aaff>условия</color>, чтобы стать владельцем:", ["EnteringZone3"] = "Ваш кулдаун на получение статуса владельца монумента на этом РТ составляет: <color=#55aaff>{0} сек.</color>", ["RuleTimeToGetZone"] = " - Вы <color=#738d43>должны</color> находится в зоне монумента <color=#55aaff>{0} сек.</color>.", ["RuleDamage"] = " - Вы <color=#738d43>должны</color> нанести <color=#55aaff>{0} урона</color> по NPC или Bradley.", ["RuleOpenCrate"] = " - Вы <color=#738d43>должны</color> открыть хотя бы <color=#55aaff>один ящик</color>.", ["NoHackCrateMonument"] = "Вы <color=#ce3f27>не можете</color> начать взламывать ящик.", ["NoDamageScientist"] = "Вы <color=#ce3f27>не можете</color> наносить урон по <color=#55aaff>NPC</color>.", ["NoDamageTank"] = "Вы <color=#ce3f27>не можете</color> наносить урон по <color=#55aaff>Bradley</color>.", ["NoDamageBarrel"] = "Вы <color=#ce3f27>не можете</color> наносить урон по <color=#55aaff>бочке</color>.", ["NoDamageTarget"] = "Вы <color=#ce3f27>не можете</color> наносить урон по <color=#55aaff>цели</color> вне зоны.", ["CanNotLoot"] = "Вы <color=#ce3f27>не можете</color> это залутать.", ["CanNotOpen"] = "Вы <color=#ce3f27>не можете</color> это открыть.", ["NoEnterMonument"] = "Вы <color=#ce3f27>не можете</color>зайти в зону монумента.", ["CanNotResourceSet"] = "Вы <color=#ce3f27>не можете</color> изменить тип добываемого ресурса.", ["RuleOpenDoor"] = " - Вы <color=#738d43>должны</color> открыть хотя бы одну дверь <color=#55aaff>ключ-картой</color>.", ["RuleStartQuarry"] = " - Вы <color=#738d43>должны</color> запустить <color=#55aaff>карьер</color>.", ["RuleStartExcavator"] = " - Вы <color=#738d43>должны</color> запустить <color=#55aaff>экскаватор</color>.", ["YouDontHaveCooldown"] = "У вас <color=#ce3f27>нет</color> кулдауна на монументах.", ["YouHaveCooldown"] = "Ваши <color=#ce3f27>кулдауны</color>: {0}", ["NoEnterAnotherOwner"] = "Вы или ваш тиммейт уже <color=#738d43>являетесь</color> владельцем другого монумента.Одновременно можно быть владельцем только 1 монумента."
}
, this, "ru");
}
private string GetMessage(string langKey, string userID) => lang.GetMessage(langKey, _here, userID);
private string GetMessage(string langKey, string userID, params object[] args) => (args.Length == 0) ? GetMessage(langKey, userID) : string.Format(GetMessage(langKey, userID), args);
#endregion Lang
#region GUI
internal string ConvertHexToRGBA(string hexColor) {
Color color = new Color();
if (ColorUtility.TryParseHtmlString(hexColor, out color)) {
float red = color.r;
float green = color.g;
float blue = color.b;
float alpha = 1f;
string rgbaString = string.Format("{0} {1} {2} {3}", red, green, blue, alpha);
return rgbaString;
}
return null;
}
void GUI(BasePlayer player, string message) {
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiPanel {
Image = {
Color = "0 0 0 0"
}
, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, CursorEnabled = false,
}
, "Under", "MainInvisPanel");
if (message == "Owner") {
container.Add(new CuiElement {
Name = "TopBarBackground", Parent = "MainInvisPanel", Components = {
new CuiImageComponent {
Color = "0 0 0 0.8"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.94", AnchorMax = "0.5 0.94", OffsetMin = "-200 -10", OffsetMax = "200 10"
}
}
}
);
container.Add(new CuiElement {
Name = "TopBarText", Parent = "TopBarBackground", Components = {
new CuiTextComponent() {
Color = ConvertHexToRGBA(_config.ColorTextForOwnerPanel), Text = GetMessage("YouOwnerMonumentGUI", player.UserIDString), Align = TextAnchor.MiddleCenter, FontSize = 15
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
}
if (message == "NoOwner") {
container.Add(new CuiElement {
Name = "TopBarBackground", Parent = "MainInvisPanel", Components = {
new CuiImageComponent {
Color = "0 0 0 0.8"
}
, new CuiRectTransformComponent {
AnchorMin = "0.5 0.94", AnchorMax = "0.5 0.94", OffsetMin = "-240 -10", OffsetMax = "240 10"
}
}
}
);
container.Add(new CuiElement {
Name = "TopBarText", Parent = "TopBarBackground", Components = {
new CuiTextComponent() {
Color = ConvertHexToRGBA(_config.ColorTextForNoOwnerPanel), Text = GetMessage("YouNonOwnerMonumentGUI", player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FontSize = 15
}
, new CuiRectTransformComponent {
AnchorMin = "0 0", AnchorMax = "1 1"
}
}
}
);
}
CuiHelper.AddUi(player, container);
}
internal void DestroyGUI(BasePlayer player = null, HashSet<BasePlayer> InsidePlayers = null) {
if (player != null) CuiHelper.DestroyUi(player, "MainInvisPanel");
if (InsidePlayers != null) {
foreach (BasePlayer locPlayer in InsidePlayers) {
CuiHelper.DestroyUi(locPlayer, "MainInvisPanel");
}
}
}
internal void CreateGUI(ulong Owner, BasePlayer player = null, HashSet<BasePlayer> InsidePlayers = null) {
if (player != null) {
DestroyGUI(player : player);
if (IsTeam(player, Owner)) GUI(player, "Owner");
if (!IsTeam(player, Owner)) GUI(player, "NoOwner");
}
if (InsidePlayers != null) {
DestroyGUI(InsidePlayers : InsidePlayers);
foreach (BasePlayer locPlayer in InsidePlayers) {
if (IsTeam(locPlayer, Owner)) GUI(locPlayer, "Owner");
if (!IsTeam(locPlayer, Owner)) GUI(locPlayer, "NoOwner");
}
}
}
#endregion GUI
#region Data System
private void WriteData() {
DetermineRemainCooldown();
Interface.Oxide.DataFileSystem.WriteObject("MM_Data/MonumentOwner/CooldownPlayers", _playersData);
}
private void LoadFiles() {
_playersData = Interface.Oxide.DataFileSystem.ReadObject<HashSet<PlayerData>>("MM_Data/MonumentOwner/CooldownPlayers");
foreach (PlayerData p in _playersData) {
if (p.lastTimeForMonuments == null) {
_oldPlayersData = new HashSet<OldPlayerData>();
_oldPlayersData = Interface.Oxide.DataFileSystem.ReadObject<HashSet<OldPlayerData>>("MM_Data/MonumentOwner/CooldownPlayers");
_playersData.Clear();
break;
}
}
ConvertValuesForDateTime();
}
#endregion Data System
#region Oxide Hooks
private void OnServerInitialized() {
if (BossMonster != null) bosses = (HashSet<ScientistNPC>)BossMonster.Call("GetAllBosses");
if (bosses == null) bosses = new HashSet<ScientistNPC>();
LoadMonumentSettings();
LoadEventSettings();
LoadCustomMonumentSettings();
UpdateAllDataFiles();
_playersData = new HashSet<PlayerData>();
ListAllMonumentsOnTheMap();
ListAllCustomMonumentsOnTheMap();
foreach (CargoShip cargo in BaseNetworkable.serverEntities.OfType<CargoShip>()) OnEntitySpawned(cargo);
LoadFiles();
_corountine = ServerMgr.Instance.StartCoroutine(TimerCanTimeOwner());
Subscribe("OnEntitySpawned");
Subscribe("OnEntityKill");
}
void OnEntityKill(CargoShip cargo) {
ControllerMonument zone = _zones.FirstOrDefault(x => x.Name == "Cargo" && cargo.net.ID.Value.ToString() == x.ID);
if (zone != null) {
foreach (BasePlayer playerWithGUI in zone.InsidePlayers) {
DestroyGUI(player : playerWithGUI);
}
if (zone.Owner != 0) zone.DeleteOwnerInZone();
_zones.Remove(zone);
}
}
private static MonumentOwner _here;
private void Init() {
_here = this;
Unsubscribe("OnEntitySpawned");
Unsubscribe("OnEntityKill");
}
private void Unload() {
WriteData();
if (_corountine != null) ServerMgr.Instance.StopCoroutine(_corountine);
foreach (ulong playerUserID in AllInsidePlayers.Keys) {
BasePlayer playerWithGUI = BasePlayer.FindByID(playerUserID);
DestroyGUI(player : playerWithGUI);
}
foreach (ControllerMonument i in _zones) {
UnityEngine.Object.Destroy(i.gameObject);
}
_here = null;
}
void OnEntitySpawned(CargoShip cargo) {
if (cargo == null || cargo.net == null) {
PrintError("Cargo was tagged with an incorrect NetID.The creation of a zone for it has been discontinued.Contact the plugin developer [Monument Owner] with this problem");
return;
}
foreach (MonumentInfo harborMonument in AllHarborsOnMap) {
if (IsObjectInSphere(harborMonument.transform.position, 250.0f, cargo.transform.position)) return;
}
ControllerMonument zoneObject = new GameObject().AddComponent<ControllerMonument>();
ListOfMonuments settings = _monumentSettings["Cargo"];
if (settings != null && settings.Enabled) CreateZoneForCargo(settings, cargo, zoneObject);
}
object OnPlayerDeath(BasePlayer player, HitInfo info) {
if (AllInsidePlayers.ContainsKey(player.userID)) {
string id = AllInsidePlayers[player.userID];
if (id != null) {
ControllerMonument zone = _zones.FirstOrDefault(x => x.ID == id);
if (zone != null) {
zone.OnExitPlayer(player);
}
}
}
return null;
}
object OnCardSwipe(CardReader cardReader, Keycard card, BasePlayer player) {
if (IgnoreAdmin(player)) return null;
if (card.accessLevel == cardReader.accessLevel) {
ControllerMonument zone = _zones.FirstOrDefault(x => IsObjectInSphere(x.transform.position, x.Radius, cardReader.transform.position));
if (zone != null) {
zone.IfPlayerCantBeOwner(player);
if (zone.Owner == 0) {
if (zone.DicTermsOwner.ContainsKey(player.userID)) {
if (!PlayersWhoOpenedDoor.Contains(player.userID) && zone.monConfig.RulesBecomeOwner.OpenDoor) {
zone.DicTermsOwner[player.userID]++;
PlayersWhoOpenedDoor.Add(player.userID);
zone.CanPlayerBecomeOwner(player);
}
return null;
}
}
if (zone.Owner != 0) {
if (player.userID == zone.Owner || IsTeam(player, zone.Owner)) {
return null;
}
}
else return true;
}
}
return null;
}
internal bool IsObjectInSphere(Vector3 sphereCenter, float sphereRadius, Vector3 objectPosition) => Vector3.Distance(sphereCenter, objectPosition) <= sphereRadius;
void OnPlayerDisconnected(BasePlayer player, string reason) {
if (AllInsidePlayers.ContainsKey(player.userID)) {
string id = AllInsidePlayers[player.userID];
if (id != null) {
ControllerMonument zone = _zones.FirstOrDefault(x => x.ID == id);
if (zone != null) {
zone.OnExitPlayer(player);
}
}
}
}
private void OnEntityKill(ScientistNPC entity) {
if (!entity.IsExists()) return;
OnBossKill(entity);
ControllerMonument controllerMon = _zones.FirstOrDefault(x => x.ScientistList.Contains(entity));
if (controllerMon != null) {
controllerMon.ScientistList.Remove(entity);
}
}
#endregion Oxide Hooks
#region Monuments
private string Quarry {
get;
set;
}
= "assets/bundled/prefabs/static/miningquarry_static.prefab";
private string Excavator {
get;
set;
}
= "assets/bundled/prefabs/autospawn/monument/large/excavator_1.prefab";
private string Harbor_1 {
get;
set;
}
= "assets/bundled/prefabs/autospawn/monument/harbor/harbor_1.prefab";
private string Harbor_2 {
get;
set;
}
= "assets/bundled/prefabs/autospawn/monument/harbor/harbor_2.prefab";
private HashSet<string> QuarryList {
get;
set;
}
= new HashSet<string>() {
"assets/bundled/prefabs/autospawn/monument/small/mining_quarry_a.prefab", "assets/bundled/prefabs/autospawn/monument/small/mining_quarry_b.prefab", "assets/bundled/prefabs/autospawn/monument/small/mining_quarry_c.prefab"
}
;
private Dictionary<string, Vector3> LocalСoordZoneForMonument {
get;
set;
}
= new Dictionary<string, Vector3>() {
["assets/bundled/prefabs/autospawn/monument/military_bases/desert_military_base_c.prefab"]
= new Vector3(7.5f, 0f, 19f), ["assets/bundled/prefabs/autospawn/monument/military_bases/desert_military_base_b.prefab"] = new Vector3(0f, 0f, 6f), ["assets/bundled/prefabs/autospawn/monument/military_bases/desert_military_base_d.prefab"] = new Vector3(0f, 0f, -1.7f), ["assets/bundled/prefabs/autospawn/monument/large/water_treatment_plant_1.prefab"] = new Vector3(0f, 0f, -30f), ["assets/bundled/prefabs/autospawn/monument/large/airfield_1.prefab"] = new Vector3(0f, 0f, -26.673f), ["assets/bundled/prefabs/autospawn/monument/large/excavator_1.prefab"] = new Vector3(23.133f, 0f, -20.633f), ["assets/bundled/prefabs/autospawn/monument/large/powerplant_1.prefab"] = new Vector3(-23.401f, 0f, 0f), ["assets/bundled/prefabs/autospawn/monument/medium/junkyard_1.prefab"] = new Vector3(-12.407f, 0f, 9.618f), ["assets/bundled/prefabs/autospawn/monument/medium/radtown_small_3.prefab"] = new Vector3(0f, 0f, -17.107f), ["OilrigAI"] = new Vector3(14.847f, 0f, -12.318f), ["assets/bundled/prefabs/autospawn/monument/roadside/gas_station_1.prefab"] = new Vector3(0f, 0f, 12.687f), ["assets/bundled/prefabs/autospawn/monument/roadside/warehouse.prefab"] = new Vector3(0f, 0f, -9.360f)
}
;
private Dictionary<string, string> EntrancesUnderwaterLab {
get;
set;
}
= new Dictionary<string, string>() {
["assets/bundled/prefabs/autospawn/monument/underwater_lab/underwater_lab_a.prefab"]
= "moonpool_1200x1500_1way", ["assets/bundled/prefabs/autospawn/monument/underwater_lab/underwater_lab_b.prefab"] = "moonpool_1200x1500_2way", ["assets/bundled/prefabs/autospawn/monument/underwater_lab/underwater_lab_c.prefab"] = "moonpool_1200x1500_3way", ["assets/bundled/prefabs/autospawn/monument/underwater_lab/underwater_lab_d.prefab"] = "moonpool_1200x1800_ladder",
}
;
private HashSet<string> ExcludedMonuments {
get;
set;
}
= new HashSet<string>() {
"assets/bundled/prefabs/autospawn/monument/fishing_village/fishing_village_a.prefab", "assets/bundled/prefabs/autospawn/monument/fishing_village/fishing_village_b.prefab", "assets/bundled/prefabs/autospawn/monument/fishing_village/fishing_village_c.prefab", "assets/bundled/prefabs/autospawn/monument/small/stables_a.prefab", "assets/bundled/prefabs/autospawn/monument/small/stables_b.prefab", "assets/bundled/prefabs/autospawn/monument/medium/compound.prefab", "assets/bundled/prefabs/autospawn/monument/medium/bandit_town.prefab", "Water Well", "Abandoned Cabins", "Wild Swamp", "Ice Lake", "Train Tunnel", "Substation", "Mountain", ""
}
;
private HashSet<MonumentInfo> AllHarborsOnMap {
get;
set;
}
= new HashSet<MonumentInfo>();
private HashSet<DungeonBaseInfo> labsThatAlreadyHaveZone {
get;
set;
}
= new HashSet<DungeonBaseInfo>();
private static string GetNameMonument(MonumentInfo monument) {
if (monument.name.Contains("harbor_1")) return "Small " + monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("harbor_2")) return "Large " + monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("desert_military_base_a")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("desert_military_base_b")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("desert_military_base_c")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("desert_military_base_d")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("underwater_lab_a")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("underwater_lab_b")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("underwater_lab_c")) return monument.displayPhrase.english.Replace("\n", string.Empty);
if (monument.name.Contains("underwater_lab_d")) return m
// ... [Code preview truncated due to length. Full source in attached file] ...