C#:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using UnityEngine;
using Color = UnityEngine.Color;
namespace Oxide.Plugins {
[Info("RustMap", "TopPlugin.ru / https://discord.com/invite/5DPTsRmd3G", "2.1.7")]
class RustMap : RustPlugin {
[PluginReference]
Plugin Clans, Friends, MutualPermission, NTeleportation, Teleport, Teleportation, SleepingbagHome, HomesGUI, QuarryCapture, NoEscape, SpawnsControl;
Dictionary<Vector3, int> GetSpawnZones() => SpawnsControl?.Call<Dictionary<Vector3, int>>("GetSpawnZones");
class MapMarker {
public Transform transform;
public int Rotation = -1;
public Vector2 anchorPosition {
get {
return ins.ToScreenCoords(position);
}
}
public Vector2 position = Vector2.zero;
public string name;
public string png;
public bool rotSupport = false;
public string text;
public float size;
public float alpha;
public int fontsize;
public ulong counter = 0;
public bool inMap = true;
protected MapMarker(Transform transform) {
this.transform = transform;
}
public virtual bool NeedRedraw() {
if (transform == null) return false;
var lastRot = Rotation;
if (rotSupport) Rotation = GetRotation(transform.eulerAngles.y);
var lastPos = position;
position = transform.position;
position.y = 0;
if (rotSupport && Rotation != lastRot) {
position = lastPos;
return true;
}
if (Vector3.Distance(position, lastPos) > 0.5) return true;
position = lastPos;
return false;
}
public static MapMarker Create(Transform transform) {
return new MapMarker(transform);
}
}
class MapPlayer : MapMarker {
public BasePlayer player;
public List<MapPlayer> clanTeam = new List<MapPlayer>();
protected MapPlayer(BasePlayer player) : base(player.transform) {
this.player = player;
}
public override bool NeedRedraw() {
var lastRot = Rotation;
if (player == null || transform == null) return false;
Rotation = GetRotation(player.eyes.rotation.eulerAngles.y);
var lastPos = position;
position = transform.position;
position.y = 0;
if (Rotation != lastRot) {
position = lastPos;
return true;
}
if (Vector3.Distance(position, lastPos) > 0.5) {
return true;
}
position = lastPos;
return false;
}
public void OnCloseMap() {
Rotation = -1;
position = Vector2.zero;
clanTeam?.ForEach(p => p.OnCloseMap());
}
public static MapPlayer Create(BasePlayer player) {
return new MapPlayer(player) {
alpha = 1, size = 0.3f
}
;
}
}
private PluginConfig config;
protected override void LoadDefaultConfig() {
PrintWarning("Thank you for ordering the plugin from developer OxideBro.If you transfer this plugin to third parties, be aware that it will deprive you of guaranteed updates!");
config = PluginConfig.DefaultConfig();
}
protected override void LoadConfig() {
base.LoadConfig();
config = Config.ReadObject<PluginConfig>();
if (config.PluginVersion != Version) UpdateConfigValues();
SaveConfig();
if (!string.IsNullOrEmpty(config.mainSettings.mapUrl)) {
if (!config.mainSettings.mapUrl.ToLower().Contains("http")) {
config.mainSettings.mapUrl = "file://" + Interface.Oxide.DataDirectory + Path.DirectorySeparatorChar + "RustMap" + Path.DirectorySeparatorChar + config.mainSettings.mapUrl;
}
DataMap = config.mainSettings.mapUrl;
}
}
private void UpdateConfigValues() {
PluginConfig baseConfig = PluginConfig.DefaultConfig();
if (config.PluginVersion < Version) {
PrintWarning("Config update detected! Updating config values...");
PrintWarning("Config update completed!");
}
config.PluginVersion = Version;
}
protected override void SaveConfig() {
if (Author != _("BkvqrOeb - EhfgCyhtva.eh")) Author = _("Cyhtva nhgube BkvqrOeb - EhfgCyhtva.eh");
Config.WriteObject(config);
}
public class MainSettings {
[JsonProperty("Кастомная карта (http:// или с папки data/RustMap)")]
public string mapUrl = "";
[JsonProperty("Частота обновления иконок на карте")]
public float MapUpdate = 0.3f;
[JsonProperty("Время до автоматического закрытия карты после ее открытия")]
public int TimeToClose = 10;
[JsonProperty("Прозрачность карты")]
public float mapAlpha = 1f;
[JsonProperty("Размер карты")]
public float mapSize = 0.5f;
[JsonProperty("Отображать местоположение монументов")]
public bool monuments = true;
[JsonProperty("Отображать названия монументов")]
public bool monumentIconNames = true;
[JsonProperty("Размер шрифта названия монументов")]
public int monumentsFontSize = 13;
[JsonProperty("Отображать пещеры")]
public bool caves = true;
[JsonProperty("Отображать метро")]
public bool entrance = true;
[JsonProperty("Отображать водонапорные башни")]
public bool water = true;
[JsonProperty("Отображать подстанции")]
public bool powersub = true;
[JsonProperty("Отображать местоположение cброшенного груза с грузового вертолёта")]
public bool NewHeliCrate = true;
[JsonProperty("Отображать местоположение грузового вертолёта (чинука)")]
public bool NewHeli = true;
[JsonProperty("Отображать местоположение магазинов с Сompound (Аванпост)")]
public bool NPCVendingMachine = false;
[JsonProperty("Отображать местоположение самолета")]
public bool plane = true;
[JsonProperty("Отображать местоположение танка")]
public bool bradley = true;
[JsonProperty("Отображать местоположение вертолёта")]
public bool heli = true;
[JsonProperty("Отображать местоположение cброшенного груза (Аирдроп)")]
public bool planeDrop = true;
[JsonProperty("Отображать местоположение ящиков с вертолёта")]
public bool heliDrop = true;
[JsonProperty("Отображать местоположение корабля")]
public bool ship = true;
[JsonProperty("Отображать местоположение торговых автоматов")]
public bool vendingMachine = true;
[JsonProperty("Отображать местоположение пустых торговых автоматов")]
public bool vendingMachineEmpty = true;
[JsonProperty("Показывать текущие координаты игрока")]
public bool playerCoordinates = true;
[JsonProperty("Поддержка Clans (Отображение сокланов на карте)")]
public bool clanSupport = false;
[JsonProperty("Поддержка Friends (Отображение друзей на карте)")]
public bool friendsSupport = false;
[JsonProperty("Поддержка Внутриигровой системы друзей (Отображение друзей на карте)")]
public bool TeamSupport = false;
[JsonProperty("Поддержка NoEscape (Отображение рейда дома игрока)")]
public bool noescapeSupport = false;
[JsonProperty("Поддержка NoEscape (Отображение всех рейдов на сервере по привилегии)")]
public bool noescapeSupportAdmin = false;
[JsonProperty("Поддержка Teleportation, NTeleportation, Teleport (Отображение сохраненных точек игроков)")]
public bool teleportSupport = false;
}
class PluginConfig {
[JsonProperty("Основные настройки")]
public MainSettings mainSettings;
[JsonProperty("Версия конфигурации")]
public VersionNumber PluginVersion = new VersionNumber();
public static PluginConfig DefaultConfig() {
return new PluginConfig() {
mainSettings = new MainSettings(), PluginVersion = new VersionNumber(),
}
;
}
}
static RustMap ins;
private string mapIconJson = @"[{""name"":""{0}"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.RawImage"",""sprite"":""assets/content/textures/generic/fulltransparent.tga"",""png"":""{3}"",""color"":""{color}""},{""type"":""RectTransform"",""anchormin"":""{1}"",""anchormax"":""{2}""}]}]";
private string mapIconTextJsonIcon = @"[{""name"":""{0}"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{3}"",""font"":""RobotoCondensed-Regular.ttf"",""align"":""MiddleCenter"",""fontSize"":{4},""color"":""{color1}""},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 0.6""},{""type"":""RectTransform"",""anchormin"":""{1}"",""anchormax"":""{2}""}]}]";
private string mapCoordsTextJson = @"[{""name"":""map_coordinates"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{0}"",""font"":""RobotoCondensed-Regular.ttf"",""align"":""MiddleCenter"",""fontSize"":18},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 0.3"",""distance"": ""0.5 -0.5""},{""type"":""RectTransform"",""anchormin"":""0 0.95"",""anchormax"":""1 1""}]}]";
Dictionary<BasePlayer, MapPlayer> mapPlayers = new Dictionary<BasePlayer, MapPlayer>();
Dictionary<BasePlayer, MapPlayer> subscribers = new Dictionary<BasePlayer, MapPlayer>();
List<MapMarker> temporaryMarkers = new List<MapMarker>();
const string MAP_ADMIN = "rustmap.admin";
string monumentsJson;
bool init = false;
private List<BasePlayer> AllPlayerUsers = new List<BasePlayer>();
[ChatCommand("map")]
void cmdMapControl(BasePlayer player, string command, string[] args) {
if (!init) {
SendReply(player, "Извините! В данный момент карта не активирована");
return;
}
CuiHelper.DestroyUi(player, "maphelp_2");
if (subscribers.Keys.Contains(player)) CloseMap(player);
else {
if (permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
if (data.MapPlayerData[player.userID].AllPlayers) AllPlayerUsers.Add(player);
else if (AllPlayerUsers.Contains(player)) AllPlayerUsers.Remove(player);
}
OpenMap(player);
}
}
[ConsoleCommand("map.open")]
void ConsoleMap(ConsoleSystem.Arg arg) {
var player = arg.Player();
if (!init) return;
if (subscribers.Keys.Contains(player)) CloseMap(player);
else OpenMap(player);
return;
}
private Timer mtimer;
void Loaded() {
ins = this;
LoadData();
permission.RegisterPermission(MAP_ADMIN, this);
permission.RegisterPermission(permissionName, this);
anchorMin = new Vector2(0.5f - config.mainSettings.mapSize * 0.5f, 0.5f - config.mainSettings.mapSize * 0.800f);
anchorMax = new Vector2(0.5f + config.mainSettings.mapSize * 0.5f, 0.5f + config.mainSettings.mapSize * 0.930f);
mapIconTextJsonIcon = mapIconTextJsonIcon.Replace("{color1}", "1 1 1 1");
}
void OnServerInitialized() {
_terrainTexture = TerrainTexturing.Instance;
if (_terrainTexture == null) return;
_terrain = _terrainTexture.GetComponent<Terrain>();
if (_terrain == null) return;
_heightMap = _terrainTexture.GetComponent<TerrainHeightMap>();
if (_heightMap == null) return;
_splatMap = _terrainTexture.GetComponent<TerrainSplatMap>();
if (_splatMap == null) return;
InitFileManager();
foreach (var entity in BaseNetworkable.serverEntities.Select(p => p as BaseEntity).Where(p => p != null)) OnEntitySpawned(entity);
foreach (var player in BasePlayer.activePlayerList) OnPlayerConnected(player);
mtimer = timer.Every(config.mainSettings.MapUpdate, () => {
foreach (var mm in temporaryMarkers) if (mm.NeedRedraw()) {
++mm.counter;
foreach (var sub in subscribers) DrawMapMarker(sub.Key, mm);
}
foreach (var sub in subscribers) {
RedrawPlayers(sub.Value);
}
}
);
timer.Every(1f, TimerHandler);
}
[ConsoleCommand("map.update")]
void cmdMapUpdateImages(ConsoleSystem.Arg args) {
if (args.Connection != null) return;
PrintWarning("Image update started, please wait.....");
m_FileManager.WipeData();
}
void OnNewSave() {
Interface.Oxide.DataFileSystem.WriteObject($"RustMap/Images", new sbyte());
PrintWarning("Wipe detected, clears image data");
}
void OnPlayerInput(BasePlayer player, InputState input) {
if (!timers.ContainsKey(player)) return;
if (!input.WasJustReleased(BUTTON.FIRE_SECONDARY)) return;
timers.Remove(player);
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, "map_infomouse");
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMax = "0 0"
}
, Image = {
Color = "0 0 0 0"
}
}
, "map_mainPanel");
CuiHelper.AddUi(player, container);
subscribers.Remove(player);
mapPlayers[player].OnCloseMap();
}
Dictionary<BasePlayer, int> timers = new Dictionary<BasePlayer, int>();
void TimerHandler() {
foreach (var player in timers.Keys.ToList()) {
if (player == null) {
timers.Remove(player);
continue;
}
var seconds = --timers[player];
if (seconds <= 0) {
CloseMap(player);
continue;
}
}
}
void LoadData() {
try {
MapPlayerData = Interface.Oxide.DataFileSystem.GetFile("RustMap/MapPlayerData");
data = Interface.GetMod().DataFileSystem.ReadObject<DataStorage>("RustMap/MapPlayerData");
CustomIcons = Interface.GetMod().DataFileSystem.ReadObject<Dictionary<string, CustomMapIcons>>("RustMap/CustomIcons");
CustomText = Interface.GetMod().DataFileSystem.ReadObject<Dictionary<string, CustomMapTexts>>("RustMap/CustomText");
}
catch {
data = new DataStorage();
CustomIcons = new Dictionary<string, CustomMapIcons>();
CustomText = new Dictionary<string, CustomMapTexts>();
}
}
void OnServerSave() {
if (data != null) MapPlayerData.WriteObject(data);
Interface.Oxide.DataFileSystem.WriteObject($"RustMap/CustomIcons", CustomIcons);
Interface.Oxide.DataFileSystem.WriteObject($"RustMap/CustomText", CustomText);
}
class DataStorage {
public Dictionary<ulong, MAPDATA> MapPlayerData = new Dictionary<ulong, MAPDATA>();
public DataStorage() {
}
}
class MAPDATA {
public bool Homes = false;
public bool Raid = false;
public bool AllRaids = false;
public bool Friends = false;
public bool Clans = false;
public bool Death = false;
public bool AllPlayers = false;
public bool Teams = false;
}
DataStorage data;
private DynamicConfigFile MapPlayerData;
void OnPlayerConnected(BasePlayer player) {
if (!mapPlayers.ContainsKey(player)) mapPlayers[player] = MapPlayer.Create(player);
if (!data.MapPlayerData.ContainsKey(player.userID)) data.MapPlayerData.Add(player.userID, new MAPDATA());
}
void Unload() {
OnServerSave();
foreach (var sub in subscribers.Keys) CuiHelper.DestroyUi(sub, "map_mainPanel");
if (FileManagerObject != null) UnityEngine.Object.Destroy(FileManagerObject);
}
void OnEntitySpawned(BaseEntity entity) {
if (entity == null) return;
if (config.mainSettings.plane && entity is CargoPlane) AddTemporaryMarker("plane", true, 0.03f, 1, entity.transform);
if (config.mainSettings.planeDrop && entity is SupplyDrop) AddTemporaryMarker("mapsupply", false, 0.04f, 1, entity.transform, "");
if (config.mainSettings.NewHeli && entity is CH47Helicopter) AddTemporaryMarker("newheli", true, 0.03f, 1, entity.transform);
if (config.mainSettings.NewHeliCrate && entity is HackableLockedCrate) {
var crate = entity as HackableLockedCrate;
if (!(entity.GetParentEntity() is CargoShip)) AddTemporaryMarker("newhelicreate", false, 0.03f, 1, entity.transform);
}
if (config.mainSettings.bradley && entity is BradleyAPC) AddTemporaryMarker("bradley", true, 0.03f, 1, entity.transform);
if (config.mainSettings.heli && entity is BaseHelicopter) AddTemporaryMarker("heli", true, 0.03f, 1, entity.transform);
if (config.mainSettings.ship && entity is CargoShip) AddTemporaryMarker("ship", true, 0.03f, 1, entity.transform);
if (config.mainSettings.heliDrop && entity.ShortPrefabName.Contains("heli_crate")) AddTemporaryMarker("helidebris", false, 0.03f, 1, entity.transform);
if (config.mainSettings.vendingMachine && entity is VendingMachine && ((VendingMachine)entity).HasFlag(BaseEntity.Flags.Reserved4)) {
if (entity is NPCVendingMachine) return;
if (config.mainSettings.vendingMachineEmpty && !((VendingMachine)entity).IsInventoryEmpty()) {
AddTemporaryMarker("vending", false, 0.03f, 1, entity.transform);
}
}
}
void OnToggleVendingBroadcast(VendingMachine machine, BasePlayer player) {
if (machine == null || machine.IsDestroyed) return;
if (machine.HasFlag(BaseEntity.Flags.Reserved4)) AddTemporaryMarker("vending", false, 0.03f, 1, machine.transform);
else {
var transform = machine.transform;
var mm = temporaryMarkers.Find(p => p.transform == transform);
if (mm != null) RemoveTemporaryMarker(mm);
}
}
List<Vector3> GetQuarries() {
return QuarryCapture?.Call("GetQuarries") as List<Vector3>;
}
void OnEntityKill(BaseNetworkable entity) {
if (entity?.net?.ID == null) return;
if (entity is CargoPlane || entity is SupplyDrop || entity is BaseHelicopter || entity is HelicopterDebris || entity is VendingMachine) {
var transform = entity.transform;
var mm = temporaryMarkers.Find(p => p.transform == transform);
if (mm != null) RemoveTemporaryMarker(mm);
}
}
List<ulong> GetMembersClan(ulong playerid = 2801664) {
if (Clans) {
List<ulong> Members = new List<ulong>();
if (Clans.ResourceId == 2087) {
var clan1tag = (string)Clans.Call("GetClanOf", playerid);
if (clan1tag != null) {
var members1 = ((JObject)Clans.Call("GetClan", clan1tag))["members"].ToObject<List<ulong>>();
if (members1 != null) return members1;
}
return null;
}
if (Clans.ResourceId == 14) {
var clanmates = Clans.Call("GetClanMembers", playerid) as List<string>;
if (clanmates != null) {
var list = clanmates.Select(ulong.Parse).ToList();
return list;
}
}
}
return null;
}
Vector2 anchorMin = new Vector2();
Vector2 anchorMax = new Vector2();
void OpenMap(BasePlayer player) {
if (player == null) return;
if (!init) {
SendReply(player, "Извините! В данный момент карта не активирована");
return;
}
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiElement {
Name = "map_mainPanel", Parent = "Hud", Components = {
new CuiImageComponent {
Color = $"1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_mainPanel", Components = {
new CuiButtonComponent {
Color = $"1 1 1 0", Close = "map_mainPanel"
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
,
}
}
);
container.Add(new CuiElement {
Name = "map_mainImage", Parent = "map_mainPanel", Components = {
new CuiRawImageComponent {
Color = $"1 1 1 {config.mainSettings.mapAlpha}", Png = MapPng()
}
, new CuiRectTransformComponent {
AnchorMin = $"{anchorMin.x} {anchorMin.y}", AnchorMax = $"{anchorMax.x} {anchorMax.y}"
}
}
}
);
container.Add(new CuiElement {
Name = "map_infomouse", Parent = "map_mainImage", FadeOut = 1f, Components = {
new CuiTextComponent {
Color="0.64 0.64 0.64 0.5", Text = "НАЖМИ ПРАВУЮ КНОПКУ МЫШИ ЧТОБЫ УПРАВЛЯТЬ КАРТОЙ", Align = TextAnchor.LowerCenter, FontSize = (int)TextSize(13), FadeIn = 0.5f, Font = "robotocondensed-regular.ttf"
}
, new CuiRectTransformComponent {
AnchorMin= "0 0.01", AnchorMax="1 0.1"
}
,
}
,
}
);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.8 0.01", AnchorMax = "0.99 0.1", OffsetMax = "0 0"
}
, Image = {
Color = "0 0 0 0"
}
}
, "map_mainImage", "map_settings");
container.Add(new CuiElement {
Parent = "map_settings", Components = {
new CuiRawImageComponent {
Color="0.64 0.64 0.64 1", Png = m_FileManager.GetPng("settings")
}
, new CuiRectTransformComponent {
AnchorMin= "0 0", AnchorMax="0.17 0.38"
}
,
}
,
}
);
container.Add(new CuiElement {
Parent = "map_settings", Components = {
new CuiTextComponent {
Color="0.64 0.64 0.64 1", Text = "НАСТРОЙКИ", Align = TextAnchor.LowerLeft, FontSize = (int)TextSize(13) /*, Font = "robotocondensed-regular.ttf"*/
}
, new CuiRectTransformComponent {
AnchorMin= "0.23 0.16", AnchorMax="1 0.6"
}
,
}
,
}
);
container.Add(new CuiElement {
Parent = "map_settings", Components = {
new CuiTextComponent {
Color="0.64 0.64 0.64 1", Text = "Нажми чтобы открыть", Align = TextAnchor.LowerLeft, FontSize = (int)TextSize(9), Font = "robotocondensed-regular.ttf"
}
, new CuiRectTransformComponent {
AnchorMin= "0.23 0", AnchorMax="1 1"
}
,
}
,
}
);
container.Add(new CuiElement {
Parent = "map_settings", Components = {
new CuiButtonComponent {
Color="0.64 0.64 0.64 0", Command = "map_settings"
}
, new CuiRectTransformComponent {
AnchorMin= "0 0", AnchorMax="1 0.5"
}
,
}
,
}
);
CuiHelper.DestroyUi(player, "map_mainPanel");
CuiHelper.AddUi(player, container);
CuiHelper.AddUi(player, monumentsJson);
if (SpawnsControl != null) {
var zone = GetSpawnZones().FirstOrDefault();
var anchor = ToAnchors(zone.Key, (float)zone.Value * 2 / World.Size);
DrawIcon(player, "RaidZones" + zone, "RaidZones" + zone, anchor, images["RaidZones"], 0.95f, null, 12, false);
}
foreach (var mm in temporaryMarkers) DrawMapMarker(player, mm);
List<ulong> members = new List<ulong>();
if (data.MapPlayerData[player.userID].AllPlayers && permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
mapPlayers[player].clanTeam = BasePlayer.activePlayerList.ToList().Where(p => p != player).Select(MapPlayer.Create).ToList();
}
else {
mapPlayers[player].clanTeam = new List<MapPlayer>();
if (config.mainSettings.clanSupport) {
if (data.MapPlayerData[player.userID].Clans) {
var clanmates = GetMembersClan(player.userID);
if (clanmates != null) members.AddRange(clanmates);
}
}
if (config.mainSettings.TeamSupport) if (data.MapPlayerData[player.userID].Teams) {
var teams = GetTeamMembers(player);
if (teams != null) members.AddRange(teams);
}
if (config.mainSettings.friendsSupport) {
if (data.MapPlayerData[player.userID].Friends) {
var friends = Friends?.Call("GetFriends", player.userID);
if (friends != null) members.AddRange(friends as ulong[]);
var MutualFr = MutualPermission?.Call("GetFriends", player.userID, "Map") as ulong[];
if (MutualFr != null) members.AddRange(MutualFr as ulong[]);
}
}
}
var homes = GetHomes(player);
if (config.mainSettings.teleportSupport && homes != null) foreach (var home in homes) {
var anchors = ToAnchors(home.Value, 0.03f);
if (data.MapPlayerData[player.userID].Homes) DrawButtonIcon(player, "sethome" + home.Key, "sethome" + home.Key, anchors, images["sethome"], 1.0f, $"home {home.Key}", $"Дом: {home.Key}", "1 1 1 1", 10, false);
}
if (members != null && members.Count > 0) {
var onlineMembers = BasePlayer.activePlayerList.ToList().Where(p => members.Contains(p.userID) && p != player).ToList();
mapPlayers[player].clanTeam.AddRange(onlineMembers.Select(MapPlayer.Create).ToList());
}
if (config.mainSettings.noescapeSupport && data.MapPlayerData[player.userID].Raid) {
var zones = GetRaidZones(player.userID);
if (zones != null) foreach (var zone in zones) {
var anchors = ToAnchors(zone, 0.06f);
DrawIcon(player, "raidhome" + zone, "raidhome" + zone, anchors, images["raidhome"], 0.95f, null, 12, false);
}
}
if (config.mainSettings.noescapeSupportAdmin && data.MapPlayerData[player.userID].AllRaids && permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
var zones = AdminGetRaidZones();
if (zones != null) foreach (var zone in zones) {
var anchors = ToAnchors(zone, 0.06f);
DrawIcon(player, "raidhome" + zone, "raidhome" + zone, anchors, images["raidhome"], 0.95f, null, 12, false);
}
}
if (playerDic.ContainsKey(player.userID)) {
if (data.MapPlayerData[player.userID].Death) {
var anchors = ToAnchors(playerDic[player.userID].ToVector3(), 0.03f);
DrawIconNull(player, "death" + player.userID, "death" + player.userID, anchors, images["death"], 1.0f, $"Ты умер здесь", null, 10, false);
}
}
if (QuarryCapture) {
var playerQuarries = GetQuarries();
if (playerQuarries != null) {
foreach (var quarry in playerQuarries) {
var anchors = ToAnchors(quarry, 0.03f);
DrawIconNull(player, "quarry" + quarry, "quarry" + quarry, anchors, images["quarry"], 1.0f, "УНИКАЛЬНЫЙ КАРЬЕР", null, 9, false);
}
}
}
if (CustomIcons.Count > 0) {
foreach (var icon in CustomIcons) {
var size = icon.Value.Size <= 0 ? 0.04f : icon.Value.Size;
var anchors = ToAnchors(icon.Value.position, size);
DrawIconNull(player, icon.Key, icon.Key, anchors, icon.Value.PNG, 1.0f, icon.Value.NAME, null, 10, false);
}
}
if (CustomText.Count > 0) {
foreach (var icon in CustomText) {
var size = 0.2f;
var anchors = ToAnchors(icon.Value.position, size);
DrawIconNull(player, icon.Key, icon.Key, anchors, null, 1.0f, icon.Value.NAME, icon.Value.Color, icon.Value.Size, false, 0, 1);
}
}
subscribers[player] = mapPlayers[player];
RedrawPlayers(mapPlayers[player]);
timers[player] = int.Parse(config.mainSettings.TimeToClose.ToString());
}
[ConsoleCommand("map_settings")]
void cmdOpenMapSettings(ConsoleSystem.Arg args) {
var player = args.Player();
if (player == null) return;
if (subscribers.ContainsKey(player)) subscribers.Remove(player);
mapPlayers[player].OnCloseMap();
if (args.Args != null && args.Args.Length > 0 && args.Args[0] == "set") {
switch (args.Args[1]) {
case "friends" : if (data.MapPlayerData[player.userID].Friends) data.MapPlayerData[player.userID].Friends = false;
else data.MapPlayerData[player.userID].Friends = true;
break;
case "team" : if (data.MapPlayerData[player.userID].Teams) data.MapPlayerData[player.userID].Teams = false;
else data.MapPlayerData[player.userID].Teams = true;
break;
case "clans" : if (data.MapPlayerData[player.userID].Clans) data.MapPlayerData[player.userID].Clans = false;
else data.MapPlayerData[player.userID].Clans = true;
break;
case "homes" : if (data.MapPlayerData[player.userID].Homes) data.MapPlayerData[player.userID].Homes = false;
else data.MapPlayerData[player.userID].Homes = true;
break;
case "allplayers" : if (data.MapPlayerData[player.userID].AllPlayers) data.MapPlayerData[player.userID].AllPlayers = false;
else data.MapPlayerData[player.userID].AllPlayers = true;
break;
case "death" : if (data.MapPlayerData[player.userID].Death) data.MapPlayerData[player.userID].Death = false;
else data.MapPlayerData[player.userID].Death = true;
break;
case "raid" : if (data.MapPlayerData[player.userID].Raid) data.MapPlayerData[player.userID].Raid = false;
else data.MapPlayerData[player.userID].Raid = true;
break;
case "allraids" : if (data.MapPlayerData[player.userID].AllRaids) data.MapPlayerData[player.userID].AllRaids = false;
else data.MapPlayerData[player.userID].AllRaids = true;
break;
}
}
CuiElementContainer container = new CuiElementContainer();
container.Add(new CuiElement {
Name = "map_Mainsettings", Parent = "map_mainImage", Components = {
new CuiImageComponent {
Color = $"0 0 0 0.8", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
, new CuiNeedsCursorComponent {
}
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings", Components = {
new CuiTextComponent {
Color="1 1 1 1", Text = "НАСТРОЙКА ОТОБРАЖЕНИЯ НА КАРТЕ", Align = TextAnchor.MiddleCenter, FontSize = (int)TextSize(25), Font = "robotocondensed-regular.ttf"
}
, new CuiRectTransformComponent {
AnchorMin= "0 0.7", AnchorMax="1 0.9"
}
,
}
,
}
);
container.Add(new CuiElement {
Name = "map_Mainsettings.menu", Parent = "map_Mainsettings", Components = {
new CuiImageComponent {
Color = $"0 0 0 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.1 0.1", AnchorMax = $"0.9 0.7"
}
,
}
}
);
double AnchorMin = 0;
double AnchorMax = 0.33;
double TwoAnchorMin = 0.85;
double TwoAnchorMax = 1;
if (config.mainSettings.friendsSupport) {
container.Add(new CuiElement {
Parent = "map_Mainsettings.menu", Name = "map_Mainsettings.friends", Components = {
new CuiImageComponent {
Color = "1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"{AnchorMin} {TwoAnchorMin}", AnchorMax = $"{AnchorMax} {TwoAnchorMax}"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.friends", Components = {
new CuiTextComponent {
Text = $"ДРУЗЬЯ", Color = "1 1 1 1", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(18)
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.friends", Name = "map_Mainsettings.friends.buttons", Components = {
new CuiImageComponent {
Color = "1 1 1 0.1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.05 0.05", AnchorMax = $"0.95 0.5"
}
,
}
}
);
container.Add(new CuiButton {
Button = {
Color = data.MapPlayerData[player.userID].Friends ? "0.59 0.83 0.60 1" : "1 1 1 0.1", Command = !data.MapPlayerData[player.userID].Friends ? "map_settings set friends" : ""
}
, Text = {
Text = "ВКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0 0", AnchorMax = $"0.49 0.98"
}
,
}
, "map_Mainsettings.friends.buttons");
container.Add(new CuiButton {
Button = {
Color = !data.MapPlayerData[player.userID].Friends ? "0.81 0.55 0.55 1" : "1 1 1 0.1", Command = data.MapPlayerData[player.userID].Friends ? "map_settings set friends" : ""
}
, Text = {
Text = "ВЫКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0.51 0", AnchorMax = $"1 0.98"
}
,
}
, "map_Mainsettings.friends.buttons");
AnchorMin = AnchorMax;
AnchorMax = AnchorMax + 0.33;
}
if (config.mainSettings.clanSupport) {
container.Add(new CuiElement {
Name = "map_Mainsettings.clans", Parent = "map_Mainsettings.menu", Components = {
new CuiImageComponent {
Color = "1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"{AnchorMin} {TwoAnchorMin}", AnchorMax = $"{AnchorMax} {TwoAnchorMax}"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.clans", Components = {
new CuiTextComponent {
Text = $"СОКЛАНОВЦЫ", Color = "1 1 1 1", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(18)
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.clans", Name = "map_Mainsettings.clans.buttons", Components = {
new CuiImageComponent {
Color = "1 1 1 0.1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.05 0.05", AnchorMax = $"0.95 0.5"
}
,
}
}
);
container.Add(new CuiButton {
Button = {
Color = data.MapPlayerData[player.userID].Clans ? "0.59 0.83 0.60 1" : "1 1 1 0.1", Command = !data.MapPlayerData[player.userID].Clans ? "map_settings set clans" : ""
}
, Text = {
Text = "ВКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0 0", AnchorMax = $"0.49 0.98"
}
,
}
, "map_Mainsettings.clans.buttons");
container.Add(new CuiButton {
Button = {
Color = !data.MapPlayerData[player.userID].Clans ? "0.81 0.55 0.55 1" : "1 1 1 0.1", Command = data.MapPlayerData[player.userID].Clans ? "map_settings set clans" : ""
}
, Text = {
Text = "ВЫКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0.51 0", AnchorMax = $"1 0.98"
}
,
}
, "map_Mainsettings.clans.buttons");
AnchorMin = AnchorMax;
AnchorMax = AnchorMax + 0.33;
}
if (config.mainSettings.TeamSupport) {
container.Add(new CuiElement {
Name = "map_Mainsettings.team", Parent = "map_Mainsettings.menu", Components = {
new CuiImageComponent {
Color = "1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"{AnchorMin} {TwoAnchorMin}", AnchorMax = $"{AnchorMax} {TwoAnchorMax}"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.team", Components = {
new CuiTextComponent {
Text = $"КОМАНДА", Color = "1 1 1 1", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(18)
}
, new CuiRectTransformComponent {
AnchorMin = $"0 0", AnchorMax = $"1 1"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.team", Name = "map_Mainsettings.team.buttons", Components = {
new CuiImageComponent {
Color = "1 1 1 0.1"
}
, new CuiRectTransformComponent {
AnchorMin = $"0.05 0.05", AnchorMax = $"0.95 0.5"
}
,
}
}
);
container.Add(new CuiButton {
Button = {
Color = data.MapPlayerData[player.userID].Teams ? "0.59 0.83 0.60 1" : "1 1 1 0.1", Command = !data.MapPlayerData[player.userID].Teams ? "map_settings set team" : ""
}
, Text = {
Text = "ВКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0 0", AnchorMax = $"0.49 0.98"
}
,
}
, "map_Mainsettings.team.buttons");
container.Add(new CuiButton {
Button = {
Color = !data.MapPlayerData[player.userID].Teams ? "0.81 0.55 0.55 1" : "1 1 1 0.1", Command = data.MapPlayerData[player.userID].Teams ? "map_settings set team" : ""
}
, Text = {
Text = "ВЫКЛ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(15)
}
, RectTransform = {
AnchorMin = $"0.51 0", AnchorMax = $"1 0.98"
}
,
}
, "map_Mainsettings.team.buttons");
AnchorMin = AnchorMax;
AnchorMax = AnchorMax + 0.33;
}
if (config.mainSettings.teleportSupport) {
if (AnchorMin >= 0.7f) {
AnchorMin = 0;
AnchorMax = 0.33;
TwoAnchorMin = 0.65;
TwoAnchorMax = 0.8;
}
container.Add(new CuiElement {
Name = "map_Mainsettings.homes", Parent = "map_Mainsettings.menu", Components = {
new CuiImageComponent {
Color = "1 1 1 0"
}
, new CuiRectTransformComponent {
AnchorMin = $"{AnchorMin} {TwoAnchorMin}", AnchorMax = $"{AnchorMax} {TwoAnchorMax}"
}
,
}
}
);
container.Add(new CuiElement {
Parent = "map_Mainsettings.homes", Components = {
new CuiTextComponent {
Text = $"ДОМА", Color = "1 1 1 1", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = (int)TextSize(18)
}
, n
// ... [Code preview truncated due to length. Full source in attached file] ...