C#:
// Reference: System.Drawing
using Network;
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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using UnityEngine;
namespace Oxide.Plugins {
[Info("RustMap", "RustPlugin.ru", "1.3.5")]
class RustMap : RustPlugin {
#region Classes
[PluginReference]
Plugin Clans;
[PluginReference]
Plugin Friends;
[PluginReference]
Plugin MutualPermission;
[PluginReference]
Plugin NTeleportation;
[PluginReference]
Plugin Teleport;
[PluginReference]
Plugin Teleportation;
[PluginReference]
Plugin CustomQuarry;
[PluginReference]
Plugin HomesGUI;
[PluginReference]
Plugin PlayersClasses;
class MapMarker {
public Transform transform;
public int Rotation = -1;
public Vector2 anchorPosition {
get {
return m_Instance.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 = m_Instance.playerIconAlpha, size = m_Instance.playerIconSize
}
;
}
}
#endregion
#region Configuration
string beancanKey;
float mapAlpha;
float mapSize;
bool clanSupport;
bool friendsSupport;
float playerIconSize;
float playerIconAlpha;
bool playerCoordinates;
bool monuments;
bool caves;
bool powersub;
float monumentIconSize;
float monumentIconAlpha;
bool monumentIconNames;
float MapUpdate;
bool raidhomes;
float raidhomeSIze;
int monumentsFontSize;
bool bradley;
float bradleyIconSize;
float bradleyIconAlpha;
bool car;
bool plane;
float planeIconSize;
float planeIconAlpha;
float TimeToClose;
bool NewHeli;
float NewheliIconSize;
float NewheliIconAlpha;
bool NewHeliCrate;
float NewHeliCrateIconSize;
float NewHeliCrateIconAlpha;
bool ship;
float shipIconSize;
float shipIconAlpha;
bool ballon;
float ballonIconSize;
float ballonIconAlpha;
bool planeDrop;
bool sethome;
float sethomeIconSize;
float deathIconSize;
float planeDropIconSize;
float planeDropIconAlpha;
bool heli;
float heliIconSize;
float heliIconAlpha;
bool heliDrop;
bool quarry;
float quarryIconAlpha;
float quarryIconSize;
float heliDropIconSize;
float heliDropIconAlpha;
bool vendingMachine;
bool vendingMachineEmpty;
float vendingMachineIconSize;
float vendingMachineIconAlpha;
string textColor;
string textColor1;
float bannedSize;
string mapUrl;
string MapText;
private string version;
bool NPCVendingMachine;
protected override void LoadDefaultConfig() {
Config["Ключ Beancan (Генерация карты с beancan.io)"] = beancanKey = GetConfig("Ключ Beancan (Генерация карты с beancan.io)", "");
Config["Кастомная карта (http:// или с папки data/RustMap)"] = mapUrl = GetConfig("Кастомная карта (http:// или с папки data/RustMap)", "");
Config["Прозрачность карты"] = mapAlpha = GetConfig("Прозрачность карты", 0.95f);
Config["Размер карты"] = mapSize = GetConfig("Размер карты", 0.5f);
Config["Частота обновлений карты"] = MapUpdate = GetConfig("Частота обновлений карты", 0.15f);
Config["Время до автоматического закрытия карты после ее открытия"] = TimeToClose = GetConfig("Время до автоматического закрытия карты после ее открытия", 15f);
Config["Версия конфигурации карты"] = version = GetConfig("Версия конфигурации карты ", Version.ToString());
Config["Отображать местоположение магазинов на базе ученых"] = NPCVendingMachine = GetConfig("Отображать местоположение магазинов на базе ученых", false);
Config["Отображать местоположение карьеров (CustomQuarry)"] = quarry = GetConfig("Отображать местоположение карьеров(CustomQuarry)", false);
Config["Размер иконки карьера"] = quarryIconSize = GetConfig("Размер иконки карьера", 0.03f);
Config["Прозрачность иконки карьера"] = quarryIconAlpha = GetConfig("Прозрачность иконки карьера", 0.95f);
Config["Отображать дома, который рейдят"] = raidhomes = GetConfig("Отображать дома, который рейдят", true);
Config["Размер иконок домов, которые рейдят"] = raidhomeSIze = GetConfig("Размер иконок домов, которые рейдят", 0.04f);
Config["Отображать местоположение соклановцев"] = clanSupport = GetConfig("Отображать местоположение соклановцев", false);
Config["Отображать местоположение друзей"] = friendsSupport = GetConfig("Отображать местоположение друзей", false);
Config["Цвет текста (RED, GREEN, BLUE, ALPHA)"] = textColor = GetConfig("Цвет текста (RED, GREEN, BLUE, ALPHA)", "0 0.7 0 0.7");
Config["Цвет текста кастомных иконок (Homes)"] = textColor1 = GetConfig("Цвет текста кастомных иконок (Homes)", "1 1 1 1");
Config["Текст внизу карты (советуем оставить /map help)"] = MapText = GetConfig("Текст внизу карты (советуем оставить /map help)", "Помощь по карте: <color=#EF015A>/map help</color>");
Config["Отображать местоположение сохраненных домов"] = sethome = GetConfig("Отображать местоположение сохраненных домов", false);
Config["Размер иконок сохраненных домов"] = sethomeIconSize = GetConfig("Размер иконок сохраненных домов", 0.03f);
Config["Размер иконки смерти игрока"] = deathIconSize = GetConfig("Размер иконки смерти игрока", 0.03f);
Config["Размер иконки игрока"] = playerIconSize = GetConfig("Размер иконки игрока", 0.03f);
Config["Прозрачность иконки игрока"] = playerIconAlpha = GetConfig("Прозрачность иконки игрока", 0.95f);
Config["Показывать текущие координаты игрока"] = playerCoordinates = GetConfig("Показывать текущие координаты игрока", true);
Config["Отображать местоположение монументов"] = monuments = GetConfig("Отображать местоположение монументов", true);
Config["Показывать пещеры"] = caves = GetConfig("Показывать пещеры", true);
Config["Показывать подстанции"] = powersub = GetConfig("Показывать подстанции", true);
Config["Размер иконок монументов"] = monumentIconSize = GetConfig("Размер иконок монументов", 0.035f);
Config["Размер иконки забаненого игрока"] = bannedSize = GetConfig("Размер иконки забаненого игрока", 0.04f);
Config["Прозрачность иконок монументов"] = monumentIconAlpha = GetConfig("Прозрачность иконок монументов", 0.95f);
Config["Показывать название монументов"] = monumentIconNames = GetConfig("Показывать название монументов", true);
Config["Размер шрифта монументов"] = monumentsFontSize = GetConfig("Размер шрифта монументов", 13);
Config["Отображать местоположение самолета"] = plane = GetConfig("Отображать местоположение самолета", true);
Config["Размер иконок самолёта"] = planeIconSize = GetConfig("Размер иконок самолёта", 0.035f);
Config["Прозрачность иконок самолёта"] = planeIconAlpha = GetConfig("Прозрачность иконок самолёта", 0.95f);
Config["Отображать местоположение cброшенного груза с грузового вертолёта"] = NewHeliCrate = GetConfig("Отображать местоположение cброшенного груза с грузового вертолёта", true);
Config["Размер иконки груза с грузового вертолёта"] = NewHeliCrateIconSize = GetConfig("Размер иконки груза с грузового вертолёта", 0.04f);
Config["Прозрачность иконки груза с грузового вертолёта"] = NewHeliCrateIconAlpha = GetConfig("Прозрачность иконки груза с грузового вертолёта", 0.95f);
Config["Отображать местоположение грузового вертолёта"] = NewHeli = GetConfig("Отображать местоположение самолета", true);
Config["Размер иконки грузового вертолёта"] = NewheliIconSize = GetConfig("Размер иконки грузового вертолёта", 0.035f);
Config["Прозрачность иконки грузового вертолёта"] = NewheliIconAlpha = GetConfig("Прозрачность иконок самолёта", 0.95f);
Config["Отображать местоположение корабля"] = ship = GetConfig("Отображать местоположение корабля", true);
Config["Размер иконки корабля"] = shipIconSize = GetConfig("Размер иконки корабля", 0.035f);
Config["Прозрачность иконки корабля"] = shipIconAlpha = GetConfig("Прозрачность иконки корабля", 0.95f);
Config["Отображать местоположение воздушного шара"] = ballon = GetConfig("Отображать местоположение воздушного шара", true);
Config["Размер иконки воздушного шара"] = ballonIconSize = GetConfig("Размер иконки воздушного шара", 0.035f);
Config["Прозрачность иконки воздушного шара"] = ballonIconAlpha = GetConfig("Прозрачность иконки воздушного шара", 0.95f);
Config["Отображать местоположение танка"] = bradley = GetConfig("Отображать местоположение танка", false);
Config["Размер иконки танка"] = bradleyIconSize = GetConfig("Размер иконки танка", 0.05f);
Config["Прозрачность иконки танка"] = bradleyIconAlpha = GetConfig("Прозрачность иконки танка", 0.95f);
Config["Отображать местоположение вертолёта"] = heli = GetConfig("Отображать местоположение вертолёта", true);
Config["Размер иконок вертолёта"] = heliIconSize = GetConfig("Размер иконок вертолёта", 0.04f);
Config["Прозрачность иконок вертолёта"] = heliIconAlpha = GetConfig("Прозрачность иконок вертолёта", 0.95f);
Config["Отображать местоположение cброшенного груза"] = planeDrop = GetConfig("Отображать местоположение cброшенного груза", true);
Config["Размер иконок cброшенного груза"] = planeDropIconSize = GetConfig("Размер иконок cброшенного груза", 0.045f);
Config["Прозрачность иконок cброшенного груза"] = planeDropIconAlpha = GetConfig("Прозрачность иконок cброшенного груза", 0.95f);
Config["Отображать местоположение ящиков с вертолёта"] = heliDrop = GetConfig("Отображать местоположение ящиков с вертолёта", true);
Config["Размер иконок ящиков с вертолёта"] = heliDropIconSize = GetConfig("Размер иконок ящиков с вертолёта", 0.035f);
Config["Прозрачность иконок ящиков с вертолёта"] = heliDropIconAlpha = GetConfig("Прозрачность иконок ящиков с вертолёта", 0.95f);
Config["Отображать местоположение торговых автоматов"] = vendingMachine = GetConfig("Отображать местоположение торговых автоматов", true);
Config["Отображать местоположение пустых торговых автоматов"] = vendingMachineEmpty = GetConfig("Отображать местоположение пустых торговых автоматов", true);
Config["Размер иконок торговых автоматов"] = vendingMachineIconSize = GetConfig("Размер иконок торговых автоматов", 0.025f);
Config["Прозрачность иконок торговых автоматов"] = vendingMachineIconAlpha = GetConfig("Прозрачность иконок торговых автоматов", 0.95f);
SaveConfig();
if (!string.IsNullOrEmpty(mapUrl)) {
if (!mapUrl.ToLower().Contains("http")) {
mapUrl = "file://" + Interface.Oxide.DataDirectory + Path.DirectorySeparatorChar + "RustMap" + Path.DirectorySeparatorChar + mapUrl;
}
}
}
T GetConfig <T> (string name, T defaultValue) => Config[name] == null ? defaultValue : (T) Convert.ChangeType(Config[name], typeof(T));
#endregion
#region Fields
static RustMap m_Instance;
private string mapIconJson = @"[{""name"":""{0}"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.RawImage"",""sprite"":""assets/content/textures/generic/fulltransparent.tga"",""png"":""{3}"",""color"":""1 1 1 {4}""},{""type"":""RectTransform"",""anchormin"":""{1}"",""anchormax"":""{2}""}]}]";
private string mapIconTextJson = @"[{""name"":""{0}"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{3}"",""align"":""MiddleCenter"",""fontSize"":12,""color"":""{color}""},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 1""},{""type"":""RectTransform"",""anchormin"":""{1}"",""anchormax"":""{2}""}]}]";
private string mapIconTextJsonIcon = @"[{""name"":""{0}"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{3}"",""align"":""MiddleCenter"",""fontSize"":9,""color"":""{color1}""},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 1""},{""type"":""RectTransform"",""anchormin"":""{1}"",""anchormax"":""{2}""}]}]";
private string mapJson = "[{\"name\":\"map_mainImage\",\"parent\":\"Overlay\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"1 1 1 {1}\",\"png\":\"{0}\"},{\"type\":\"RectTransform\",\"anchormin\":\"{2}\",\"anchormax\":\"{3}\"}]}]";
private string mapCoordsTextJson = @"[{""name"":""map_coordinates"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{0}"",""align"":""MiddleCenter"",""fontSize"":18},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 1"",""distance"": ""0.5 -0.5""},{""type"":""RectTransform"",""anchormin"":""0 0.95"",""anchormax"":""1 1""}]}]";
private string mapHelpJson = @"[{""name"":""map_help"",""parent"":""map_mainImage"",""components"":[{""type"":""UnityEngine.UI.Text"",""text"":""{0}"",""align"":""MiddleLeft"",""fontSize"":16},{""type"": ""UnityEngine.UI.Outline"",""color"": ""0 0 0 1"",""distance"": ""0.5 -0.5""},{""type"":""RectTransform"",""anchormin"":""0.02 0.001"",""anchormax"":""1 0.05""}]}]";
Dictionary<BasePlayer, MapPlayer> mapPlayers = new Dictionary<BasePlayer, MapPlayer>();
Dictionary<BasePlayer, MapPlayer> subscribers = new Dictionary<BasePlayer, MapPlayer>();
List<MapMarker> temporaryMarkers = new List<MapMarker>();
const string MARKER_BANNED_PERM = "rustmap.banned";
const string MAP_ADMIN = "rustmap.admin";
const string MAP_DEATH = "rustmap.death";
static float mapSize1;
static string mapSeed;
static int worldSize;
static string level;
string monumentsJson;
bool init = false;
#endregion
#region Command
private List<BasePlayer> AllPlayerUsers = new List<BasePlayer>();
private Timer CloseMapTimer;
[ChatCommand("map")]
void cmdMapControl(BasePlayer player, string command, string[] args) {
if (!init || player == null) {
SendReply(player, "Извините! В данный момент карта не активирована");
return;
}
CuiHelper.DestroyUi(player, "maphelp_2");
if (sethome) {
if (args.Count() >= 1 && args[0] == "homes") {
if (data.MapPlayerData[player.userID].Homes == true) {
data.MapPlayerData[player.userID].Homes = data.MapPlayerData[player.userID].Homes = false;
SendReply(player, $"<color=orange>Map homes</color>: False");
PlayerSaveData();
return;
}
if (data.MapPlayerData[player.userID].Homes == false) {
data.MapPlayerData[player.userID].Homes = data.MapPlayerData[player.userID].Homes = true;
PlayerSaveData();
SendReply(player, $"<color=orange>Map homes</color>: True");
return;
}
}
}
if (friendsSupport) {
if (args.Count() >= 1 && args[0] == "friends") {
if (data.MapPlayerData[player.userID].Friends == true) {
data.MapPlayerData[player.userID].Friends = data.MapPlayerData[player.userID].Friends = false;
SendReply(player, $"<color=orange>Map friends</color>: False");
PlayerSaveData();
return;
}
if (data.MapPlayerData[player.userID].Friends == false) {
data.MapPlayerData[player.userID].Friends = data.MapPlayerData[player.userID].Friends = true;
PlayerSaveData();
SendReply(player, $"<color=orange>Map Friends</color>: True");
return;
}
}
}
if (clanSupport) {
if (args.Count() >= 1 && args[0] == "clans") {
if (data.MapPlayerData[player.userID].Clans == true) {
data.MapPlayerData[player.userID].Clans = data.MapPlayerData[player.userID].Clans = false;
SendReply(player, $"<color=orange>Map Clans</color>: False");
PlayerSaveData();
return;
}
if (data.MapPlayerData[player.userID].Clans == false) {
data.MapPlayerData[player.userID].Clans = data.MapPlayerData[player.userID].Clans = true;
PlayerSaveData();
SendReply(player, $"<color=orange>Map Clans</color>: True");
return;
}
}
}
if (permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
if (args.Count() >= 1 && args[0] == "players") {
if (data.MapPlayerData[player.userID].AllPlayers == true) {
data.MapPlayerData[player.userID].AllPlayers = data.MapPlayerData[player.userID].AllPlayers = false;
PlayerSaveData();
SendReply(player, $"<color=orange>Map AllPlayers</color>: False");
return;
}
if (data.MapPlayerData[player.userID].AllPlayers == false) {
data.MapPlayerData[player.userID].AllPlayers = data.MapPlayerData[player.userID].AllPlayers = true;
PlayerSaveData();
SendReply(player, $"<color=orange>Map AllPlayers</color>: True");
return;
}
}
if (args.Count() >= 1 && args[0] == "bans") {
if (data.MapPlayerData[player.userID].BanPlayers == true) {
data.MapPlayerData[player.userID].BanPlayers = data.MapPlayerData[player.userID].BanPlayers = false;
SendReply(player, $"<color=orange>Map BanPlayers</color>: False");
PlayerSaveData();
return;
}
if (data.MapPlayerData[player.userID].BanPlayers == false) {
data.MapPlayerData[player.userID].BanPlayers = data.MapPlayerData[player.userID].BanPlayers = true;
PlayerSaveData();
SendReply(player, $"<color=orange>Map BanPlayers</color>: True");
return;
}
}
}
if (subscribers.Keys.Contains(player)) {
CloseMap(player);
}
else {
if (permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
if (args.Count() >= 1 && args[0] == "help") {
HelpUI(player);
return;
}
if (data.MapPlayerData[player.userID].AllPlayers == true) {
AllPlayerUsers.Add(player);
}
if (data.MapPlayerData[player.userID].AllPlayers == false) {
if (AllPlayerUsers.Contains(player)) AllPlayerUsers.Remove(player);
}
OpenMap(player);
return;
}
if (!permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
if (args.Count() >= 1 && args[0] == "help") {
HelpUI(player);
return;
}
OpenMap(player);
}
}
}
string button = "[{\"name\":\"CuiElement\",\"parent\":\"maphelp_2\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"{color}\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.03 {amin}\",\"anchormax\":\"0.97 {amax}\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"CuiElement\",\"parent\":\"CuiElement\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"{text}\",\"fontSize\":16,\"align\":\"MiddleCenter\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0 0 0 0.2784314\",\"distance\":\"1 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"CuiElement\",\"parent\":\"CuiElement\",\"components\":[{\"type\":\"UnityEngine.UI.Button\",\"command\":\"{command}\",\"color\":\"1 1 1 0\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]}]";
private string MapHelp = "[{\"name\":\"maphelp_2\",\"parent\":\"Overlay\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"0.1647059 0.1647059 0.1647059 1\"},{\"type\":\"NeedsCursor\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.3704246 0.1914063\",\"anchormax\":\"0.6222548 0.7773438\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_3\",\"parent\":\"maphelp_2\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"0.8431373 0.3372549 0.2509804 1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0.9359605\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_4\",\"parent\":\"maphelp_3\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"<b>RustMap v{version}</b>\",\"fontSize\":18,\"align\":\"MiddleCenter\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0 0 0 0.2784314\",\"distance\":\"1 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_5\",\"parent\":\"maphelp_2\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"<b>by Fartus</b> \",\"align\":\"MiddleRight\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.01492521 0.004926026\",\"anchormax\":\"1 0.06896545\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_6\",\"parent\":\"maphelp_2\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"0.2728048 0.2728048 0.2728048 1\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0.8431373 0.3372549 0.2509804 1\",\"distance\":\"0 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.51 0.07635458\",\"anchormax\":\"0.97 0.135468\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_7\",\"parent\":\"maphelp_6\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"☓ <b>Закрыть</b>\",\"fontSize\":16,\"align\":\"MiddleCenter\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0 0 0 0.2784314\",\"distance\":\"1 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"button1\",\"parent\":\"maphelp_6\",\"components\":[{\"type\":\"UnityEngine.UI.Button\",\"close\":\"maphelp_2\",\"color\":\"1 1 1 0\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\"}]},{\"name\":\"maphelp_8\",\"parent\":\"maphelp_2\",\"components\":[{\"type\":\"UnityEngine.UI.RawImage\",\"sprite\":\"Assets/Content/UI/UI.Background.Tile.psd\",\"color\":\"0.8431373 0.3372549 0.2509804 1\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0.8431373 0.3372549 0.2509804 1\",\"distance\":\"0 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0.03 0.07731612\",\"anchormax\":\"0.48 0.1364295\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"maphelp_9\",\"parent\":\"maphelp_8\",\"components\":[{\"type\":\"UnityEngine.UI.Text\",\"text\":\"♦ <b>Открыть карту</b>\",\"fontSize\":16,\"align\":\"MiddleCenter\"},{\"type\":\"UnityEngine.UI.Outline\",\"color\":\"0 0 0 0.2784314\",\"distance\":\"1 -1\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\",\"offsetmin\":\"0 0\",\"offsetmax\":\"1 1\"}]},{\"name\":\"button2\",\"parent\":\"maphelp_8\",\"components\":[{\"type\":\"UnityEngine.UI.Button\",\"command\":\"map.open\",\"color\":\"1 1 1 0\"},{\"type\":\"RectTransform\",\"anchormin\":\"0 0\",\"anchormax\":\"1 1\"}]}]";
void HelpUI(BasePlayer player) {
CuiHelper.DestroyUi(player, "maphelp_2");
CuiHelper.AddUi(player, MapHelp.Replace("{version}", Version.ToString()));
var container = new CuiElementContainer();
double amin = 0.82;
double amax = 0.91;
if (friendsSupport) {
var color = data.MapPlayerData[player.userID].Friends ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Друзья на карте").Replace("{command}", "cmd.help friends").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color));
amin = (amin - 0.11);
amax = (amax - 0.11);
}
if (clanSupport) {
var color = data.MapPlayerData[player.userID].Clans ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Соклановцы на карте").Replace("{command}", "cmd.help clans").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color));
amin = (amin - 0.11);
amax = (amax - 0.11);
}
if (sethome) {
var color = data.MapPlayerData[player.userID].Homes ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Отображение домов на карте").Replace("{command}", "cmd.help homes").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color));
amin = (amin - 0.11);
amax = (amax - 0.11);
}
var color1 = data.MapPlayerData[player.userID].Death ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Отображение последней смерти на карте").Replace("{command}", "cmd.help death").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color1));
amin = (amin - 0.11);
amax = (amax - 0.11);
if (player.IsAdmin || permission.UserHasPermission(player.UserIDString, MAP_ADMIN)) {
CuiHelper.AddUi(player, button.Replace("{text}", "Админ раздел").Replace("{command}", "").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", "0.85 0.34 0.25 0"));
amin = (amin - 0.11);
amax = (amax - 0.11);
var color = data.MapPlayerData[player.userID].AllPlayers ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Отобразить всех игроков на карте").Replace("{command}", "cmd.help allplayers").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color));
amin = (amin - 0.11);
amax = (amax - 0.11);
var color2 = data.MapPlayerData[player.userID].BanPlayers ? "0.85 0.34 0.25 1.00" : "0.33 0.33 0.33 1.00";
CuiHelper.AddUi(player, button.Replace("{text}", "Отобразить забаненых игроков на карте").Replace("{command}", "cmd.help banplayers").Replace("{amin}", amin.ToString()).Replace("{amax}", amax.ToString()).Replace("{color}", color2));
amin = (amin - 0.11);
amax = (amax - 0.11);
}
}
[ConsoleCommand("cmd.help")]
private void CmdHelpControll(ConsoleSystem.Arg arg) {
var player = arg.Player();
switch (arg.Args[0]) {
case "friends" : if (data.MapPlayerData[player.userID].Friends) {
data.MapPlayerData[player.userID].Friends = false;
}
else {
data.MapPlayerData[player.userID].Friends = 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 "banplayers" : if (data.MapPlayerData[player.userID].BanPlayers) {
data.MapPlayerData[player.userID].BanPlayers = false;
}
else {
data.MapPlayerData[player.userID].BanPlayers = true;
}
break;
case "death" : if (data.MapPlayerData[player.userID].Death) {
data.MapPlayerData[player.userID].Death = false;
}
else {
data.MapPlayerData[player.userID].Death = true;
}
break;
}
HelpUI(player);
}
[ConsoleCommand("map.wipe")]
private void CmdTest(ConsoleSystem.Arg arg) {
if (arg.Connection != null) return;
m_FileManager.WipeData();
Interface.Oxide.ReloadPlugin(Title);
}
[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;
}
#endregion
#region Oxide Hooks
private Timer mtimer;
void OnServerInitialized() {
m_Instance = this;
worldSize = (int)World.Size;
mapSeed = World.Seed.ToString();
level = ConVar.Server.level;
mapSize1 = TerrainMeta.Size.x;
MapPlayerData = Interface.Oxide.DataFileSystem.GetFile("RustMap/MapPlayerData");
LoadData();
PermissionService.RegisterPermissions(this, new List<string>() {
MARKER_BANNED_PERM, MAP_ADMIN, MAP_DEATH
}
);
LoadDefaultConfig();
worldSize = (int) World.Size;
var anchorMin = new Vector2(0.5f - mapSize * 0.5f, 0.5f - mapSize * 0.800f);
var anchorMax = new Vector2(0.5f + mapSize * 0.5f, 0.5f + mapSize * 0.930f);
mapJson = mapJson.Replace("{2}", $"{anchorMin.x} {anchorMin.y}").Replace("{3}", $"{anchorMax.x} {anchorMax.y}");
mapIconTextJson = mapIconTextJson.Replace("{color}", textColor);
mapIconTextJsonIcon = mapIconTextJsonIcon.Replace("{color1}", textColor1);
InitFileManager();
m_FileManager.StartCoroutine(DownloadMapImage());
foreach (var player in BasePlayer.activePlayerList) {
OnPlayerInit(player);
}
mtimer = timer.Every(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);
}
}
);
BansUpdate();
timer.Every(20f, BansUpdate);
foreach (var entity in BaseNetworkable.serverEntities.Select(p => p as BaseEntity).Where(p => p != null)) OnEntitySpawned(entity);
}
void OnPlayerInit(BasePlayer player) {
if (!mapPlayers.ContainsKey(player)) mapPlayers[player] = MapPlayer.Create(player);
if (!data.MapPlayerData.ContainsKey(player.userID)) {
data.MapPlayerData.Add(player.userID, new MAPDATA() {
Name = player.displayName, Homes = false, Friends = false, Clans = false, AllPlayers = false, BanPlayers = false,
}
);
PlayerSaveData();
}
else {
data.MapPlayerData[player.userID].Name = player.displayName.ToString();
LoadData();
}
}
void OnNewSave() {
LoadData();
PrintWarning("Обнаружен вайп.Обновляем карту!");
Interface.Oxide.DataFileSystem.WriteObject("RustMap/Images", new Dictionary<string, FileInfo>());
Interface.Oxide.ReloadPlugin(Title);
}
void Unload() {
if (m_FileManager != null) {
m_FileManager.SaveData();
PlayerSaveData();
}
if (!init) return;
foreach (var sub in subscribers.Keys) {
CuiHelper.DestroyUi(sub, "map_mainImage");
}
if (FileManagerObject != null) UnityEngine.Object.Destroy(FileManagerObject);
}
void OnEntitySpawned(BaseEntity entity) {
if (entity == null) return;
if (plane && entity is CargoPlane) AddTemporaryMarker("plane", true, planeIconSize, planeIconAlpha, entity.transform);
if (planeDrop && entity is SupplyDrop) {
AddTemporaryMarker("mapsupply", false, planeDropIconSize, planeDropIconAlpha, entity.transform, "name");
}
if (NewHeli && entity is CH47Helicopter) {
AddTemporaryMarker("newheli", true, NewheliIconSize, NewheliIconAlpha, entity.transform);
}
if (NewHeliCrate && entity is HackableLockedCrate) {
if (!(entity.GetParentEntity() is CargoShip)) AddTemporaryMarker("newhelicreate", false, NewHeliCrateIconSize, NewHeliCrateIconAlpha, entity.transform);
}
if (bradley && entity is BradleyAPC) {
AddTemporaryMarker("bradley", true, bradleyIconSize, bradleyIconAlpha, entity.transform);
}
if (ship && entity is CargoShip) {
AddTemporaryMarker("ship", true, shipIconSize, shipIconAlpha, entity.transform);
}
if (ballon && entity is HotAirBalloon) {
AddTemporaryMarker("ballon", false, ballonIconSize, ballonIconAlpha, entity.transform);
}
if (heli && entity is BaseHelicopter) {
AddTemporaryMarker("heli", true, heliIconSize, heliIconAlpha, entity.transform);
}
if (heliDrop && entity is HelicopterDebris) {
AddTemporaryMarker("helidebris", false, heliDropIconSize, heliDropIconAlpha, entity.transform);
}
if (vendingMachine && entity is VendingMachine) {
if (!NPCVendingMachine) if (entity is NPCVendingMachine) return;
if (vendingMachineEmpty || !((VendingMachine)entity).IsInventoryEmpty()) {
AddTemporaryMarker("vending", false, vendingMachineIconSize, vendingMachineIconAlpha, entity.transform);
}
}
}
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);
}
}
#endregion
#region PlayerData
void LoadData() {
try {
data = Interface.GetMod().DataFileSystem.ReadObject<DataStorage>("RustMap/MapPlayerData");
}
catch {
data = new DataStorage();
}
}
private void PlayerSaveData() {
MapPlayerData.WriteObject(data);
}
class DataStorage {
public Dictionary<ulong, MAPDATA> MapPlayerData = new Dictionary<ulong, MAPDATA>();
public DataStorage() {
}
}
class MAPDATA {
public string Name;
public bool Homes;
public bool Friends;
public bool Clans;
public bool Death;
public bool AllPlayers;
public bool BanPlayers;
}
DataStorage data;
private DynamicConfigFile MapPlayerData;
#endregion
#region Core
void OpenMap(BasePlayer player) {
if (!init || player == null) {
SendReply(player, "Извините! В данный момент карта не активирована");
return;
}
if (CloseMapTimer != null) timer.Destroy(ref CloseMapTimer);
CuiHelper.AddUi(player, mapJson);
CuiHelper.AddUi(player, monumentsJson);
foreach (var mm in temporaryMarkers) DrawMapMarker(player, mm);
List<ulong> members = new List<ulong>();
if (PermissionService.HasPermission(player.userID, MARKER_BANNED_PERM)) {
if (data.MapPlayerData[player.userID].BanPlayers == true) {
foreach(var mm in bannedMarkers.Values) DrawMapMarker(player, mm);
}
}
if (data.MapPlayerData[player.userID].AllPlayers == true) {
mapPlayers[player].clanTeam = BasePlayer.activePlayerList.Where(p => p != player).Select(MapPlayer.Create).ToList();
}
else {
mapPlayers[player].clanTeam = new List<MapPlayer>();
if (clanSupport) {
if (data.MapPlayerData[player.userID].Clans == true) {
var clanmates = Clans.Call("GetClanMembers", player.userID);
if (clanmates != null) members.AddRange(clanmates as List<ulong>);
}
}
if (friendsSupport) {
if (data.MapPlayerData[player.userID].Friends == true) {
var friends = Friends?.Call("GetFriends", player.userID);
if (friends != null) members.AddRange(friends as ulong[]);
var classes = PlayersClasses?.Call("GetPlayers", player.userID);
if (classes != null) members.AddRange(classes as List<ulong>);
var MutualFr = MutualPermission?.Call("GetFriends", player.userID) as ulong[];
if (MutualFr != null) members.AddRange(MutualFr as ulong[]);
}
}
else {
}
}
var homes = GetHomes(player);
if (sethome && homes != null) foreach (var home in homes) {
var anchors = ToAnchors(home.Value, sethomeIconSize);
if (data.MapPlayerData[player.userID].Homes == true) {
DrawIconNull(player, "sethome" + home.Key, "sethome" + home.Key, anchors, images["sethome"], 0.95f, $"Дом: \"{home.Key}\"", 8, false);
}
}
if (quarry && CustomQuarry != null) {
var playerQuarries = GetPlayerQuarries(player.userID);
if (playerQuarries != null) {
foreach (var quarry in playerQuarries) {
var anchors = ToAnchors(quarry.Key, quarryIconSize);
DrawIconNull(player, "quarry" + quarry.Value, "quarry" + quarry.Value, anchors, images["quarry"], 0.95f, "Топливо: " + quarry.Value, 2, false);
}
}
}
if (members != null && members.Count > 0) {
var onlineMembers = BasePlayer.activePlayerList.Where(p => members.Contains(p.userID) && p != player).ToList();
mapPlayers[player].clanTeam.AddRange(onlineMembers.Select(MapPlayer.Create).ToList());
}
if (raidhomes) {
var zones = GetRaidZones(player);
if (zones != null) foreach (var zone in zones) {
var anchors = ToAnchors(zone, raidhomeSIze);
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(), deathIconSize);
DrawIconNull(player, "death" + player.userID, "death" + player.userID, anchors, images["death"], 0.95f, $"Ты умер здесь", 10, false);
}
}
subscribers[player] = mapPlayers[player];
RedrawPlayers(mapPlayers[player]);
CloseMapTimer = timer.Once(TimeToClose, () => {
if (player == null) return;
CloseMap(player);
}
);
}
private Dictionary<ulong, string> playerDic = new Dictionary<ulong, string>();
private object OnPlayerDie(BasePlayer player, HitInfo info) {
if (!permission.UserHasPermission(player.UserIDString, MAP_DEATH)) return null;
if (playerDic.ContainsKey(player.userID)) {
playerDic.Remove(player.userID);
}
playerDic.Add(player.userID, player.transform.position.ToString());
return null;
}
[PluginReference]
Plugin NoEscape;
List<Vector3> GetRaidZones(BasePlayer player) {
return (List<Vector3>)NoEscape?.Call("ApiGetOwnerRaidZones", player.userID);
}
void OnPlayerDisconnected(BasePlayer player, string reason) {
subscribers.Remove(player);
mapPlayers.Remove(player);
foreach (var sub in mapPlayers) {
var toRemove = sub.Value.clanTeam.Where(p => p.player == player).ToList();
foreach (var teammate in toRemove) {
CuiHelper.DestroyUi(sub.Key, teammate.name + teammate.counter);
CuiHelper.DestroyUi(sub.Key, teammate.name + teammate.counter + "text");
}
toRemove.ForEach(p => sub.Value.clanTeam.Remove(p));
}
}
void RedrawPlayers(MapPlayer mapPlayer) {
var player = mapPlayer.player;
if (mapPlayer.clanTeam != null) {
foreach (var tmMapPlayer in mapPlayer.clanTeam) {
DrawMapPlayer(player, tmMapPlayer, true);
}
}
DrawMapPlayer(player, mapPlayer);
}
// HOME
void CloseMap(BasePlayer player) {
if (CloseMapTimer != null) timer.Destroy(ref CloseMapTimer);
subscribers.Remove(player);
mapPlayers[player].OnCloseMap();
CuiHelper.DestroyUi(player, "map_mainImage");
}
void DrawMapPlayer(BasePlayer player, MapPlayer mp, bool friend = false) {
if (mp.Ne
// ... [Code preview truncated due to length. Full source in attached file] ...