C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
//#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using UnityEngine;
namespace Oxide.Plugins {
[Info("Admin Radar", "nivex", "5.0.1")]
[Description("Radar tool for Admins and Developers.")]
class AdminRadar : RustPlugin {
[PluginReference]
private Plugin Vanish;
private const string permAllowed = "adminradar.allowed";
private const string permBypass = "adminradar.bypass";
private const string permAuto = "adminradar.auto";
private const string permBypassOverride = "adminradar.bypass.override";
private const string genericPrefab = "assets/prefabs/tools/map/genericradiusmarker.prefab";
private const string vendingPrefab = "assets/prefabs/deployable/vendingmachine/vending_mapmarker.prefab";
private const float flickerDelay = 0.05f;
private static AdminRadar ins;
private StoredData storedData = new StoredData();
private bool init;
// don't use cache while false
private static bool isUnloading;
private static readonly List<string> tags = new List<string> {
"ore", "cluster", "1", "2", "3", "4", "5", "6", "_", ".", "-", "deployed", "wooden", "large", "pile", "prefab", "collectable", "loot", "small"
}
;
// strip these from names to reduce the size of the text and make it more readable
private readonly Dictionary<ulong, Color> playersColor = new Dictionary<ulong, Color>();
private readonly List<BasePlayer> accessList = new List<BasePlayer>();
private readonly Dictionary<ulong, Timer> voices = new Dictionary<ulong, Timer>();
private static readonly List<Radar> activeRadars = new List<Radar>();
private readonly List<string> warnings = new List<string>();
private static readonly Dictionary<ulong, float> cooldowns = new Dictionary<ulong, float>();
private static Cache cache = new Cache();
private Coroutine coroutine;
private const bool True = true;
private const bool False = false;
public enum CupboardAction {
Authorize, Clear, Deauthorize
}
private class Cache {
public readonly HashSet<BaseNpc> Animals = new HashSet<BaseNpc>();
public readonly HashSet<BaseEntity> CargoPlanes = new HashSet<BaseEntity>();
public readonly HashSet<DroppedItemContainer> Backpacks = new HashSet<DroppedItemContainer>();
public readonly Dictionary<Vector3, CachedInfo> Bags = new Dictionary<Vector3, CachedInfo>();
public readonly HashSet<BaseEntity> Boats = new HashSet<BaseEntity>();
public readonly HashSet<BradleyAPC> BradleyAPCs = new HashSet<BradleyAPC>();
public readonly HashSet<BaseEntity> CargoShips = new HashSet<BaseEntity>();
public readonly HashSet<BaseEntity> Cars = new HashSet<BaseEntity>();
public readonly HashSet<BaseEntity> CH47 = new HashSet<BaseEntity>();
public readonly HashSet<BuildingPrivlidge> Cupboards = new HashSet<BuildingPrivlidge>();
public readonly Dictionary<Vector3, CachedInfo> Collectibles = new Dictionary<Vector3, CachedInfo>();
public readonly HashSet<StorageContainer> Containers = new HashSet<StorageContainer>();
public readonly Dictionary<PlayerCorpse, CachedInfo> Corpses = new Dictionary<PlayerCorpse, CachedInfo>();
public readonly HashSet<BaseHelicopter> Helicopters = new HashSet<BaseHelicopter>();
public readonly HashSet<BaseEntity> MiniCopter = new HashSet<BaseEntity>();
public readonly HashSet<BasePlayer> NPCPlayers = new HashSet<BasePlayer>();
public readonly Dictionary<Vector3, CachedInfo> Ores = new Dictionary<Vector3, CachedInfo>();
public readonly HashSet<BaseEntity> RHIB = new HashSet<BaseEntity>();
public readonly HashSet<BaseEntity> RidableHorse = new HashSet<BaseEntity>();
public readonly HashSet<SupplyDrop> SupplyDrops = new HashSet<SupplyDrop>();
public readonly HashSet<AutoTurret> Turrets = new HashSet<AutoTurret>();
public readonly HashSet<Zombie> Zombies = new HashSet<Zombie>();
}
private class StoredData {
public readonly List<string> Extended = new List<string>();
public readonly Dictionary<string, List<string>> Filters = new Dictionary<string, List<string>>();
public readonly List<string> Hidden = new List<string>();
public readonly List<string> OnlineBoxes = new List<string>();
public readonly List<string> Visions = new List<string>();
public StoredData() {
}
}
private class CachedInfo {
public object Info;
public string Name;
public float Size;
}
public enum EntityType {
Active, Airdrops, Animals, Bags, Backpacks, Boats, Bradley, Cars, CargoPlanes, CargoShips, CH47Helicopters, Containers, Collectibles, Cupboards, CupboardsArrow, Dead, GroupLimit, Heli, MiniCopter, Npc, Ore, RidableHorses, RigidHullInflatableBoats, Sleepers, Source, Turrets, Zombies
}
private class Radar : FacepunchBehaviour {
WaitForSecondsRealtime _cachedWaitForSecondsRealtime;
private int drawnObjects;
private EntityType entityType;
private int _inactiveSeconds;
private int activeSeconds;
private float _invokeTime;
public float invokeTime {
get {
return _invokeTime;
}
set {
_cachedWaitForSecondsRealtime = new WaitForSecondsRealtime(value);
_invokeTime = value;
}
}
public float maxDistance;
public BasePlayer player;
private Vector3 position;
private float currDistance;
private bool setSource = True;
public bool showBags;
public bool showBoats;
public bool showBox;
public bool showBradley;
public bool showCars;
public bool showCargoPlanes;
public bool showCargoShips;
public bool showCH47;
public bool showCollectible;
public bool showDead;
public bool showHeli;
public bool showHT;
public bool showLoot;
public bool showMiniCopter;
public bool showNPC;
public bool showOre;
public bool showRidableHorses;
public bool showRHIB;
public bool showSleepers;
public bool showStash;
public bool showTC;
public bool showTCArrow;
public bool showTurrets;
public bool showAll;
private BaseEntity source;
private DateTime tick;
private StringBuilder _cachedStringBuilder = new StringBuilder();
private class Ping {
public int AveragePing;
public float Time;
}
private class PrivInfo {
public float ProtectedMinutes;
public float LastTime = float.MaxValue;
public PrivInfo() {
}
}
private Dictionary<BuildingPrivlidge, PrivInfo> tcs;
private Dictionary<ulong, Ping> pings;
private Dictionary<int, List<BasePlayer>> groupedPlayers;
private List<BasePlayer> nearbyPlayers;
private List<BasePlayer> distantPlayers;
private List<BasePlayer> removePlayers;
private bool limitFlag;
private int limitIndex;
private void Awake() {
removePlayers = new List<BasePlayer>();
groupedPlayers = new Dictionary<int, List<BasePlayer>>();
nearbyPlayers = new List<BasePlayer>();
distantPlayers = new List<BasePlayer>();
tcs = new Dictionary<BuildingPrivlidge, PrivInfo>();
pings = new Dictionary<ulong, Ping>();
activeRadars.Add(this);
if (activeRadars.Count == 1 && (blockDamageAnimals || blockDamageBuildings || blockDamageNpcs || blockDamagePlayers || blockDamageOther)) {
ins.Subscribe(nameof(OnEntityTakeDamage));
}
player = GetComponent<BasePlayer>();
source = player;
position = player.transform.position;
if (inactiveSeconds > 0f || inactiveMinutes > 0) {
InvokeRepeating(Activity, 0f, 1f);
}
}
public void Start() {
CancelInvoke(DoRadar);
Invoke(DoRadar, invokeTime);
InvokeRepeating(DoRadar, 0f, invokeTime);
}
private void OnDestroy() {
StopAllCoroutines();
nearbyPlayers.Clear();
groupedPlayers.Clear();
distantPlayers.Clear();
tcs.Clear();
pings.Clear();
if (radarUI.Contains(player.UserIDString)) ins.DestroyUI(player);
if (inactiveSeconds > 0 || inactiveMinutes > 0) CancelInvoke(Activity);
CancelInvoke(DoRadar);
activeRadars.Remove(this);
if (activeRadars.Count == 0 && !isUnloading) ins.Unsubscribe(nameof(OnEntityTakeDamage));
if (player != null && player.IsConnected) {
if (coolDown > 0f) {
if (!cooldowns.ContainsKey(player.userID)) cooldowns.Add(player.userID, Time.realtimeSinceStartup + coolDown);
else cooldowns[player.userID] = Time.realtimeSinceStartup + coolDown;
}
player.ChatMessage(ins.msg("Deactivated", player.UserIDString));
}
Destroy(this);
}
public bool GetBool(string value) {
switch (value) {
case "All" : return showAll;
case "Bags" : return showBags;
case "Boats" : return showBoats;
case "Box" : return showBox;
case "Bradley" : return showBradley;
case "CargoPlanes" : return showCargoPlanes;
case "CargoShips" : return showCargoShips;
case "Cars" : return showCars;
case "CH47" : return showCH47;
case "Collectibles" : return showCollectible;
case "Dead" : return showDead;
case "Heli" : return showHeli;
case "Loot" : return showLoot;
case "MiniCopter" : return showMiniCopter;
case "NPC" : return showNPC;
case "Ore" : return showOre;
case "RidableHorses" : return showRidableHorses;
case "RHIB" : return showRHIB;
case "Sleepers" : return showSleepers;
case "Stash" : return showStash;
case "TCArrows" : return showTCArrow;
case "TC" : return showTC;
case "Turrets" : return showTurrets;
default : return False;
}
}
private bool LatencyAccepted() {
if (latencyMs > 0) {
double ms = (DateTime.Now - tick).TotalMilliseconds;
if (ms > latencyMs) {
player.ChatMessage(ins.msg("DoESP", player.UserIDString, ms, latencyMs));
return False;
}
}
return True;
}
private void Activity() {
if (source != player) {
_inactiveSeconds = 0;
return;
}
_inactiveSeconds = position == player.transform.position ? _inactiveSeconds + 1 : 0;
position = player.transform.position;
if (inactiveMinutes > 0 && ++activeSeconds / 60 > inactiveMinutes) Destroy(this);
else if (inactiveSeconds > 0 && _inactiveSeconds > inactiveSeconds) Destroy(this);
}
Coroutine _routine;
void StartRoutine() {
_routine = ServerMgr.Instance.StartCoroutine(DoRadarRoutine());
}
IEnumerator DoRadarRoutine() {
yield return _cachedWaitForSecondsRealtime;
}
private void DoRadar() {
tick = DateTime.Now;
bool isAdmin = player.IsAdmin;
try {
if (!player.IsConnected) {
Destroy(this);
return;
}
drawnObjects = 0;
if (!isAdmin && ins.permission.UserHasPermission(player.UserIDString, permAllowed)) {
player.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, True);
player.SendNetworkUpdateImmediate();
}
if (!SetSource()) return;
if (!ShowActive()) return;
if (!ShowSleepers()) return;
if (barebonesMode) return;
if (!ShowEntity(EntityType.Cars, showCars, "C", cache.Cars)) return;
if (!ShowEntity(EntityType.CargoPlanes, showCargoPlanes, "CP", cache.CargoPlanes)) return;
if (!ShowEntity(EntityType.CargoShips, showCargoShips, "CS", cache.CargoShips)) return;
if (!ShowHeli()) return;
if (!ShowBradley()) return;
if (!ShowLimits()) return;
if (!ShowTC()) return;
if (!ShowContainers()) return;
if (!ShowBags()) return;
if (!ShowTurrets()) return;
if (!ShowDead()) return;
if (!ShowNPC()) return;
if (!ShowOre()) return;
if (!ShowEntity(EntityType.CH47Helicopters, showCH47, "CH47", cache.CH47)) return;
if (!ShowEntity(EntityType.RigidHullInflatableBoats, showRHIB, "RHIB", cache.RHIB)) return;
if (!ShowEntity(EntityType.Boats, showBoats, "RB", cache.Boats)) return;
if (!ShowEntity(EntityType.MiniCopter, showMiniCopter, "MC", cache.MiniCopter)) return;
if (!ShowEntity(EntityType.RidableHorses, showRidableHorses, "RH", cache.RidableHorse)) return;
ShowCollectables();
}
catch (Exception ex) {
ins.Puts("Error @{0}: {1} --- {2}", Enum.GetName(typeof(EntityType), entityType), ex.Message, ex.StackTrace);
player.ChatMessage(ins.msg("Exception", player.UserIDString));
switch (entityType) {
case EntityType.Active : {
trackActive = False;
}
break;
case EntityType.Airdrops : {
trackSupplyDrops = False;
cache.SupplyDrops.Clear();
}
break;
case EntityType.Animals : case EntityType.Npc : case EntityType.Zombies : {
trackNPC = False;
showNPC = False;
uiBtnNPC = False;
cache.Animals.Clear();
cache.Zombies.Clear();
cache.NPCPlayers.Clear();
}
break;
case EntityType.Bags : {
trackBags = False;
showBags = False;
uiBtnBags = False;
cache.Bags.Clear();
}
break;
case EntityType.Backpacks : {
trackLoot = False;
showLoot = False;
uiBtnLoot = False;
cache.Backpacks.Clear();
}
break;
case EntityType.Bradley : {
showBradley = False;
uiBtnBradley = False;
trackBradley = False;
cache.BradleyAPCs.Clear();
}
break;
case EntityType.Cars : {
showCars = False;
uiBtnCars = False;
trackCars = False;
cache.Cars.Clear();
}
break;
case EntityType.CargoPlanes : {
uiBtnCargoPlanes = False;
trackCargoPlanes = False;
showCargoPlanes = False;
cache.CargoPlanes.Clear();
}
break;
case EntityType.CargoShips : {
trackCargoShips = False;
showCargoShips = False;
uiBtnCargoShips = False;
cache.CargoShips.Clear();
}
break;
case EntityType.CH47Helicopters : {
showCH47 = False;
uiBtnCH47 = False;
trackCH47 = False;
cache.CH47.Clear();
}
break;
case EntityType.Containers : {
showBox = False;
showLoot = False;
showStash = False;
uiBtnBox = False;
uiBtnLoot = False;
uiBtnStash = False;
trackBox = False;
trackLoot = False;
trackStash = False;
cache.Containers.Clear();
}
break;
case EntityType.Collectibles : {
trackCollectibles = False;
showCollectible = False;
uiBtnCollectible = False;
cache.Collectibles.Clear();
}
break;
case EntityType.Cupboards : {
trackTC = False;
showTC = False;
uiBtnTC = False;
cache.Cupboards.Clear();
}
break;
case EntityType.CupboardsArrow : {
showTCArrow = False;
uiBtnTCArrow = False;
}
break;
case EntityType.Dead : {
trackDead = False;
showDead = False;
uiBtnDead = False;
cache.Corpses.Clear();
}
break;
case EntityType.GroupLimit : {
drawX = False;
}
break;
case EntityType.Heli : {
showHeli = False;
uiBtnHeli = False;
trackHeli = False;
cache.Helicopters.Clear();
}
break;
case EntityType.MiniCopter : {
showMiniCopter = False;
uiBtnMiniCopter = False;
trackMiniCopter = False;
cache.MiniCopter.Clear();
}
break;
case EntityType.Ore : {
trackOre = False;
showOre = False;
uiBtnOre = False;
cache.Ores.Clear();
}
break;
case EntityType.RidableHorses : {
showRidableHorses = False;
uiBtnRidableHorses = False;
trackRidableHorses = False;
cache.RidableHorse.Clear();
}
break;
case EntityType.RigidHullInflatableBoats : {
showRHIB = False;
uiBtnRHIB = False;
trackRigidHullInflatableBoats = False;
cache.RHIB.Clear();
}
break;
case EntityType.Boats : {
showBoats = False;
uiBtnBoats = False;
trackBoats = False;
cache.Boats.Clear();
}
break;
case EntityType.Sleepers : {
trackSleepers = False;
showSleepers = False;
uiBtnSleepers = False;
}
break;
case EntityType.Source : {
setSource = False;
}
break;
case EntityType.Turrets : {
trackTurrets = False;
showTurrets = False;
uiBtnTurrets = False;
cache.Turrets.Clear();
}
break;
}
uiBtnNames = new string[0];
uiButtons = null;
}
finally {
if (!isAdmin && player.HasPlayerFlag(BasePlayer.PlayerFlags.IsAdmin)) {
player.SetPlayerFlag(BasePlayer.PlayerFlags.IsAdmin, False);
player.SendNetworkUpdateImmediate();
}
if (!LatencyAccepted()) {
double ms = (DateTime.Now - tick).TotalMilliseconds;
string message = ins.msg("DoESP", player.UserIDString, ms, latencyMs);
ins.Puts("{0} for {1} ({2})", message, player.displayName, player.UserIDString);
enabled = false;
Destroy(this);
}
}
}
private Vector3 GetNearestCupboard(BasePlayer target) {
var positions = new List<Vector3>();
float distance = 0f;
foreach (var tc in cache.Cupboards) {
if (tc.IsAuthed(target)) {
distance = (target.transform.position - tc.transform.position).magnitude;
if (distance >= 5f && distance <= tcArrowsDistance) {
positions.Add(tc.transform.position);
}
}
}
if (positions.Count == 0) {
return Vector3.zero;
}
if (positions.Count > 1) {
positions.Sort((x, y) => ((x - target.transform.position).magnitude).CompareTo(((y - target.transform.position).magnitude)));
}
return positions[0];
}
private int GetAveragePing(BasePlayer target) {
Ping ping;
if (!pings.TryGetValue(target.userID, out ping)) {
pings[target.userID] = ping = new Ping();
}
if (ping.Time == 0f || Time.realtimeSinceStartup - ping.Time >= averagePingInterval) {
ping.Time = Time.realtimeSinceStartup;
ping.AveragePing = Network.Net.sv.GetAveragePing(target.Connection);
}
return ping.AveragePing;
}
private bool IsLetters(string value) {
if (string.IsNullOrEmpty(value)) {
return False;
}
foreach (char c in value) {
if (!char.IsLetter(c)) {
return False;
}
}
return True;
}
private bool IsNumeric(string value) {
if (string.IsNullOrEmpty(value)) {
return False;
}
foreach (char c in value) {
if (!char.IsDigit(c)) {
return False;
}
}
return True;
}
private bool SetSource() {
if (!setSource) {
source = player;
return True;
}
entityType = EntityType.Source;
source = player;
if (player.IsSpectating()) {
var parentEntity = player.GetParentEntity();
if (parentEntity as BasePlayer != null) {
var target = parentEntity as BasePlayer;
if (target.IsDead() && !target.IsConnected) player.StopSpectating();
else source = parentEntity;
}
}
if (player == source && (player.IsDead() || player.IsSleeping() || player.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot))) return False;
return True;
}
private void DrawVision(BasePlayer target) {
RaycastHit hit;
if (Physics.Raycast(target.eyes.HeadRay(), out hit, Mathf.Infinity)) {
DrawArrow(Color.red, target.eyes.position + new Vector3(0f, 0.115f, 0f), hit.point, 0.15f, true);
}
}
private void DrawArrow(Color color, Vector3 from, Vector3 to, float size, bool bypass) {
if (drawArrows || bypass) player.SendConsoleCommand("ddraw.arrow", invokeTime + flickerDelay, color, from, to, size);
}
private void DrawText(Color color, Vector3 position, string text, bool @override = false) {
if (drawText || @override) player.SendConsoleCommand("ddraw.text", invokeTime + flickerDelay, color, position, text);
}
private void DrawBox(Color color, Vector3 position, float size, bool @override = false) {
if (drawBox || @override) player.SendConsoleCommand("ddraw.box", invokeTime + flickerDelay, color, position, size);
}
private bool ShowActive() {
if (!trackActive) return True;
entityType = EntityType.Active;
Color color;
foreach (var target in BasePlayer.activePlayerList) {
if (target == null || target.transform == null || !target.IsConnected) {
continue;
}
currDistance = (target.transform.position - source.transform.position).magnitude;
if (player == target || currDistance > maxDistance) {
continue;
}
if (ins.permission.UserHasPermission(target.UserIDString, permBypass) && !ins.permission.UserHasPermission(player.UserIDString, permBypassOverride)) {
continue;
}
color = __(target.IsAlive() ? activeCC : activeDeadCC);
if (currDistance < playerDistance) {
_cachedStringBuilder.Clear();
if (ins.storedData.Extended.Contains(player.UserIDString) && target.GetActiveItem() != null) {
_cachedStringBuilder.Append(target.GetActiveItem().info.displayName.translated);
var itemList = target.GetActiveItem().contents?.itemList;
if (itemList?.Count > 0) {
_cachedStringBuilder.Append(" (");
for (int index = 0; index < itemList.Count; index++) {
_cachedStringBuilder.Append(itemList[index].info.displayName.translated).Append("|");
}
_cachedStringBuilder.Replace("Weapon ", "");
_cachedStringBuilder.Replace("Simple Handmade ", "");
_cachedStringBuilder.Replace("Muzzle ", "");
_cachedStringBuilder.Replace("4x Zoom Scope", "4x");
_cachedStringBuilder.Append(")");
}
}
string vanished = ins.Vanish != null && ins.Vanish.Call<bool>("IsInvisible", target) ? "<color=#FF00FF>V</color>" : string.Empty;
string health = showHT && target.metabolism != null ? string.Format("{0} <color=#FFA500>{1}</color>:<color=#FFADD8E6>{2}</color>", Math.Floor(target.health), target.metabolism.calories.value.ToString("#0"), target.metabolism.hydration.value.ToString("#0")) : Math.Floor(target.health).ToString("#0");
if (averagePingInterval > 0) _cachedStringBuilder.Append(" ").Append(GetAveragePing(target)).Append("ms");
if (ins.storedData.Visions.Contains(player.UserIDString)) DrawVision(target);
DrawArrow(__(colorDrawArrows), target.transform.position + new Vector3(0f, target.transform.position.y + 10), target.transform.position, 1, false);
DrawText(color, target.transform.position + new Vector3(0f, 2f, 0f), string.Format("{0} <color={1}>{2}</color> <color={3}>{4}</color>{5} {6}", ins.RemoveFormatting(target.displayName) ?? target.userID.ToString(), healthCC, health, distCC, currDistance.ToString("0"), vanished, _cachedStringBuilder.ToString()));
DrawBox(color, target.transform.position + new Vector3(0f, 1f, 0f), target.GetHeight(target.modelState.ducked));
if (ins.voices.ContainsKey(target.userID) && (target.transform.position - player.transform.position).magnitude <= voiceDistance) {
DrawArrow(Color.yellow, target.transform.position + new Vector3(0f, 5f, 0f), target.transform.position + new Vector3(0f, 2.5f, 0f), 0.5f, true);
}
ShowCupboardArrows(target, EntityType.Active);
}
else if (drawX) distantPlayers.Add(target);
else DrawBox(color, target.transform.position + new Vector3(0f, 1f, 0f), 5f, true);
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
return LatencyAccepted();
}
private bool ShowSleepers() {
if (!showSleepers || !trackSleepers) return True;
entityType = EntityType.Sleepers;
Color color;
foreach (var sleeper in BasePlayer.sleepingPlayerList) {
if (sleeper == null || sleeper.transform == null) continue;
currDistance = (sleeper.transform.position - source.transform.position).magnitude;
if (currDistance > maxDistance) continue;
if (currDistance < playerDistance) {
string health = showHT && sleeper.metabolism != null ? string.Format("{0} <color=#FFA500>{1}</color>:<color=#FFADD8E6>{2}</color>", Math.Floor(sleeper.health), sleeper.metabolism.calories.value.ToString("#0"), sleeper.metabolism.hydration.value.ToString("#0")) : Math.Floor(sleeper.health).ToString("#0");
color = __(sleeper.IsAlive() ? sleeperCC : sleeperDeadCC);
DrawArrow(__(colorDrawArrows), sleeper.transform.position + new Vector3(0f, sleeper.transform.position.y + 10), sleeper.transform.position, 1, false);
DrawText(color, sleeper.transform.position, string.Format("{0} <color={1}>{2}</color> <color={3}>{4}</color>", ins.RemoveFormatting(sleeper.displayName) ?? sleeper.userID.ToString(), healthCC, health, distCC, currDistance.ToString("0")));
DrawText(color, sleeper.transform.position + new Vector3(0f, 1f, 0f), "X", drawX);
if (!drawX && drawBox) DrawBox(color, sleeper.transform.position, GetScale(currDistance));
ShowCupboardArrows(sleeper, EntityType.Sleepers);
}
else DrawBox(Color.cyan, sleeper.transform.position + new Vector3(0f, 1f, 0f), 5f, true);
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
return LatencyAccepted();
}
private void ShowCupboardArrows(BasePlayer target, EntityType lastType) {
if (!barebonesMode && showTCArrow && uiBtnTCArrow && uiBtnTC) {
entityType = EntityType.CupboardsArrow;
var nearest = GetNearestCupboard(target);
if (nearest != Vector3.zero) {
DrawArrow(__(tcCC), target.transform.position + new Vector3(0f, 0.115f, 0f), nearest, 0.25f, true);
}
entityType = lastType;
}
}
private bool ShowHeli() {
if (!showHeli || (!trackHeli && !uiBtnHeli)) return True;
entityType = EntityType.Heli;
if (cache.Helicopters.Count > 0) {
foreach (var heli in cache.Helicopters) {
if (heli == null || heli.transform == null || heli.IsDestroyed) continue;
currDistance = (heli.transform.position - source.transform.position).magnitude;
string heliHealth = heli.health > 1000 ? Math.Floor(heli.health).ToString("#,##0,K", CultureInfo.InvariantCulture) : Math.Floor(heli.health).ToString("#0");
string info = showHeliRotorHealth ? string.Format("<color={0}>{1}</color> (<color=#FFFF00>{2}</color>/<color=#FFFF00>{3}</color>)", healthCC, heliHealth, Math.Floor(heli.weakspots[0].health), Math.Floor(heli.weakspots[1].health)) : string.Format("<color={0}>{1}</color>", healthCC, heliHealth);
DrawText(__(heliCC), heli.transform.position + new Vector3(0f, 2f, 0f), string.Format("H {0} <color={1}>{2}</color>", info, distCC, currDistance.ToString("0")));
DrawBox(__(heliCC), heli.transform.position + new Vector3(0f, 1f, 0f), GetScale(currDistance));
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
}
return LatencyAccepted();
}
private bool ShowBradley() {
if (!showBradley || (!uiBtnBradley && !trackBradley)) return True;
entityType = EntityType.Bradley;
if (cache.BradleyAPCs.Count > 0) {
foreach (var bradley in cache.BradleyAPCs) {
if (bradley == null || bradley.transform == null || bradley.IsDestroyed) continue;
currDistance = (bradley.transform.position - source.transform.position).magnitude;
string info = string.Format("<color={0}>{1}</color>", healthCC, bradley.health > 1000 ? Math.Floor(bradley.health).ToString("#,##0,K", CultureInfo.InvariantCulture) : Math.Floor(bradley.health).ToString());
DrawText(__(bradleyCC), bradley.transform.position + new Vector3(0f, 2f, 0f), string.Format("B {0} <color={1}>{2}</color>", info, distCC, currDistance.ToString("0")));
DrawBox(__(bradleyCC), bradley.transform.position + new Vector3(0f, 1f, 0f), GetScale(currDistance));
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
}
return LatencyAccepted();
}
bool ShowLimits() {
entityType = EntityType.GroupLimit;
if (!drawX) {
return True;
}
distantPlayers.RemoveAll(p => p == null || p.transform == null);
if (distantPlayers.Count == 0) {
return True;
}
limitIndex = 0;
limitFlag = False;
foreach(var p in distantPlayers) {
nearbyPlayers.Clear();
for (int j = 0; j < distantPlayers.Count; j++) {
if ((distantPlayers[j].transform.position - p.transform.position).magnitude < groupRange) {
limitFlag = False;
for (int i = 0; i < groupedPlayers.Values.Count; i++) {
if (groupedPlayers[i].Contains(distantPlayers[j])) {
limitFlag = True;
break;
}
}
if (!limitFlag) {
nearbyPlayers.Add(distantPlayers[j]);
}
}
}
if (nearbyPlayers.Count > groupLimit) {
while (groupedPlayers.ContainsKey(limitIndex)) limitIndex++;
groupedPlayers.Add(limitIndex, nearbyPlayers.ToList());
removePlayers.AddRange(nearbyPlayers);
}
}
distantPlayers.RemoveAll(player => removePlayers.Contains(player));
for (int j = 0; j < distantPlayers.Count; j++) {
DrawText(distantPlayers[j].IsAlive() ? Color.green : Color.red, distantPlayers[j].transform.position + new Vector3(0f, 1f, 0f), "X", true);
}
for (int j = 0; j < groupedPlayers.Count; j++) {
for (int k = 0; k < groupedPlayers[j].Count; k++) {
if (groupCountHeight != 0f && k == 0) {
DrawText(Color.magenta, groupedPlayers[j][k].transform.position + new Vector3(0f, groupCountHeight, 0f), groupedPlayers[j].Count.ToString(), true);
}
DrawText(__(groupedPlayers[j][k].IsAlive() ? GetGroupColor(j) : groupColorDead), groupedPlayers[j][k].transform.position + new Vector3(0f, 1f, 0f), "X", true);
}
}
nearbyPlayers.Clear();
groupedPlayers.Clear();
distantPlayers.Clear();
removePlayers.Clear();
return LatencyAccepted();
}
private bool ShowTC() {
if (!showTC || !trackTC) return True;
entityType = EntityType.Cupboards;
int bags;
float time;
foreach (var tc in cache.Cupboards) {
if (tc == null || tc.transform == null || tc.IsDestroyed) {
tcs.Remove(tc);
continue;
}
currDistance = (tc.transform.position - source.transform.position).magnitude;
if (currDistance < tcDistance && currDistance < maxDistance) {
if (drawText) {
bags = 0;
if (showTCBagCount) {
var building = tc.GetBuilding();
if (building != null) {
foreach (var entity in building.decayEntities) {
if (entity is SleepingBag) {
bags++;
}
}
}
}
if (!tcs.ContainsKey(tc)) {
tcs.Add(tc, new PrivInfo());
}
time = Time.realtimeSinceStartup;
if (tcs[tc].LastTime == float.MaxValue || time - tcs[tc].LastTime > 60) {
tcs[tc].ProtectedMinutes = tc.GetProtectedMinutes();
tcs[tc].LastTime = time;
}
string text = string.Empty;
if (bags > 0 && showTCAuthedCount) text = string.Format("TC <color={0}>{1}</color> <color={2}>{3}</color> <color={4}>{5}</color> <color={0}>{6}</color>", distCC, currDistance, bagCC, bags, tcCC, tc.authorizedPlayers.Count, tcs[tc].ProtectedMinutes);
else if (bags > 0) text = string.Format("TC <color={0}>{1}</color> <color={2}>{3}</color> <color={0}>{4}</color>", distCC, currDistance, bagCC, bags, tcs[tc].ProtectedMinutes);
else if (showTCAuthedCount) text = string.Format("TC <color={0}>{1}</color> <color={2}>{3}</color> <color={0}>{4}</color>", distCC, currDistance, tcCC, tc.authorizedPlayers.Count, tcs[tc].ProtectedMinutes);
else text = string.Format("TC <color={0}>{1} {2}</color>", distCC, currDistance, tcs[tc].ProtectedMinutes);
DrawText(__(tcCC), tc.transform.position + new Vector3(0f, 0.5f, 0f), text, true);
}
DrawBox(__(tcCC), tc.transform.position + new Vector3(0f, 0.5f, 0f), 3f);
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
}
return LatencyAccepted();
}
private bool ShowContainers() {
if (!showBox && !showLoot && !showStash) {
return True;
}
bool isBox;
bool isLoot;
if (showLoot) {
entityType = EntityType.Backpacks;
foreach (var backpack in cache.Backpacks) {
if (backpack == null || backpack.transform == null || backpack.IsDestroyed) continue;
currDistance = (backpack.transform.position - source.transform.position).magnitude;
if (currDistance > maxDistance || currDistance > lootDistance) continue;
DrawText(__(backpackCC), backpack.transform.position + new Vector3(0f, 0.5f, 0f), string.Format("{0} {1}<color={2}>{3}</color>", string.IsNullOrEmpty(backpack._playerName) ? ins.msg("backpack", player.UserIDString) : backpack._playerName, GetContents(backpack), distCC, currDistance.ToString("0")));
DrawBox(__(backpackCC), backpack.transform.position + new Vector3(0f, 0.5f, 0f), GetScale(currDistance));
if (objectsLimit > 0 && ++drawnObjects > objectsLimit) return False;
}
}
if (showBox && trackSupplyDrops) {
entityType = EntityType.Airdrops;
foreach (var drop in cache.SupplyDrops) {
if (drop == null || drop.transform == null || drop.IsDestroyed) continue;
currDistance = (drop.transform.position - source.transform.position).magnitude;
if (currDistance > maxDistance || currDistance > adDistance) continue;
string text = showAirdropContents && drop.inventory.itemList.Count > 0 ? GetContents(drop.inventory.itemList) : string.Format("({0}) ", drop.inventory.itemList.Count);
DrawText(__(airdropCC), drop.transform.position + new Vector3(0f, 0.5f, 0f), string.Format("{0} {1}<color={2}>{3}</color>", _(drop.ShortPrefabName), text, distCC, currDistance.ToString("0"), lootCC));
DrawBox(__(airdropCC), drop.transform.position + new Vector3(0f, 0.5f, 0f), GetScale(currDistance));
}
}
entityType = EntityType.Containers;
foreach (var container in cache.Containers) {
if (container == null || container.transform == null || container.IsDestroyed) continue;
currDistance = (container.transform.position - source.transform.position).magnitude;
if (currDistance > maxDistance) continue;
isBox = IsBox(container.ShortPrefabName);
isLoot = IsLoot(container.ShortPrefabName);
if (container is StashContainer) {
if (!showStash || currDistance > stashDistance || !trackStash) continue;
}
else if (isBox) {
if (!showBox || currDistance > boxDistance || !trackBox) continue;
}
else if (isLoot) {
if (!showLoot || currDistance > lootDistance || !trackLoot) continue;
}
string colorHex = isBox ? boxCC : isLoot ? lootCC : stashCC;
_cachedStringBuilder.Clear();
if (ins.storedData.OnlineBoxes.Contains(player.UserIDString) && container.OwnerID.IsSteamId() && (container.name.Contains("box") || container.name.Contains("coffin"))) {
var owner = BasePlayer.FindByID(container.OwnerID);
if (owner == null || !owner.IsConnected) {
continue;
}
}
// ... [Code preview truncated due to length. Full source in attached file] ...