C#:
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("NoEscape", "https://topplugin.ru / https://discord.com/invite/5DPTsRmd3G", "1.0.3")]
class NoEscape : RustPlugin
{
class Raid
{
public HashSet<ulong> owners;
public HashSet<ulong> raiders;
public Vector3 pos;
public Raid(List<ulong> owners, List<ulong> raiders)
{
this.owners = new HashSet<ulong>(owners);
this.raiders = new HashSet<ulong>(raiders);
}
}
class DamageTimer
{
public List<ulong> owners;
public int seconds;
public DamageTimer(List<ulong> owners, int seconds)
{
this.owners = owners;
this.seconds = seconds;
}
}
static DynamicConfigFile config;
bool EnabledBuildingPrivilage = false;
float radius = 50f;
int blockTime = 120;
int blockAttackTime = 10;
bool blockAttack = false;
int ownerBlockTime = 120;
bool useDamageScale = false;
bool blockOwner = true;
bool friedsAPI = false;
bool canBuild = true;
bool canRemove = true;
bool canRemoveStan = true;
bool canKits = true;
bool canRepair = true;
bool canUpgrade = true;
bool canTeleport = true;
bool canTrade = true;
bool canRec = true;
bool CanBuilt = true;
bool CanBuiltNoEscape = true;
bool LadderBuilding = false;
float offlineScale = 0.5f;
public List<string> WriteList = new List<string>();
private void LoadDefaultConfig()
{
GetConfig("Основное", "Размер радиуса блокировки", ref radius);
GetConfig("Основное", "Включить отключение блокировки при разрушении шкафа (BuildingPrivilage), если функция будет включена игроку не будет давать блокировку если разрушенный объект будет вне билдинг зоны",
ref EnabledBuildingPrivilage);
GetConfig("Основное", "Время блокировки атакующего", ref blockTime);
GetConfig("Основное", "Блокировать игроков при нанесение урона (Блокировка инициатора и жертвы)", ref blockAttack);
GetConfig("Основное", "Время блокировки при нанесение урона по игрокам (Блокировка инициатора и жертвы)", ref blockAttackTime);
GetConfig("Основное", "Блокировать хозяина строения, если он не в радиусе блокировки", ref blockOwner);
GetConfig("Основное", "Время блокировки хозяина", ref ownerBlockTime);
GetConfig("Основное", "Запретить установку штурмовых лестниц в радиусе зоны чужого шкафа", ref CanBuilt);
GetConfig("Множитель", "Множитель урона если хозяина нет в сети (наносимый урон = урон*SCALE)", ref offlineScale);
GetConfig("Множитель", "Использовать множитель урона", ref useDamageScale);
GetConfig("Блокировка", "Блокировать строительство", ref canBuild);
var _WriteList = new List<object>() {"wall.external.high.stone", "barricade.metal"};
GetConfig("Блокировка", "Белый список предметов какие можно строить при рейдблоке", ref _WriteList);
WriteList = _WriteList.Select(p => p.ToString()).ToList();
GetConfig("Блокировка", "Блокировать удаление построек (CanRemove)", ref canRemove);
GetConfig("Блокировка", "Блокировать использование китов", ref canKits);
GetConfig("Блокировка", "Блокировать ремонт построек (стандартный)", ref canRepair);
GetConfig("Блокировка", "Блокировать улучшение построек (стандартное)", ref canUpgrade);
GetConfig("Блокировка", "Блокировать телепорты", ref canTeleport);
GetConfig("Блокировка", "Блокировать удаление построек (стандартное)", ref canRemoveStan);
GetConfig("Блокировка", "Блокировать обмен между игроками (Trade)", ref canTrade);
GetConfig("Блокировка", "Блокировать переработчик (Recycler)", ref canRec);
GetConfig("Блокировка", "Блокировать установку штурмовых лесниц в рейд блоке", ref LadderBuilding);
SaveConfig();
}
private void GetConfig<T>(string menu, string Key, ref T var)
{
if (Config[menu, Key] != null)
{
var = (T) Convert.ChangeType(Config[menu, Key], typeof(T));
}
Config[menu, Key] = var;
}
Dictionary<ulong, RaidBlock> timers = new Dictionary<ulong, RaidBlock>();
public class RaidBlock
{
public BuildingPrivlidge building;
public double Seconds;
public bool Attack;
}
Dictionary<BuildingPrivlidge, Raid> raids = new Dictionary<BuildingPrivlidge, Raid>();
List<DamageTimer> damageTimers = new List<DamageTimer>();
private Dictionary<BasePlayer, DateTime> CooldownsAttackDic = new Dictionary<BasePlayer, DateTime>();
private double CooldownAttack = 15f;
private string PERM_IGNORE = "noescape.ignore";
private string PERM_VK_NOTIFICATION = "noescape.vknotification";
void OnEntityBuilt(Planner plan, GameObject go)
{
if (go == null || plan == null) return;
if (!CanBuilt) return;
var player = plan.GetOwnerPlayer();
BaseEntity entity = go.ToBaseEntity();
var targetLocation = player.transform.position + (player.eyes.BodyForward() * 4f);
if (go.name == "assets/prefabs/building/ladder.wall.wood/ladder.wooden.wall.prefab" && player.IsBuildingBlocked(targetLocation, new Quaternion(0, 0, 0, 0), new Bounds(Vector3.zero, Vector3.zero)))
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
if (!LadderBuilding) return;
}
SendReply(player, Messages["BlockLadders"]);
NextTick(() => { entity.Kill(); });
}
}
void OnServerInitialized()
{
PermissionService.RegisterPermissions(this, new List<string>() {PERM_IGNORE, PERM_VK_NOTIFICATION});
LoadDefaultConfig();
lang.RegisterMessages(Messages, this, "en");
Messages = lang.GetMessages("en", this);
timer.Every(1f, NoEscapeTimerHandle);
timer.Every(1f, RaidZoneTimerHandle);
LoadData();
}
void OnEntityDeath(BaseCombatEntity entity, HitInfo info, Item item)
{
if (!(entity is BuildingBlock) && !(entity is Door) && !entity.ShortPrefabName.Contains("external.high.")) return;
var player = info?.InitiatorPlayer;
if (entity == null && info == null) return;
if (player == null) return;
if (player.userID == entity.OwnerID) return;
var block = entity as BuildingBlock;
if (block && block.grade <= 0) return;
if (EnabledBuildingPrivilage && entity?.GetBuildingPrivilege() == null || entity.GetBuildingPrivilege()?.buildingID == 0) return;
bool justCreated;
var raid = GetRaid(entity.GetNetworkPosition(), out justCreated, EnabledBuildingPrivilage ? entity?.GetBuildingPrivilege() : null);
if (PermissionService.HasPermission(player.userID, PERM_IGNORE)) return;
if (!timers.ContainsKey(player.userID))
{
if (blockOwner)
{
var p = BasePlayer.FindByID(entity.OwnerID);
SendReply(p, Messages["blockactive"], FormatTime(TimeSpan.FromSeconds(ownerBlockTime)));
SendReply(player, Messages["blockactiveAttacker"], FormatTime(TimeSpan.FromSeconds(ownerBlockTime)));
}
else
{
var p = BasePlayer.FindByID(entity.OwnerID);
SendReply(p, Messages["noblockowner"]);
SendReply(player, Messages["blockactiveAttacker"], FormatTime(TimeSpan.FromSeconds(ownerBlockTime)));
}
}
GetAroundPlayers(entity.GetNetworkPosition()).ForEach(p => BlockPlayer(p, EnabledBuildingPrivilage ? entity.GetBuildingPrivilege() : null, "raid"));
if (!raid.owners.Contains(entity.OwnerID))
{
var p = BasePlayer.FindByID(entity.OwnerID);
if (blockOwner)
{
raid.owners.Add(entity.OwnerID);
}
if (useDamageScale)
{
if (justCreated && p)
{
damageTimers.Add(new DamageTimer(raid.owners.ToList(), 3600));
}
}
}
foreach (var owner in GetOwnersByOwner(entity.OwnerID, entity.GetNetworkPosition())) raid.owners.Add(owner);
}
bool IsOnline(ulong id)
{
foreach (BasePlayer active in BasePlayer.activePlayerList)
{
if (active.userID == id) return true;
}
return false;
}
Raid GetRaid(Vector3 pos, out bool justCreated, BuildingPrivlidge building = null)
{
justCreated = false;
foreach (var raid in raids)
if (Vector3.Distance(raid.Value.pos, pos) < 50)
return raid.Value;
justCreated = true;
var ownerraid = new Raid(new List<ulong>(), new List<ulong>()) {pos = pos};
raids.Add(building == null ? new BuildingPrivlidge() : building, ownerraid);
return ownerraid;
}
void BlockPlayer(BasePlayer player, BuildingPrivlidge building = null, string mode = "", bool owner = false)
{
if (player.IsSleeping()) return;
if (player == null) return;
if (mode == "raid")
{
if (!owner || !timers.ContainsKey(player.userID))
{
var secs = owner ? ownerBlockTime : blockTime;
timers[player.userID] = new RaidBlock() {building = building, Seconds = secs, Attack = false};
SetCooldown(player, "raid", secs);
SaveData();
}
return;
}
if (mode == "attack")
{
var cooldown = GetCooldown(player, "raid");
if (cooldown != 0)
{
return;
}
if (!timers.ContainsKey(player.userID))
{
player.ChatMessage(string.Format(Messages[owner ? "ownerhome" : "blockattackactive"], FormatTime(TimeSpan.FromSeconds(blockAttackTime))));
}
if (!owner || !timers.ContainsKey(player.userID))
{
var secs = blockAttackTime;
timers[player.userID] = new RaidBlock() {building = null, Seconds = secs, Attack = building == null,};
SetCooldown(player, "attack", secs);
SaveData();
}
}
}
private string GetFormatTime(double seconds)
{
double minutes = Math.Floor((double) (seconds / 60));
seconds -= (int) (minutes * 60);
return string.Format("{0}:{1:00}", minutes, seconds);
}
public static string FormatTime(TimeSpan time)
{
string result = string.Empty;
if (time.Days != 0) result += $"{Format(time.Days, "дней", "дня", "день")} ";
if (time.Hours != 0) result += $"{Format(time.Hours, "часов", "часа", "час")} ";
if (time.Minutes != 0) result += $"{Format(time.Minutes, "минут", "минуты", "минута")} ";
if (time.Seconds != 0) result += $"{Format(time.Seconds, "секунд", "секунды", "секунда")} ";
return result;
}
private static string Format(int units, string form1, string form2, string form3)
{
var tmp = units % 10;
if (units >= 5 && units <= 20 || tmp >= 5 && tmp <= 9) return $"{units} {form1}";
if (tmp >= 2 && tmp <= 4) return $"{units} {form2}";
return $"{units} {form3}";
}
void Unload()
{
foreach (var player in BasePlayer.activePlayerList)
{
DestroyUITimer(player);
}
}
void OnPlayerConnected(BasePlayer player)
{
if (useDamageScale)
{
foreach (var raid in raids)
if (raid.Value.owners.Contains(player.userID) && raid.Value.owners.Count(p => BasePlayer.FindByID(p) != null) <= 1 && raid.Value.owners.Any(o => damageTimers.All(t => !t.owners.Contains(o))))
{
foreach (var raider in raid.Value.raiders) BasePlayer.FindByID(raider)?.ChatMessage(Messages["OwnerEnterOnline"]);
break;
}
}
}
private List<string> damageTypes;
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info, BaseCombatEntity victim)
{
try
{
var initiator = info?.InitiatorPlayer;
var victimBP = entity.ToPlayer();
if (entity == null) return;
if (initiator == null) return;
if (victimBP == null) return;
if (initiator == victimBP) return;
if (blockAttack)
{
if (entity is BasePlayer && info.Initiator is BasePlayer)
{
if (entity != null && victimBP != null)
{
BlockPlayer(initiator, null, "attack");
BlockPlayer(victimBP, null, "attack");
}
}
}
if (info.WeaponPrefab is BaseProjectile) return;
if (damageTimers.Any(p => p.owners.Contains(entity.OwnerID))) return;
if (!(entity is BuildingBlock) && !(entity is Door)) return;
if (entity.OwnerID == 0) return;
if (useDamageScale)
{
bool justCreated;
var raid = GetRaid(entity.GetNetworkPosition(), out justCreated, EnabledBuildingPrivilage ? entity.GetBuildingPrivilege() : null);
bool SendMessages = false;
SendMessages = false;
if (CooldownsAttackDic.ContainsKey(initiator))
{
double seconds = CooldownsAttackDic[initiator].Subtract(DateTime.Now).TotalSeconds;
if (seconds >= 0)
{
SendMessages = true;
}
}
bool sendRemoveOwnerMessage = false;
if (!BasePlayer.FindByID(entity.OwnerID))
{
info.damageTypes.ScaleAll(offlineScale);
damageTimers.Add(new DamageTimer(raid.owners.ToList(), 3600));
if (SendMessages == false)
{
SendReply(initiator, Messages["DamageNotOnlineOwner"]);
SendMessages = true;
}
CooldownsAttackDic[initiator] = DateTime.Now.AddSeconds(CooldownAttack);
}
if (justCreated && initiator && !sendRemoveOwnerMessage)
{
sendRemoveOwnerMessage = true;
justCreated = false;
}
}
}
catch (NullReferenceException)
{
}
}
object OnStructureUpgrade(BaseCombatEntity entity, BasePlayer player, BuildingGrade.Enum grade)
{
if (player == null) return null;
if (canUpgrade)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockupgrade"], seconds));
return false;
}
}
return null;
}
object OnStructureDemolish(BaseCombatEntity entity, BasePlayer player)
{
if (player == null) return null;
if (canRemoveStan)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockremove"], seconds));
return false;
}
}
return null;
}
object OnStructureRepair(BaseCombatEntity entity, BasePlayer player)
{
if (player == null) return null;
if (canRepair)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockrepair"], seconds));
return false;
}
}
return null;
}
object CanUpgrade(BasePlayer player)
{
if (player == null) return null;
if (canUpgrade)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockupgrade"], seconds));
return false;
}
}
return null;
}
readonly int cupboardMask = LayerMask.GetMask("Deployed");
object CanBuild(Planner planner, Construction prefab, Construction.Target target)
{
var player = planner.GetOwnerPlayer();
if (player == null) return null;
if (canBuild)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
if (prefab.fullName.Contains("Twigs")) return null;
if (!LadderBuilding && prefab.fullName.Contains("ladder.wooden")) return null;
if (WriteList.Contains(prefab.CreateConstruction(target).ShortPrefabName)) return null;
SendReply(player, string.Format(Messages["blockbuld"], seconds));
if (prefab.fullName.Contains("cupboard.tool"))
{
BuildingPrivlidge privilege = target.entity.GetBuildingPrivilege(target.entity.WorldSpaceBounds());
if (privilege != null) privilege.Kill();
}
return false;
}
}
return null;
}
object CanTeleport(BasePlayer player)
{
if (player == null) return null;
var cooldown = GetCooldown(player, "attack");
if (cooldown > 0 && !player.IsAdmin)
{
return false;
}
var seconds = ApiGetTime(player.userID);
return seconds > 0 ? string.Format(Messages["blocktp"], seconds) : null;
}
object CanTrade(BasePlayer player)
{
if (player == null) return null;
if (canTrade)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blocktrade"], seconds));
return false;
}
}
return null;
}
object canRedeemKit(BasePlayer player)
{
if (player == null) return null;
if (canKits)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockKits"], seconds));
return false;
}
}
return null;
}
object CanRecycleCommand(BasePlayer player)
{
if (player == null) return null;
if (canRec)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["blockrec"], seconds));
return false;
}
}
return null;
}
object CanRemove(BasePlayer player, BaseEntity entity)
{
if (player == null) return null;
if (canRemove)
{
var seconds = ApiGetTime(player.userID);
if (seconds > 0)
{
SendReply(player, string.Format(Messages["raidremove"], seconds));
return false;
}
}
return null;
}
private string TextReplace(string key, params KeyValuePair<string, string>[] replacements)
{
string message = key;
foreach (var replacement in replacements) message = message.Replace($"{{{replacement.Key}}}", replacement.Value);
return message;
}
void NoEscapeTimerHandle()
{
foreach (var uid in timers.Keys.ToList())
{
if (timers[uid].building == null && !timers[uid].Attack && EnabledBuildingPrivilage) timers[uid].Seconds = 0;
if (--timers[uid].Seconds <= 0)
{
bool cont = false;
foreach (var raid in raids)
if (raid.Value.owners.Contains(uid))
cont = true;
if (cont) continue;
timers.Remove(uid);
foreach (var player in BasePlayer.activePlayerList)
CuiHelper.DestroyUi(player, "noescape_main2");
BasePlayer.activePlayerList.ToList().Find(p => p.userID == uid)?.ChatMessage(Messages["blocksuccess"]);
}
else
{
DrawUITimer(BasePlayer.activePlayerList.ToList().Find(p => p.userID == uid));
}
}
for (int i = damageTimers.Count - 1; i >= 0; i--)
{
var rem = damageTimers[i];
if (--rem.seconds <= 0)
{
damageTimers.RemoveAt(i);
continue;
}
}
}
void RaidZoneTimerHandle()
{
List<BuildingPrivlidge> toRemove = new List<BuildingPrivlidge>();
foreach (var raid in raids)
{
foreach (var player in GetAroundPlayers(raid.Value.pos))
{
if (raid.Value.owners.Contains(player.userID))
{
BlockPlayer(player, raid.Key, "raid", true);
}
}
raid.Value.raiders.RemoveWhere(raider => !timers.ContainsKey(raider));
if (raid.Value.raiders.Count <= 0)
{
foreach (var owner in raid.Value.owners)
{
timers[owner] = new RaidBlock() {building = raid.Key, Seconds = ownerBlockTime, Attack = raid.Key == null};
var p = BasePlayer.FindByID(owner);
if (p) SetCooldown(p, "raid", ownerBlockTime);
SaveData();
}
toRemove.Add(raid.Key);
}
}
toRemove.ForEach(raid => raids.Remove(raid));
}
List<BasePlayer> GetAroundPlayers(Vector3 position)
{
var coliders = new List<BaseEntity>();
Vis.Entities(position, radius, coliders, Rust.Layers.Server.Players);
return coliders.OfType<BasePlayer>().ToList();
}
List<ulong> GetOwnersByOwner(ulong owner, Vector3 position, ulong pIayerid = 2281488)
{
var coliders = new List<BaseEntity>();
Vis.Entities(position, radius, coliders, Rust.Layers.Server.Deployed);
var codelocks = coliders.OfType<BoxStorage>().Select(s => s.GetSlot(BaseEntity.Slot.Lock)).OfType<CodeLock>().ToList();
var owners = new HashSet<ulong>();
var reply = 1567;
if (reply == 0)
{
}
foreach (var codelock in codelocks)
{
var whitelist = codelock.whitelistPlayers;
if (whitelist == null) continue;
if (!whitelist.Contains(owner)) continue;
foreach (var uid in whitelist)
if (uid != owner)
owners.Add(uid);
}
return owners.ToList();
}
void DrawUITimer(BasePlayer player)
{
if (player != null && timers.ContainsKey(player.userID))
{
CuiHelper.DestroyUi(player, "noescape_main2");
var container = new CuiElementContainer();
container.Add(new CuiPanel
{
CursorEnabled = false,
RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "82 -25", OffsetMax = "108 0" },
Image = { Color = "1 1 1 0.1" }
}, "Hud", "noescape_main2");
container.Add(new CuiElement
{
Parent = "noescape_main2",
Components =
{
new CuiImageComponent { Color = "1 1 1 0.8", Sprite = "assets/icons/explosion_sprite.png"},
new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "4 4", OffsetMax = "-4 -4" }
}
});
var amax = Convert.ToDouble((float) Math.Min(ApiGetTime(player.userID), blockTime) / blockTime);
container.Add(new CuiElement
{
Parent = "noescape_main2",
Components =
{
new CuiImageComponent { Color = "0.93 0.24 0.38 1" },
new CuiRectTransformComponent {AnchorMin = $"0 0", AnchorMax = $"{amax} 0.1", OffsetMax = "0 0"},
}
});
CuiHelper.AddUi(player, container);
}
}
void DestroyUITimer(BasePlayer player)
{
CuiHelper.DestroyUi(player, "noescape_main2");
}
DynamicConfigFile cooldownsFile = Interface.Oxide.DataFileSystem.GetFile("NoEscapeCooldown");
private class Cooldown
{
public ulong UserId;
public double Expired;
[JsonIgnore] public Action OnExpired;
}
private static Dictionary<string, List<Cooldown>> cooldowns;
internal static void Service()
{
var time = GrabCurrentTime();
List<string> toRemove = new List<string>();
foreach (var cd in cooldowns)
{
var keyCooldowns = cd.Value;
List<string> toRemoveCooldowns = new List<string>();
for (var i = keyCooldowns.Count - 1; i >= 0; i--)
{
var cooldown = keyCooldowns[i];
if (cooldown.Expired < time)
{
cooldown.OnExpired?.Invoke();
keyCooldowns.RemoveAt(i);
;
}
}
if (keyCooldowns.Count == 0) toRemove.Add(cd.Key);
}
toRemove.ForEach(p => cooldowns.Remove(p));
}
public static void SetCooldown(BasePlayer player, string key, int seconds, Action onExpired = null)
{
List<Cooldown> cooldownList;
if (!cooldowns.TryGetValue(key, out cooldownList)) cooldowns[key] = cooldownList = new List<Cooldown>();
cooldownList.Add(new Cooldown() {UserId = player.userID, Expired = GrabCurrentTime() + (double) seconds, OnExpired = onExpired});
}
public static int GetCooldown(BasePlayer player, string key)
{
List<Cooldown> source = new List<Cooldown>();
if (cooldowns.TryGetValue(key, out source))
{
Cooldown cooldown = source.FirstOrDefault<Cooldown>((Func<Cooldown, bool>) (p => (long) p.UserId == (long) player.userID));
if (cooldown != null) return (int) (cooldown.Expired - GrabCurrentTime());
}
return 0;
}
static double GrabCurrentTime() => DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
private Image raidhomeImage;
TimeSpan TimeLeft(DateTime time)
{
return DateTime.Now.Subtract(time);
}
double ApiGetTime(ulong player) => timers.ContainsKey(player) ? timers[player].Seconds : 0;
List<Vector3> ApiGetOwnerRaidZones(ulong uid)
{
return new List<Vector3>(raids.Where(p => p.Value.owners.Contains(uid)).Select(r => r.Value.pos));
}
bool IsRaidBlock(ulong id)
{
if (timers.ContainsKey(id)) return true;
return false;
}
void OnServerSave()
{
cooldownsFile.WriteObject(cooldowns);
}
void LoadData()
{
Interface.Oxide.DataFileSystem.WriteObject("NoEscapeCooldown", new Dictionary<string, FileInfo>());
cooldowns = cooldownsFile.ReadObject<Dictionary<string, List<Cooldown>>>() ?? new Dictionary<string, List<Cooldown>>();
}
void SaveData()
{
cooldownsFile.WriteObject(cooldowns);
}
Dictionary<string, string> Messages = new Dictionary<string, string>()
{
{"blocksuccess", "Блок деактивирован.Функции разблокированы"}, {"guitimertext", "<b>Блокировка:</b> Осталось {0}"}, {"noblockowner", "Ваше строение разрушено! Летите на защиту"},
{"blockactive", "Ваше строение разрушено, активирован рейд блок на <color=#ee3e61>{0}</color>\nНекоторые функции временно недоступны."},
{"blockactiveAttacker", "Вы уничтожили чужой объект, активирован рейд блок на <color=#ECBE13>{0}</color>\nНекоторые функции временно недоступны."},
{"blockattackactive", "Включен режим боя, активирован блок на {0}! Некоторые функции временно недоступны."}, {"blockrepair", "Вы не можете ремонтировать строения во время рейда, подождите {0} сек."},
{"blockremove", "Вы не можете удалить постройки во время рейда, подождите {0} сек."}, {"blockupgrade", "Вы не можете использовать автоулучшение построек во время рейда, подождите {0} сек."},
{"blockKits", "Вы не можете использовать киты во время рейда, подождите {0} сек."}, {"blockbuld", "Вы не можете строить во время рейда, подождите {0} сек."},
{"yourbuildingdestroy", "Вас, или дом Вашего соклана рейдят! Добавлена отметка на карту"}, {"yourbuildingdestroyOwner", "Внимание! Ваш дом рейдит игрок {1}! Добавлена отметка на карту"},
{"isClanMember", "Внимание! Данное строение пренадлежит Вашему соклановцу! Урон уменьшен"}, {"isFriendMember", "Внимание! Данное строение пренадлежит Вашему другу! Урон уменьшен"}, {"removerestrict", "Хозяев нет в сети! Ремув запрещён!"},
{"ownerhome", "Вы рядом со своим домом, который рейдят!\nРейдблок активирован на {0}!"}, {"raidremove", "Вы не можете удалять обьекты во время рейда, подождите {0} сек."},
{"blockrec", "Вы не можете использовать переработчик во время рейда, подождите {0} сек."}, {"ownernotonline", "Владельцов нет в сети, ремув недоступен!"},
{"DamageOnlineOwner", "Один их хозяев постройки сейчас в сети.\nУрон по объектам владельца стандартный"}, {"DamageNotOnlineOwner", "Не одного владельца постройки нет в сети.\nУрон по объектам владельца уменьшен в 2 раза!"},
{"OwnerEnterOnline", "Хозяин постройки зашел в игру.\nУрон по объектам владельца стандартный!"}, {"blocktrade", "Вы не можете использовать обмен во время рейда, подождите {0} сек."},
{"BlockLadders", "Вы не можете установить штурмовую лестницу в зоне действия чужого шкафа"}
};
public static class PermissionService
{
public static Permission permission = Interface.GetMod().GetLibrary<Permission>();
public static bool HasPermission(ulong uid, string permissionName)
{
return !string.IsNullOrEmpty(permissionName) && permission.UserHasPermission(uid.ToString(), permissionName);
}
public static void RegisterPermissions(Plugin owner, List<string> permissions)
{
if (owner == null) throw new ArgumentNullException("owner");
if (permissions == null) throw new ArgumentNullException("commands");
foreach (var permissionName in permissions.Where(permissionName => !permission.PermissionExists(permissionName)))
{
permission.RegisterPermission(permissionName, owner);
}
}
}
}
}