C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
/*
* EULA
*
* From version 2.1.0 onward, you are allowed to modify the source code for **personal use only**.* You may **not** copy, merge, publish, distribute, sublicense, sell, or share copies or modifications
* of this software without the Developer's explicit consent.*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*
* Copyright Rediz © 2023 - 2025
* Contact: eric@legacystudio.com.ar
* Developers: Rediz (former Ryuk_)
*/
// unmodified
// Reference: Mono.Data.Sqlite
using System;
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;
using Newtonsoft.Json.Linq;
using System.Linq;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using Facepunch;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Oxide.Core.Libraries.Covalence;
using Oxide.Game.Rust.Libraries.Covalence;
using ProtoBuf;
using Graphics = System.Drawing.Graphics;
using UnityEngine.UI;
using Oxide.Game.Rust.Cui;
using Oxide.Core.Plugins;
using Rust;
using System.Globalization;
using System.Text;
using System.Collections;
using Random = UnityEngine.Random;
using Oxide.Core.Configuration;
using Facepunch.Extend;
using System.Text.RegularExpressions;
using System.Security.Policy;
using System.Reflection;
using System.Threading.Tasks;
using Network;
using System.Data;
using System.Text;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net;
using Mono.Data.Sqlite;
using MySql.Data.MySqlClient;
using System.Collections.Specialized;
using System.Threading;
using System.Collections.Concurrent;
namespace Oxide.Plugins {
[Info("Creative", "Ryuk_", "2.1.0")]
[Description("Build any bases and let your players do it too.Everyone has their own private PLOT.")]
public class Creative : RustPlugin {
#region Variables & Classes
[PluginReference]
Plugin Symmetry, NoEscape, ImageLibrary;
public class PlayerSettings {
public ulong ID {
get;
set;
}
public string CurrentMenu {
get;
set;
}
public bool IsMenuOpened {
get;
set;
}
public bool AutoEntity {
get;
set;
}
public bool FillBatteries {
get;
set;
}
public bool EntityStability {
get;
set;
}
public bool Noclip {
get;
set;
}
public bool GodMode {
get;
set;
}
public bool ChangeBGrade {
get;
set;
}
public bool InfiniteAmmo {
get;
set;
}
public bool BGradeHud {
get;
set;
}
public bool GTFO {
get;
set;
}
public bool Raid {
get;
set;
}
public bool PlayerOwnZone {
get;
set;
}
public bool AutoDoors {
get;
set;
}
public bool DoorOpenClose {
get;
set;
}
public bool CodeLockDoor {
get;
set;
}
public string DoorPrefab {
get;
set;
}
public string DoubleDoorPrefab {
get;
set;
}
public bool AutoWindows {
get;
set;
}
public string WindowPrefab {
get;
set;
}
public string EmbrasurePrefab {
get;
set;
}
public bool AutoElectricity {
get;
set;
}
public List<string> ElectricityList {
get;
set;
}
= new List<string>();
public bool BuildingGrade {
get;
set;
}
public int CurrentGrade {
get;
set;
}
public int CurrentSkin {
get;
set;
}
public int CurrentContainerSkin {
get;
set;
}
public bool PlayerInArea {
get;
set;
}
public bool BuildUpgradeInProgress {
get;
set;
}
public bool BGradeBackground {
get;
set;
}
public string CurrentBaseName {
get;
set;
}
public bool NetworkingFoundations {
get;
set;
}
public bool NetworkingFloor {
get;
set;
}
public bool NetworkingWalls {
get;
set;
}
public bool NetworkingOthers {
get;
set;
}
public bool NetworkingDeployables {
get;
set;
}
public bool LoadingBase {
get;
set;
}
public int CurrentPage {
get;
set;
}
public string CommunityCurrentMenu {
get;
set;
}
public Vector3 StoredClaimedPlotLocation {
get;
set;
}
public bool ClearingPlot {
get;
set;
}
public bool BCostHud {
get;
set;
}
= true;
public string PendingReviewBase {
get;
set;
}
public float PendingReviewTime {
get;
set;
}
public ulong PendingReviewSteamId {
get;
set;
}
public string PendingReviewImageUrl {
get;
set;
}
// public float PlotRadius { get; set; }
private float _plotRadius;
private bool _plotRadiusCached;
public bool doUpdateHud;
public PlayerSettings(ulong id) {
ID = id;
ResetSettings(id);
}
public void ResetSettings(ulong id) {
IsMenuOpened = false;
AutoEntity = false;
FillBatteries = false;
EntityStability = false;
Noclip = false;
GodMode = false;
ChangeBGrade = false;
InfiniteAmmo = false;
BGradeHud = false;
GTFO = false;
Raid = false;
PlayerOwnZone = false;
AutoDoors = false;
DoorOpenClose = false;
CodeLockDoor = false;
DoorPrefab = string.Empty;
DoubleDoorPrefab = string.Empty;
AutoWindows = false;
WindowPrefab = string.Empty;
EmbrasurePrefab = string.Empty;
AutoElectricity = false;
ElectricityList.Clear();
BuildingGrade = false;
CurrentGrade = 0;
CurrentSkin = 0;
CurrentContainerSkin = 0;
PlayerInArea = false;
BuildUpgradeInProgress = false;
BGradeBackground = false;
CurrentBaseName = string.Empty;
NetworkingFoundations = false;
NetworkingFloor = false;
NetworkingWalls = false;
NetworkingOthers = false;
NetworkingDeployables = false;
LoadingBase = false;
CurrentPage = 0;
CommunityCurrentMenu = string.Empty;
StoredClaimedPlotLocation = new Vector3();
ClearingPlot = false;
PendingReviewBase = null;
PendingReviewTime = 0;
PendingReviewSteamId = 0;
PendingReviewImageUrl = null;
_plotRadiusCached = false;
doUpdateHud = false;
//PlotRadius = Instance.permission.UserHasPermission(id.ToString(), "creative.vip") ? Instance._config.plot_radius_vip : Instance._config.plot_radius_default;
}
}
public class PlayerWeather {
public float wind {
get;
set;
}
public float rain {
get;
set;
}
public float thunder {
get;
set;
}
public float rainbow {
get;
set;
}
public float atmosphere_rayleigh {
get;
set;
}
public float atmosphere_mie {
get;
set;
}
public float atmosphere_brightness {
get;
set;
}
public float atmosphere_contrast {
get;
set;
}
public float atmosphere_directionality {
get;
set;
}
public float fog {
get;
set;
}
public float cloud_size {
get;
set;
}
public float cloud_opacity {
get;
set;
}
public float cloud_coverage {
get;
set;
}
public float cloud_sharpness {
get;
set;
}
public float cloud_coloring {
get;
set;
}
public float cloud_attenuation {
get;
set;
}
public float cloud_saturation {
get;
set;
}
public float cloud_scattering {
get;
set;
}
public float current_time {
get;
set;
}
public float value {
get;
set;
}
public PlayerWeather(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float b1, float b2, float b3, float b4, float b5, float b6, float b7, float b8, float b9, float c1, float c2) {
this.wind = a1;
this.rain = a2;
this.thunder = a3;
this.rainbow = a4;
this.atmosphere_rayleigh = a5;
this.atmosphere_mie = a6;
this.atmosphere_brightness = a7;
this.atmosphere_contrast = a8;
this.atmosphere_directionality = a9;
this.fog = b1;
this.cloud_size = b2;
this.cloud_opacity = b3;
this.cloud_coverage = b4;
this.cloud_sharpness = b5;
this.cloud_coloring = b6;
this.cloud_attenuation = b7;
this.cloud_saturation = b8;
this.cloud_scattering = b9;
this.current_time = c1;
this.value = c2;
}
}
private class ImageData {
[JsonProperty(PropertyName = "ImageName")]
public string name;
[JsonProperty(PropertyName = "ImgUrl")]
public string img;
}
public enum ItemContainerType {
Main, Belt, Wear
}
private class KitData {
[JsonProperty(PropertyName = "Item ID")]
public int id;
[JsonProperty(PropertyName = "Item Skin ID")]
public ulong skinid;
[JsonProperty(PropertyName = "Player Container Type (Main, Belt, Wear)")]
public ItemContainerType itemcontainer;
}
private class MySqlData {
[JsonProperty(PropertyName = "Server")]
public string server;
[JsonProperty(PropertyName = "Username")]
public string username;
[JsonProperty(PropertyName = "Password")]
public string password;
[JsonProperty(PropertyName = "Database")]
public string database;
[JsonProperty(PropertyName = "Port")]
public int port;
}
public class SpawnedEntityInfo {
public NetworkableId entityID;
public string entityName;
public SpawnedEntityInfo(NetworkableId id, string name) {
entityID = id;
entityName = name;
}
}
[Serializable]
public class PlotManagerData {
public ulong zoneID;
public Vector3 CenterZone;
public bool GTFO;
}
public class MarkerData {
public string MarkerID {
get;
set;
}
public string Text {
get;
set;
}
public Vector3 Position {
get;
set;
}
public float Radius {
get;
set;
}
public ulong OwnerID {
get;
set;
}
}
private class BaseShareInfo {
public string CreatorName {
get;
set;
}
public string SteamId {
get;
set;
}
public string BaseName {
get;
set;
}
public string ShareCode {
get;
set;
}
public int Likes {
get;
set;
}
public int Dislikes {
get;
set;
}
public int Downloads {
get;
set;
}
public string ImageUrl {
get;
set;
}
public string baseImageUrl {
get;
set;
}
}
public class PasteData {
public string Id {
get;
set;
}
public string Description {
get;
set;
}
public int Views {
get;
set;
}
public string CreatedAt {
get;
set;
}
}
public class PasteResponse2 {
public int CurrentPage {
get;
set;
}
public List<PasteData> Data {
get;
set;
}
public bool Success {
get;
set;
}
}
public static Creative Instance;
public Dictionary<ulong, PlayerSettings> playerSettings = new Dictionary<ulong, PlayerSettings>();
public Dictionary<ulong, PlayerWeather> playerWeather = new Dictionary<ulong, PlayerWeather>();
public Dictionary<ulong, PlotManager> activeZones = new Dictionary<ulong, PlotManager>();
private Dictionary<string, VendingMachineMapMarker> machineMarkers = new Dictionary<string, VendingMachineMapMarker>();
private Dictionary<string, MapMarkerGenericRadius> sphereMarker = new Dictionary<string, MapMarkerGenericRadius>();
private List<MarkerData> markerDataList = new List<MarkerData>();
private Dictionary<ulong, float> lastCommandTime = new Dictionary<ulong, float>();
public Dictionary<ulong, List<SpawnedEntityInfo>> playerEntityCount = new Dictionary<ulong, List<SpawnedEntityInfo>>();
private Dictionary<ulong, float> commandCooldowns = new Dictionary<ulong, float>();
private Dictionary<ulong, float> menuCooldown = new Dictionary<ulong, float>();
private Dictionary<ulong, float> baseCooldown = new Dictionary<ulong, float>();
private Dictionary<uint, IOEntity> oldToNewEntityIdMap = new Dictionary<uint, IOEntity>();
public List<StabilityEntity> EntStable = Facepunch.Pool.GetList<StabilityEntity>();
private Dictionary<ulong, Dictionary<string, List<BaseEntity>>> playerToggledEntities = new Dictionary<ulong, Dictionary<string, List<BaseEntity>>>();
private readonly Dictionary<BaseEntity, Collider[]> entityColliders = new Dictionary<BaseEntity, Collider[]>();
private static ConcurrentQueue<string> saveQueue = new ConcurrentQueue<string>();
private static Dictionary<string, QueuedSave> pendingSaves = new Dictionary<string, QueuedSave>();
private static Timer saveTimer;
private const int MaxBatchSaves = 5;
private class QueuedSave {
public string Key;
public string FilePath;
public JObject SaveData;
public string SaveName;
public ulong UserId;
public BasePlayer Player;
}
#endregion
#region Hooks
private void RegisterPermissions() {
permission.RegisterPermission("creative.admin", this);
permission.RegisterPermission("creative.reviewer", this);
permission.RegisterPermission("creative.use", this);
permission.RegisterPermission("creative.fly", this);
permission.RegisterPermission("creative.godmode", this);
permission.RegisterPermission("creative.infammo", this);
permission.RegisterPermission("creative.f1_give", this);
permission.RegisterPermission("creative.vehicle", this);
permission.RegisterPermission("creative.vip", this);
}
void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<string, string> {
["AutoSave"]
= "Autosaving bases.There will be some lag.", ["InvalidEntity"] = "Invalid entity.Please look at your base before save.", ["ErrorSaveBase"] = "There was a problem trying to save your base.", ["SuccesfullSaveBase"] = "You've successfully saved.", ["NoClaimed"] = "You don't have any claimed area.", ["Cooldown"] = "You are in cooldown.Please wait before using this command again.", ["NoPerms"] = "You do not have permission to use this command.", ["OwnArea"] = "You already own a claimed area.", ["ClaimTerrain"] = "You should be in the terrain before claim a zone.", ["AreaOverlap"] = "You cannot claim a zone here; It overlaps with an existing zone.", ["NotClaimed"] = "You should claim a zone before using this.", ["ExitZone"] = "You left the plot owned by: {0}", ["EnterZone"] = "You entered the plot owned by: {0}", ["Outside"] = "You can not take photos outside your claimed area!", ["PhotoCaptured"] = "Succesfully captured base '{0}' photo!", ["BaseUpdated"] = "Base '{0}' was updated!", ["TeamLeader"] = "Only the team leader can do this action.", ["SaveLimitReached"] = "You have reached the maximum base saving limit.", ["BuildOutsideArea"] = "You can't build outside your area", ["BuildingInProccess"] = "Building upgrade is already in progress.Please wait until it finishes", ["GTFOmsg"] = "You're not allowed to be in this zone!", ["Menu_Top_Claim"] = "CLAIM PLOT", ["Menu_Top_UnClaim"] = "UNCLAIM PLOT", ["Menu_Top_Weather"] = "WEATHER SETTINGS", ["Menu_Top_Build"] = "BUILD SETTINGS", ["Menu_Top_Community"] = "COMMUNITY", ["Menu_Top_RequestResources"] = "REQUEST RESOURCES", ["Menu_VehicleManager"] = "VEHICLE MANAGER", ["Menu_AutoDoors"] = "AUTO DOORS", ["Menu_AutoDoors_CloseOpen"] = "Close/Open Doors", ["Menu_AutoDoors_Locks"] = "Add Codelock to Doors", ["Menu_AutoWindows"] = "AUTO WINDOWS", ["Menu_AutoElectricity"] = "AUTO ELECTRICITY", ["Menu_BuildingGrade"] = "BUILDING GRADE", ["Menu_BaseGrade"] = "BASE GRADE", ["Menu_EntitySettings"] = "ENTITY SETTINGS", ["Menu_EntitySettings_Furnaces"] = "Enable Furnaces", ["Menu_EntitySettings_Batteries"] = "Fill Batteries", ["Menu_EntitySettings_Stability"] = "Entity Stability", ["Menu_PersonalSettings"] = "PERSONAL SETTINGS", ["Menu_PersonalSettings_Noclip"] = "Noclip", ["Menu_PersonalSettings_GodMode"] = "God Mode", ["Menu_PersonalSettings_CBG"] = "Change Build Grade", ["Menu_PersonalSettings_InfAmmo"] = "Infinite Ammo", ["Menu_PersonalSettings_UiHud"] = "UI/MENU Hud", ["Menu_PlotSettings"] = "PLOT SETTINGS", ["Menu_PlotSettings_GTFO"] = "GTFO Mode", ["Menu_PlotSettings_RAID"] = "RAID Mode", ["Menu_PlotSettings_WTF"] = "Wipe to Foundations", ["Menu_PlotSettings_WD"] = "Wipe Deployables", ["Menu_PlotSettings_CP"] = "Clear Plot", ["Menu_Networking"] = "NETWORKING", ["Menu_Networking_Foundations"] = "FOUNDATIONS", ["Menu_Networking_Floor"] = "FLOOR", ["Menu_Networking_Walls"] = "WALLS", ["Menu_Networking_OBB"] = "OTHER BUILDING BLOCKS", ["Menu_Networking_Deployables"] = "DEPLOYABLES",
}
, this);
lang.RegisterMessages(new Dictionary<string, string> {
["AutoSave"]
= "Autosaving bases.There will be some lag.", ["InvalidEntity"] = "Entidad invalida.Por favor mira a una construccion antes de guardar la base.", ["ErrorSaveBase"] = "Ocurrio un error guardando tu base.", ["SuccesfullSaveBase"] = "Base guardada!", ["NoClaimed"] = "No tienes un area reclamada!", ["Cooldown"] = "Por favor, espera para utilizar este comando nuevamente.", ["NoPerms"] = "No tienes permisos para utilizar este comando.", ["OwnArea"] = "Ya tienes un area reclamada!", ["ClaimTerrain"] = "Debes estar sobre el terreno para reclamar esta area.", ["AreaOverlap"] = "No puedes reclamar una zona aqui, esta colisiona con otra que ya existe!", ["NotClaimed"] = "Debes reclamar un area antes de usar esto.", ["ExitZone"] = "Has salido de la parcela de: {0}", ["EnterZone"] = "Has entrado en la parcela de: {0}", ["Outside"] = "No puedes tomar fotos fuera de tu parcela!", ["PhotoCaptured"] = "Se capturo exitosamente la foto de la base '{0}'!", ["BaseUpdated"] = "La Base '{0}' se ha actualizado!", ["TeamLeader"] = "Solo el lider del equipo puede hacer esta accion.", ["SaveLimitReached"] = "Haz llegado al limite maximo de guardado de bases.", ["BuildOutsideArea"] = "No puedes construir fuera de tu parcela!", ["BuildingInProccess"] = "La mejora de la construccion esta en proceso.Por favor espera a que termine.", ["GTFOmsg"] = "No tienes permisos para estar en esta parcela!", ["Menu_Top_Claim"] = "RECLAMAR PARCELA", ["Menu_Top_UnClaim"] = "UNCLAIM PLOT", ["Menu_Top_Weather"] = "AJUSTES DEL TIEMPO", ["Menu_Top_Build"] = "AJUSTES DE CONSTRUCCION", ["Menu_Top_Community"] = "COMUNIDAD", ["Menu_Top_RequestResources"] = "SOLICITAR RECURSOS", ["Menu_VehicleManager"] = "GESTOR DE VEHICULOS", ["Menu_AutoDoors"] = "PUERTAS AUTOMATICAS", ["Menu_AutoDoors_CloseOpen"] = "Cerrar/Abrir Puertas", ["Menu_AutoDoors_Locks"] = "Agregar candados", ["Menu_AutoWindows"] = "VENTANAS AUTOMATICAS", ["Menu_AutoElectricity"] = "ELECTRICIDAD AUTOMATICA", ["Menu_BuildingGrade"] = "GRADO DE CONSTRUCCION", ["Menu_BaseGrade"] = "GRADO DE LA BASE", ["Menu_EntitySettings"] = "AJUSTES DE ENTIDADES", ["Menu_EntitySettings_Furnaces"] = "Encender Hornos", ["Menu_EntitySettings_Batteries"] = "Rellenar Baterias", ["Menu_EntitySettings_Stability"] = "Estabilidad de Entidades", ["Menu_PersonalSettings"] = "AJUSTES PERSONALES", ["Menu_PersonalSettings_Noclip"] = "Noclip", ["Menu_PersonalSettings_GodMode"] = "Modo Dios", ["Menu_PersonalSettings_CBG"] = "Cambiar Grado de Construccion", ["Menu_PersonalSettings_InfAmmo"] = "Municion Infinita", ["Menu_PersonalSettings_UiHud"] = "UI/MENU Hud", ["Menu_PlotSettings"] = "AJUSTES DE PARCELA", ["Menu_PlotSettings_GTFO"] = "Modo GTFO", ["Menu_PlotSettings_RAID"] = "Modo RAID", ["Menu_PlotSettings_WTF"] = "Borrar hasta cimientos", ["Menu_PlotSettings_WD"] = "Borrar deployables", ["Menu_PlotSettings_CP"] = "Limpiar parcela", ["Menu_Networking"] = "NETWORKING", ["Menu_Networking_Foundations"] = "CIMIENTOS", ["Menu_Networking_Floor"] = "SUELO", ["Menu_Networking_Walls"] = "PAREDES", ["Menu_Networking_OBB"] = "OTRAS ENTIDADES DE CONSTRUCCION", ["Menu_Networking_Deployables"] = "DEPLOYABLES",
}
, this, "es");
lang.RegisterMessages(new Dictionary<string, string> {
["AutoSave"]
= "Автосохранение баз.Будет наблюдаться некоторое отставание.", ["InvalidEntity"] = "Неверный объект.Пожалуйста, посмотрите конструкцию перед сохранением базы.", ["ErrorSaveBase"] = "Произошла ошибка при сохранении вашей базы.", ["SuccesfullSaveBase"] = "Хранимая база!", ["NoClaimed"] = "У вас нет заявленного участка!", ["Cooldown"] = "Пожалуйста, подождите, чтобы использовать эту команду снова.", ["NoPerms"] = "У вас нет прав на использование этой команды.", ["OwnArea"] = "У вас уже есть заявленный участок!", ["ClaimTerrain"] = "Вы должны находиться на земле, чтобы претендовать на эту территорию.", ["AreaOverlap"] = "Вы не можете объявить здесь зону, она сталкивается с существующей зоной!", ["NotClaimed"] = "Прежде чем использовать это, вы должны заявить о своем участке..", ["ExitZone"] = "Вы покинули домен: eric: {0}", ["EnterZone"] = "Этот участок принадлежит компании: {0}", ["Outside"] = "Вы не можете фотографировать за пределами своего участка!", ["PhotoCaptured"] = "Фотография базы была успешно сделана '{0}'!", ["BaseUpdated"] = "База '{0}' была обновлена!", ["TeamLeader"] = "Это действие может предпринять только руководитель группы..", ["SaveLimitReached"] = "Вы достигли максимального предела хранения базы..", ["BuildOutsideArea"] = "Вы не можете строить за пределами своего участка!", ["BuildingInProccess"] = "Работы находятся в процессе.Дождитесь их завершения..", ["GTFOmsg"] = "У вас нет разрешения находиться на этом участке!", ["Menu_Top_Claim"] = "ЗАПРОСИТЬ УЧАСТОК", ["Menu_Top_UnClaim"] = "UNCLAIM PLOT", ["Menu_Top_Weather"] = "НАСТРОЙКИ ПОГОДЫ", ["Menu_Top_Build"] = "ПАРАМЕТРЫ СТРОИТЕЛЬСТВА", ["Menu_Top_Community"] = "СООБЩЕСТВО", ["Menu_Top_RequestResources"] = "ЗАПРОСИТЬ РЕСУРСЫ", ["Menu_VehicleManager"] = "АВТОМОБИЛЬНЫЙ МЕНЕДЖЕР", ["Menu_AutoDoors"] = "АВТОМАТИЧЕСКИЕ ДВЕРИ", ["Menu_AutoDoors_CloseOpen"] = "Закрыть/открыть двери", ["Menu_AutoDoors_Locks"] = "Добавить замки", ["Menu_AutoWindows"] = "АВТОМАТИЧЕСКИЕ ОКНА", ["Menu_AutoElectricity"] = "АВТОМАТИЧЕСКОЕ ЭЛЕКТРИЧЕСТВО", ["Menu_BuildingGrade"] = "СТРОИТЕЛЬНЫЙ УРОВЕНЬ", ["Menu_BaseGrade"] = "ОСНОВНОЙ Сорт", ["Menu_EntitySettings"] = "НАСТРОЙКИ ОБЪЕКТОВ", ["Menu_EntitySettings_Furnaces"] = "Включите духовки", ["Menu_EntitySettings_Batteries"] = "Зарядите батареи", ["Menu_EntitySettings_Stability"] = "Стабильность сущности", ["Menu_PersonalSettings"] = "ПЕРСОНАЛЬНЫЕ НАСТРОЙКИ", ["Menu_PersonalSettings_Noclip"] = "Noclip", ["Menu_PersonalSettings_GodMode"] = "Режим Бога", ["Menu_PersonalSettings_CBG"] = "Изменить строительную категорию", ["Menu_PersonalSettings_InfAmmo"] = "Бесконечные боеприпасы", ["Menu_PersonalSettings_UiHud"] = "UI/MENU Hud", ["Menu_PlotSettings"] = "КОРРЕКТИРОВКИ СЮЖЕТА", ["Menu_PlotSettings_GTFO"] = "Режим GTFO", ["Menu_PlotSettings_RAID"] = "Режим RAID", ["Menu_PlotSettings_WTF"] = "Стереть до основания", ["Menu_PlotSettings_WD"] = "Очистить развертываемые объекты", ["Menu_PlotSettings_CP"] = "Четкий сюжет", ["Menu_Networking"] = "СЕТЬ", ["Menu_Networking_Foundations"] = "ФУНДАМЕНТЫ", ["Menu_Networking_Floor"] = "ПОЛ", ["Menu_Networking_Walls"] = "СТЕНЫ", ["Menu_Networking_OBB"] = "ПРОЧИЕ СТРОИТЕЛЬНЫЕ ПРЕДПРИЯТИЯ", ["Menu_Networking_Deployables"] = "РАЗВЕРТЫВАЕМЫЕ ОБЪЕКТЫ",
}
, this, "ru");
}
private void SendMessage(BasePlayer player, string key, params object[] args) {
if (player == null) return;
string fullLanguage = lang.GetLanguage(player.UserIDString);
string languageCode = fullLanguage.Split('-')[0];
lang.SetLanguage(languageCode, player.UserIDString);
player.ChatMessage(string.Format(GetTranslation(key, player), args));
}
private string GetTranslation(string key, BasePlayer player = null) {
return lang.GetMessage(key, this, player?.UserIDString);
}
private void LoadCommands() {
foreach (var command in _config.CommandList_Claim) {
cmd.AddChatCommand(command, this, "ClaimZone");
}
foreach (var command in _config.CommandList_UnClaim) {
cmd.AddChatCommand(command, this, "UnclaimZone");
}
foreach (var command in _config.CommandList_Fly) {
cmd.AddChatCommand(command, this, "NoClip");
}
foreach (var command in _config.CommandList_God) {
cmd.AddChatCommand(command, this, "GodModeCmd");
}
foreach (var command in _config.CommandList_BGrade) {
cmd.AddChatCommand(command, this, "bgradecmd");
}
foreach (var command in _config.CommandList_Menu) {
cmd.AddChatCommand(command, this, "OpenMenuCmd");
}
if (_config.weather_menu) {
foreach (var command in _config.CommandList_WeatherMenu) {
cmd.AddConsoleCommand("creative.weather", this, "CreativeWeatherCmd");
cmd.AddChatCommand(command, this, "CreativeWeatherCmdChat");
}
}
foreach (var command in _config.CommandList_SaveBase) {
cmd.AddChatCommand(command, this, "Save");
}
foreach (var command in _config.CommandList_LoadBase) {
cmd.AddChatCommand(command, this, "LoadCommand");
}
if (_config.info_menu) {
foreach (var command in _config.CommandList_InfoPanel) {
cmd.AddChatCommand(command, this, "InfoPanelCmd");
}
}
cmd.AddConsoleCommand("load", this, "LoadConsoleCommand");
cmd.AddChatCommand("invite", this, "team_invite");
if (_config.buildcost_hud) cmd.AddChatCommand("cost", this, "CmdCost");
cmd.AddChatCommand("setlobby", this, "LobbyCmd");
}
void OnServerInitialized(bool initial) {
if (!InitializeBaseInfo()) return;
Instance = this;
RegisterPermissions();
LoadDefaultMessages();
foreach (var player in BasePlayer.activePlayerList) {
UpdatePlayerSettingsClass(player);
uiBgradeHud(player);
}
NextTick(() => {
LoadCommands();
}
);
ImportImages();
Task.Run(() => InitializeDatabaseAsync()).ContinueWith(task => {
if (task.IsFaulted) {
Puts("Error initializing database: " + task.Exception?.Message);
}
}
);
foreach (ItemBlueprint bp in ItemManager.GetBlueprints()) bp.workbenchLevelRequired = 0;
foreach (ItemBlueprint bp in ItemManager.bpList) {
BPs.Add(bp.targetItem.itemid);
}
if (_config.cvar_disable_terrain_violation_kick) {
ConsoleSystem.Run(ConsoleSystem.Option.Server, "antihack.terrain_protection 0");
Puts("Terrain Violation Kick Disabled.");
}
if (_config.cvar_disable_decay) {
ConsoleSystem.Run(ConsoleSystem.Option.Server, "decay.scale 0");
ConsoleSystem.Run(ConsoleSystem.Option.Server, "decay.upkeep 0");
Puts("Decay & Upkeep Disabled.");
}
if (_config.cvar_always_day) {
ConsoleSystem.Run(ConsoleSystem.Option.Server, "env.progresstime false");
ConsoleSystem.Run(ConsoleSystem.Option.Server, "env.time 12");
Puts("Always Day Enabled.");
}
ConsoleSystem.Run(ConsoleSystem.Option.Server, $"creative.allUsers {_config.cvar_creative_allusers}");
ConsoleSystem.Run(ConsoleSystem.Option.Server, $"creative.freePlacement {_config.cvar_creative_freeplacement}");
ConsoleSystem.Run(ConsoleSystem.Option.Server, $"creative.freeBuild {_config.cvar_creative_freebuild}");
ConsoleSystem.Run(ConsoleSystem.Option.Server, $"creative.freeRepair {_config.cvar_creative_freerepair}");
if (saveTimer == null) saveTimer = timer.Every(5f, ProcessSaveQueue);
}
private bool UnloadCalled = false;
void CallUnload() {
if (UnloadCalled) return;
UnloadCalled = true;
var dataToSave = new Dictionary<ulong, PlotManagerData>();
foreach (var entry in activeZones) {
ulong zoneID = entry.Key;
PlotManager plotManager = entry.Value;
if (plotManager != null) {
var data = new PlotManagerData {
zoneID = plotManager.zoneID, CenterZone = plotManager.CenterZone, GTFO = plotManager.GTFO
}
;
dataToSave[zoneID] = data;
}
}
RemoveAllMarkers();
Interface.Oxide.DataFileSystem.WriteObject("Creative/activeZones", dataToSave);
foreach (var kvp in activeZones.ToList()) {
UnityEngine.Object.DestroyImmediate(kvp.Value.gameObject);
}
activeZones.Clear();
KillAllSpawnedEntities();
foreach (var player in BasePlayer.activePlayerList) {
CuiHelper.DestroyUi(player, "BGradeHudPanel");
CuiHelper.DestroyUi(player, "BGradeHudPanel2");
CuiHelper.DestroyUi(player, "CostPanel");
CuiHelper.DestroyUi(player, "LoadingText");
CuiHelper.DestroyUi(player, "Info_Panel");
CuiHelper.DestroyUi(player, "MainMenu_Panel");
CuiHelper.DestroyUi(player, "Build_Panel");
CuiHelper.DestroyUi(player, "Networking");
CuiHelper.DestroyUi(player, "Plot_Panel");
CuiHelper.DestroyUi(player, "Personal_Panel");
CuiHelper.DestroyUi(player, "Entity_Panel");
CuiHelper.DestroyUi(player, "AutoDoors_Panel");
CuiHelper.DestroyUi(player, "AutoWindows_Panel");
CuiHelper.DestroyUi(player, "AutoElectricity_Panel");
CuiHelper.DestroyUi(player, "BuildingUpgrade_Panel");
CuiHelper.DestroyUi(player, "BaseGradeUpdate_Panel");
CuiHelper.DestroyUi(player, "VehicleManager_Panel");
CuiHelper.DestroyUi(player, "Community_Panel");
CuiHelper.DestroyUi(player, "WeatherPanel");
CuiHelper.DestroyUi(player, "LoadingText");
CuiHelper.DestroyUi(player, "Info_Panel");
ClearAll(player);
}
}
void OnServerShutdown() {
CallUnload();
if (BPs != null) Facepunch.Pool.FreeList(ref BPs);
foreach (var player in BasePlayer.activePlayerList) if (playerSettings.ContainsKey(player.userID)) playerSettings.Remove(player.userID);
}
void Unload() {
CallUnload();
if (BPs != null) Facepunch.Pool.FreeList(ref BPs);
foreach (var player in BasePlayer.activePlayerList) if (playerSettings.ContainsKey(player.userID)) playerSettings.Remove(player.userID);
}
void OnPluginUnloaded(Plugin plugin) {
if (plugin.Name == "Creative") {
if (BPs != null) Facepunch.Pool.FreeList(ref BPs);
CallUnload();
foreach (var player in BasePlayer.activePlayerList) if (playerSettings.ContainsKey(player.userID)) playerSettings.Remove(player.userID);
}
}
void OnExplosiveDropped(BasePlayer player, BaseEntity entity, ThrownWeapon item) {
try {
if (!permission.UserHasPermission(player.UserIDString, "creative.use")) return;
AntiExplosives(player, entity, item);
}
catch (Exception e) {
LogErrors(e.Message, "OnExplosiveDropped");
}
}
void OnExplosiveThrown(BasePlayer player, BaseEntity entity, ThrownWeapon item) {
try {
if (!permission.UserHasPermission(player.UserIDString, "creative.use")) return;
AntiExplosives(player, entity, item);
}
catch (Exception e) {
LogErrors(e.Message, "OnExplosiveThrown");
}
}
void AntiExplosives(BasePlayer player, BaseEntity entity, ThrownWeapon item) {
try {
if (!permission.UserHasPermission(player.UserIDString, "creative.use")) return;
entity.OwnerID = player.userID;
ulong closestZoneID = FindClosestZone(player);
if (closestZoneID != player.userID) {
entity.Kill();
return;
}
if (activeZones != null && activeZones.Count > 0) {
float closestDistance = float.MaxValue;
PlotManager closestZone = null;
foreach (var kvp in activeZones) {
var existingZone = kvp.Value;
Vector3 existingZoneCenterPos = existingZone.GetZoneCenter();
if (existingZoneCenterPos == Vector3.zero) {
entity.Kill();
return;
}
float distanceToZone = Vector3.Distance(existingZoneCenterPos, player.transform.position);
if (distanceToZone < closestDistance) {
closestDistance = distanceToZone;
closestZone = existingZone;
}
}
if (closestZone != null) {
if (closestZone.IsPlayerAllowed(player)) {
float plot_radius = permission.UserHasPermission(player.UserIDString, "creative.vip") ? _config.plot_radius_vip : _config.plot_radius_default;
if (Vector3.Distance(closestZone.GetZoneCenter(), player.transform.position) > plot_radius) {
entity.Kill();
return;
}
}
if (!PlayerOwnedZone(player, closestZone.GetOwner())) {
entity.Kill();
return;
}
}
}
}
catch (Exception e) {
LogErrors(e.Message, "AntiExplosives");
}
}
private bool PlayerOwnedZone(BasePlayer player, ulong ownerUID) {
if (!player || ownerUID == null) return false;
if (player.Team != null) {
if (player.Team.members.Contains(ownerUID)) {
return true;
}
}
else {
if (player.userID == ownerUID) {
return true;
}
}
return false;
}
private void OnWeaponFired(BaseProjectile projectile, BasePlayer player) {
if (!permission.UserHasPermission(player.UserIDString, "creative.use")) return;
var heldEntity = projectile.GetItem();
if (!playerSettings.ContainsKey(player.userID) || !playerSettings[player.userID].InfiniteAmmo || heldEntity == null || !permission.UserHasPermission(player.UserIDString, "creative.infammo")) return;
heldEntity.condition = heldEntity.info.condition.max;
projectile.primaryMagazine.contents = projectile.primaryMagazine.capacity;
projectile.SendNetworkUpdateImmediate();
}
private void OnRocketLaunched(BasePlayer player, BaseEntity entity) {
try {
if (!permission.UserHasPermission(player.UserIDString, "creative.use")) return;
ulong closestZoneID = FindClosestZone(player);
if (closestZoneID != player.userID) {
entity.Kill();
return;
}
if (activeZones != null && activeZones.Count > 0) {
float closestDistance = float.MaxValue;
PlotManager closestZone = null;
foreach (var kvp in activeZones) {
var existingZone = kvp.Value;
Vector3 existingZoneCenterPos = existingZone.GetZoneCenter();
if (existingZoneCenterPos == Vector3.zero) {
entity.Kill();
return;
}
float distanceToZone = Vector3.Distance(existingZoneCenterPos, player.transform.position);
if (distanceToZone < closestDistance) {
closestDistance = distanceToZone;
closestZone = existingZone;
}
}
if (closestZone != null) {
if (closestZone.IsPlayerAllowed(player)) {
float plot_radius = permission.UserHasPermission(player.UserIDString, "creative.vip") ? _config.plot_radius_vip : _config.plot_radius_default;
if (Vector3.Distance(closestZone.GetZoneCenter(), player.transform.position) > plot_radius) {
entity.Kill();
return;
}
}
if (!PlayerOwnedZone(player, closestZone.GetOwner())) {
entity.Kill();
return;
}
}
}
if (entity is TimedExplosive) {
TimedExplosive rocket = (TimedExplosive)entity;
Rigidbody rigidbody = rocket.GetComponent<Rigidbody>();
if (rigidbody == null) {
rigidbody = rocket.gameObject.AddComponent<Rigidbody>();
rigidbody.isKinematic = true;
}
Collider col = rocket.GetComponent<Collider>();
if (col == null) {
BoxCollider boxCollider = rocket.gameObject.AddComponent<BoxCollider>();
boxCollider.isTrigger = true;
}
}
var heldEntity = player.GetActiveItem();
var explosive = entity as TimedExplosive;
entity.OwnerID = player.userID;
if (heldEntity == null) return;
var weapon = heldEntity.GetHeldEntity() as BaseProjectile;
if (weapon == null || !playerSettings.ContainsKey(player.userID) || !playerSettings[player.userID].InfiniteAmmo || !permission.UserHasPermission(player.UserIDString, "creative.infammo")) return;
heldEntity.condition = heldEntity.info.condition.max;
weapon.primaryMagazine.contents = weapon.primaryMagazine.capacity;
weapon.SendNetworkUpdateImmediate();
}
catch (Exception e) {
LogErrors(e.Message, "OnRocketLaunched");
}
}
void OnItemDropped(Item item, BaseEntity entity) {
NextTick(() => {
if (item != null) item.Remove();
if (entity != null && !entity.IsDestroyed) entity.Kill();
}
);
}
void OnPlayerCorpseSpawned(BasePlayer player, PlayerCorpse corpse) {
NextTick(() => {
if (corpse != null && !corpse.IsDestroyed) corpse.Kill();
}
);
}
void ClearCorpseInventory(BaseEntity entity) {
var corpse = entity as LootableCorpse;
if (corpse == null) return;
foreach (var container in corpse.containers) container.itemList.Clear();
}
private void RocketsCollider(BaseEntity entity) {
if (entity == null) return;
try {
if (entity is TimedExplosive) {
TimedExplosive rocket = (TimedExplosive)entity;
Collider col = rocket.GetComponent<Collider>();
if (col == null) {
BoxCollider boxCollider = rocket.gameObject.AddComponent<BoxCollider>();
boxCollider.isTrigger = true;
}
}
}
catch (Exception ex) {
LogErrors(ex.Message, "RocketsCollider");
}
}
private void PreventItemSpawn(BaseEntity entity) {
if (entity == null) return;
try {
foreach (string bloked_items in _config.blocked_items) {
if (entity is DroppedItemContainer || entity.PrefabName.Contains(bloked_items) || entity.PrefabName.Contains("fireworks") || entity.PrefabName.Contains("igniter.deployed") || entity.PrefabName.Contains("drone") || entity.PrefabName.Contains("smoke")) if (!entity.IsDestroyed) en
// ... [Code preview truncated due to length. Full source in attached file] ...