Иконка ресурса

FREE XStatistics : 2.1.17 2.1.17

Нет прав для скачивания
C#:
using System;
using System.Linq;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Core.Database;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("XStatistics", "Monster", "2.1.17")]
    class XStatistics : RustPlugin {
        private const bool LanguageEnglish = true;
        private const string permUse = "xstatistics.use";
        private const string permTOP = "xstatistics.top";
        private const string permC = "xstatistics.coefficients";
        private const string permPlayer = "xstatistics.player";
        private const string permRW = "xstatistics.resetwipe";
        private const string permRA = "xstatistics.resetall";
        private const string permSHStats = "xstatistics.shstats";
        private const string permAdmin = "xstatistics.admin";
        private Dictionary<ulong, Dictionary<ulong, double>> _initiators = new Dictionary<ulong, Dictionary<ulong, double>>();
        private Dictionary<string, string> _images = new Dictionary<string, string>();
        private Dictionary<ulong, string> _playersServerName = new Dictionary<ulong, string>();
        private Dictionary<BasePlayer, DateTime> Cooldowns = new Dictionary<BasePlayer, DateTime>();
        private Dictionary<BasePlayer, DateTime> CooldownsTOP = new Dictionary<BasePlayer, DateTime>();
        private Coroutine _coroutineGiveAward, _coroutineUpdateCustomTOP, _coroutineUpdateGlobalCustomTOP, _coroutineSaveDB;
        private List<ulong> _adminUiFD = new List<ulong>();
        private ulong xKamikazeFPVDroneSkinID;
#region Reference
        [PluginReference]
        private Plugin ImageLibrary, XKamikazeFPVDrone, ZLevelsRemastered, SkillTree;
#endregion
#region Config
        private StatsConfig config;
        private class StatsConfig {
            internal class GeneralSetting {
                [JsonProperty(LanguageEnglish ? "Privacy of statistics. [ True - initially opened | False - initially hidden ]" : "Приватность статистики. [ True - открыта изначально | False - скрыта изначально ]")]
                public bool ShowHideStats;
                [JsonProperty(LanguageEnglish ? "Link to image of hidden statistics" : "Ссылка на картинку скрытой статистики")]
                public string URLImage;
                [JsonProperty(LanguageEnglish ? "Number of pages" : "Количество страниц")]
                public int PageCount;
                [JsonProperty(LanguageEnglish ? "Enable statistics update/save logs in the server console" : "Включить логи обновления/сохранения статистики в консоли сервера")]
                public bool UpdateSaveLogs = true;
                [JsonProperty(LanguageEnglish ? "Player banned. Delete his statistics for the wipe" : "Игрок забанен. Удалить его статистику за вайп")]
                public bool BanDeleteStatsWipe;
                [JsonProperty(LanguageEnglish ? "Player banned. Delete his statistics for all time" : "Игрок забанен. Удалить его статистику за все время")]
                public bool BanDeleteStatsAll;
                [JsonProperty(LanguageEnglish ? "Player banned. Delete his statistics from the Global TOP of servers" : "Игрок забанен. Удалить его статистику из Глобального ТОПа серверов")]
                public bool BanDeleteStatsGlobal;
                [JsonProperty(LanguageEnglish ? "Delete a player stats for the Wipe, if he hasn't connected in server for N days" : "Удалить статистику игрока за Вайп, если он не заходил на сервер N дней")]
                public bool DeleteStats;
                [JsonProperty(LanguageEnglish ? "Additionally delete stats from the Global Top database. [ There is protection from deleting data if a player moved to another server from Global TOP. ]" : "Дополнительно удалить статистику из базы данных Глобального ТОПа. [ Есть защита от удаления данных, если игрок перешел играть на другой сервер из Глобального ТОПа. ]")]
                public bool DeleteGlobalStats;
                [JsonProperty(LanguageEnglish ? "Number of days to delete statistics" : "Кол-во дней для удаления статистики")]
                public int NumberOfDays;
                [JsonProperty(LanguageEnglish ? "List of commands to open statistics" : "Список команд для открытия статистики")]
                public List<string> CommandList;
                [JsonProperty(LanguageEnglish ? "List of commands to open TOPs" : "Список команд для открытия ТОПов")]
                public List<string> CommandListTOP;
                [JsonProperty(LanguageEnglish ? "Player blacklist [ SteamIDs ]  -  Statistics will only be available to the player himself and the administrator. Statistics will be hidden from other players and will not be displayed in the TOPs." : "Черный список игроков [ SteamIDs ]  -  Статистика будет доступна только самому игроку и администратору. Статистика будет скрыта от других игроков и не будет отображаться в ТОПах.")]
                public List<ulong> PlayerBlacklist;
            }
            internal class AdvancedSettings {
                [JsonProperty(LanguageEnglish ? "Count the killing of teammates" : "Засчитывать убийство тимейтов")]
                public bool KillTeammates;
                [JsonProperty(LanguageEnglish ? "Count fishing with a rod" : "Засчитывать рыбалку удочкой")]
                public bool FishingRod = true;
                [JsonProperty(LanguageEnglish ? "Count fishing with a trap" : "Засчитывать рыбалку ловушкой")]
                public bool FishingTrap = true;
            }
            internal class MySQLSetting {
                [JsonProperty(LanguageEnglish ? "Use database instead of oxide/data/XDataSystem/XStatistics files" : "Использовать базу данных вместо файлов oxide/data/XDataSystem/XStatistics")]
                public bool UseDB;
                [JsonProperty("[ True - MySQL | False - SQLite (oxide/data/XDataSystem/XStatistics/xstatistics.db) ]")]
                public bool MySQLorSQLite;
                public string MySQL_Host;
                public int MySQL_Port;
                public string MySQL_DB_Name;
                public string MySQL_Username;
                public string MySQL_Password;
                [JsonProperty(LanguageEnglish ? "MySQL table name - 1 [ Name must be unique if multiple server data is stored in the same database ]" : "Имя таблицы MySQL - 1 [ Имя должно быть уникальным, если в одной базе данных хранятся данные нескольких серверов ]")]
                public string TableName1 = "StoredData";
                [JsonProperty(LanguageEnglish ? "MySQL table name - 2 [ Name must be unique if multiple server data is stored in the same database ]" : "Имя таблицы MySQL - 2 [ Имя должно быть уникальным, если в одной базе данных хранятся данные нескольких серверов ]")]
                public string TableName2 = "StoredDataT";
                [JsonProperty(LanguageEnglish ? "Use MySQL for the Global TOP of servers" : "Использовать MySQL для Глобального ТОПа серверов")]
                public bool UseGlobalTOP;
                [JsonProperty(LanguageEnglish ? "Server name for the Global TOP of servers [ Maximum 30 characters ]" : "Название сервера для Глобального ТОПа серверов [ Максимум 30 символов ]")]
                public string SNGlobalTOP = "";
            }
            internal class AwardSetting {
                [JsonProperty(LanguageEnglish ? "Automatically give out awards after a wipe" : "Автоматически выдавать награды после вайпа")]
                public bool AutoGiveAward;
                [JsonProperty(LanguageEnglish ? "Automatically clear data after awards have been given" : "Автоматически очистить дату(данные) после выдачи наград")]
                public bool AutoClearDataGA;
                [JsonProperty(LanguageEnglish ? "Automatically clear data after a wipe (when automatic awards are disabled)" : "Автоматически очистить дату(данные) после вайпа (когда отключена автоматическая выдача наград)")]
                public bool AutoClearData;
                [JsonProperty("[ RU ] Секретный ключ - GameStores")]
                public string StoreKey;
                [JsonProperty("[ RU ] ID магазина - GameStores")]
                public string StoreID;
                [JsonProperty(LanguageEnglish ? "Where will the awards be given - [ 0 - GameStores | 1 - plugin economy, rewards or in-game store ]" : "Куда будут выданы награды - [ 0 - GameStores | 1 - плагин экономики, наград или внутриигровой магазин ]")]
                public int Store;
                [JsonProperty(LanguageEnglish ? "Plugin name" : "Название плагина")]
                public string PluginName;
                [JsonProperty(LanguageEnglish ? "Method name(API)" : "Название метода(API)")]
                public string HookName;
                [JsonProperty(LanguageEnglish ? "Method(API) data type - [ 0 - double | 1 - float | 2 - int ]" : "Тип данных метода(API) - [ 0 - double | 1 - float | 2 - int ]")]
                public int HookDataType;
                [JsonProperty(LanguageEnglish ? "Displayed currency" : "Отображаемая валюта")]
                public string Currency;
            }
            internal class PluginsStatsSetting {
                [JsonProperty(LanguageEnglish ? "RaidableBases - statistics for the base owner" : "RaidableBases - статистика для владельца базы")]
                public bool RBOwner;
                [JsonProperty(LanguageEnglish ? "RaidableBases - statistics for the base raiders" : "RaidableBases - статистика для рейдеров базы")]
                public bool RBRaiders;
                [JsonProperty(LanguageEnglish ? "RaidableBases - statistics for the base intruders" : "RaidableBases - статистика для взломщиков базы")]
                public bool RBIntruders;
            }
            internal class CategoryGUISetting {
                public float OffsetMinX;
                public float OffsetMinY;
                public float OffsetMaxX;
                public float OffsetMaxY;
            }
            internal class GUISetting {
                [JsonProperty(LanguageEnglish ? "Close the menu by tapping on an empty area of the screen" : "Закрыть меню нажатием на пустую область экрана")]
                public bool CloseUI;
                [JsonProperty(LanguageEnglish ? "Color_background_1" : "Цвет_фон_1")]
                public string BColor1;
                [JsonProperty(LanguageEnglish ? "Color_background_2" : "Цвет_фон_2")]
                public string BColor2;
                [JsonProperty(LanguageEnglish ? "Color_background_3" : "Цвет_фон_3")]
                public string BColor3;
                [JsonProperty(LanguageEnglish ? "Color_background_4" : "Цвет_фон_4")]
                public string BColor4;
                [JsonProperty(LanguageEnglish ? "Category background color" : "Цвет фона категории")]
                public string СBColor;
                [JsonProperty(LanguageEnglish ? "Subcategory background color" : "Цвет фона подкатегории")]
                public string SСBColor;
                [JsonProperty(LanguageEnglish ? "Background color of coefficients/tops/players" : "Цвет фона коэффициентов/топов/игроков")]
                public string CTPBColor;
                [JsonProperty(LanguageEnglish ? "Background color of custom TOPs and coefficients" : "Цвет фона кастомных ТОПов и коэффициентов")]
                public string CTCBColor;
                [JsonProperty(LanguageEnglish ? "I'm in custom TOP. Background color" : "Я в кастомном ТОПе. Цвет заднего фона")]
                public string ImCTBColor;
                [JsonProperty(LanguageEnglish ? "Button color (icons)" : "Цвет кнопок (иконки)")]
                public string IconColor;
                [JsonProperty(LanguageEnglish ? "Color progress" : "Цвет прогресс")]
                public string ProgressColor;
                [JsonProperty(LanguageEnglish ? "Color of filled progress" : "Цвет заполненного прогресса")]
                public string FProgressColor;
                [JsonProperty(LanguageEnglish ? "Active next/reset button color" : "Цвет активной кнопки далее/обнулить")]
                public string ActiveNextResetColor;
                [JsonProperty(LanguageEnglish ? "Inactive next/reset button color" : "Цвет неактивной кнопки далее/обнулить")]
                public string InactiveNextResetColor;
                [JsonProperty(LanguageEnglish ? "Active next/reset button text color" : "Цвет текста активной кнопки далее/обнулить")]
                public string ActiveNextResetColorText;
                [JsonProperty(LanguageEnglish ? "Inactive next/reset button text color" : "Цвет текста неактивной кнопки далее/обнулить")]
                public string InactiveNextResetColorText;
                [JsonProperty(LanguageEnglish ? "Active back/close button color" : "Цвет активной кнопки назад/закрыть")]
                public string ActiveBackColor;
                [JsonProperty(LanguageEnglish ? "Inactive back/close button color" : "Цвет неактивной кнопки назад/закрыть")]
                public string InactiveBackColor;
                [JsonProperty(LanguageEnglish ? "Active back/close button text color" : "Цвет текста активной кнопки назад/закрыть")]
                public string ActiveBackColorText;
                [JsonProperty(LanguageEnglish ? "Inactive back/close button text color" : "Цвет текста неактивной кнопки назад/закрыть")]
                public string InactiveBackColorText;
            }
            internal class ChatTOPSetting {
                [JsonProperty(LanguageEnglish ? "Display custom TOPs in chat" : "Отображать кастомные ТОПы в чате")]
                public bool UseCustomTOPChat;
                [JsonProperty(LanguageEnglish ? "Display TOPs subcategories in chat" : "Отображать ТОПы подкатегорий в чате")]
                public bool UseSubTOPChat;
                [JsonProperty(LanguageEnglish ? "Interval of custom TOPs messages in chat" : "Интервал сообщений кастомных ТОПов в чате")]
                public int IntervalCustomTOPChat;
                [JsonProperty(LanguageEnglish ? "Interval of messages of TOPs subcategories in chat" : "Интервал сообщений ТОПов подкатегорий в чате")]
                public int IntervalSubTOPChat;
                [JsonProperty(LanguageEnglish ? "List of custom TOPs that will be displayed in chat. [ Custom TOP name ]" : "Список кастомных ТОПов которые будут отображаться в чате. [ Имя кастомного ТОПа ]")]
                public List<string> ListCustomTOPChat;
                [JsonProperty(LanguageEnglish ? "List of TOPs subcategories that will be displayed in the chat. [ Subcategory name ]" : "Список ТОПов подкатегорий которые будут отображаться в чате. [ Имя подкатегории ]")]
                public List<string> ListSubTOPChat;
            }
            internal class TOPSetting {
                [JsonProperty(LanguageEnglish ? "Subcategories that are in the TOP and their coefficients. [ Subcategory name - coefficient ]" : "Подкатегории которые входят в ТОП и коэффициенты к ним. [ Имя подкатегории - коэффициент ]")]
                public Dictionary<string, double> CategoryList;
                [JsonProperty(LanguageEnglish ? "Awards. [ Place - Award ]" : "Награды. [ Место - награда ]")]
                public Dictionary<int, double> AwardList;
            }
            internal class ItemSetting {
                [JsonProperty(LanguageEnglish ? "Subcategory name. [ Unique / Must not be empty ]" : "Имя подкатегории. [ Уникальное / Не должно быть пустым ]")]
                public string Subname;
                [JsonProperty(LanguageEnglish ? "Shortname of the item for the image. [ Mandatory if there is no link to the custom image ]" : "Шортнейм предмета для картинки. [ Обязательно если отсутствует ссылка на кастомную картинку ]")]
                public string Shortname;
                [JsonProperty(LanguageEnglish ? "Amount of resource to fill the progress bar" : "Количество ресурса для заполнения прогрес-бара")]
                public int Progress;
                [JsonProperty(LanguageEnglish ? "Link to custom image" : "Ссылка на кастомную картинку")]
                public string URLImage;
                [JsonProperty(LanguageEnglish ? "Shortnames that will count toward the subcategory" : "Шортнеймы которые будут засчитываться в подкатегорию")]
                public List<string> ListItems;
                [JsonProperty(LanguageEnglish ? "List of classes(grades) of building blocks to be recorded in statistics. [ Leave 'null' if it is not a building block ]" : "Список классов(грейдов) строительных блоков для записи в статистику. [ Оставьте 'null' если это не строительный блок ]")]
                public List<string> BuildingGradesList;
                public ItemSetting(string subname, string shortname, int progress, string urlimage, List<string> listitems, List<string> buildinggradeslist) {
                    Subname = subname;
                    Shortname = shortname;
                    Progress = progress;
                    URLImage = urlimage;
                    ListItems = listitems;
                    BuildingGradesList = buildinggradeslist;
                }
            }
            internal class CategorySetting {
                public float OffsetMinX;
                public float OffsetMinY;
                public float OffsetMaxX;
                public float OffsetMaxY;
                [JsonProperty(LanguageEnglish ? "Number of the page on which the category will be displayed" : "Номер страницы на которой будет отображаться категория")]
                public int NumPage;
                [JsonProperty(LanguageEnglish ? "Enable pages for a category" : "Включить страницы для категории")]
                public bool UsePage;
                [JsonProperty(LanguageEnglish ? "Number of subcategories on a page" : "Количество подкатегорий на странице")]
                public int CountPage;
                [JsonProperty(LanguageEnglish ? "Setting subcategories" : "Настройка подкатегорий")]
                public List<ItemSetting> GUI = new List<ItemSetting>();
            }
            [JsonProperty(LanguageEnglish ? "General settings" : "Общие настройки")]
            public GeneralSetting Setting = new GeneralSetting();
            [JsonProperty(LanguageEnglish ? "Advanced settings" : "Дополнительные настройки")]
            public AdvancedSettings ASetting = new AdvancedSettings();
            [JsonProperty(LanguageEnglish ? "Database settings" : "Настройки базы данных")]
            public MySQLSetting DB = new MySQLSetting();
            [JsonProperty(LanguageEnglish ? "Settings for award distribution" : "Настройка выдачи наград")]
            public AwardSetting Award = new AwardSetting();
            [JsonProperty(LanguageEnglish ? "Third-party plugins statistics settings" : "Настройки статистики сторонних плагинов")]
            public PluginsStatsSetting PluginsStats = new PluginsStatsSetting();
            [JsonProperty(LanguageEnglish ? "Settings the general layout of categories" : "Настройка общего расположения категорий")]
            public CategoryGUISetting Category = new CategoryGUISetting();
            [JsonProperty(LanguageEnglish ? "GUI settings" : "Настройки GUI")]
            public GUISetting GUI = new GUISetting();
            [JsonProperty(LanguageEnglish ? "Settings messages TOP in chat" : "Настройка сообщений ТОПа в чате")]
            public ChatTOPSetting TOPChat = new ChatTOPSetting();
            [JsonProperty(LanguageEnglish ? "Settings custom TOPs and awards" : "Настройка кастомных ТОПов и наград")]
            public Dictionary<string, TOPSetting> TOP = new Dictionary<string, TOPSetting>();
            [JsonProperty(LanguageEnglish ? "Setting up categories and subcategories" : "Настройка категорий и подкатегорий")]
            public Dictionary<string, Dictionary<string, CategorySetting>> CategoryItem = new Dictionary<string, Dictionary<string, CategorySetting>>();
            public static StatsConfig GetNewConfiguration() {
                return new StatsConfig {
                    Setting = new GeneralSetting {
                        ShowHideStats = false, URLImage = "https://i.ibb.co/MDmy1Jx/zvh4xlf.png", PageCount = 3, UpdateSaveLogs = true, BanDeleteStatsWipe = true, BanDeleteStatsAll = false, BanDeleteStatsGlobal = false, DeleteStats = false, DeleteGlobalStats = false, NumberOfDays = 5, CommandList = new List<string> {
                            "stat", "stats", "statistic", "statistics"
                        }
                        , CommandListTOP = new List<string> {
                            "stop", "statstops"
                        }
                        , PlayerBlacklist = new List<ulong>()
                    }
                    , ASetting = new AdvancedSettings {
                        KillTeammates = false, FishingRod = true, FishingTrap = true
                    }
                    , DB = new MySQLSetting {
                        UseDB = false, MySQLorSQLite = false, MySQL_Host = "", MySQL_Port = 0, MySQL_DB_Name = "", MySQL_Username = "", MySQL_Password = "", TableName1 = "StoredData", TableName2 = "StoredDataT", UseGlobalTOP = false, SNGlobalTOP = ""
                    }
                    , Award = new AwardSetting {
                        AutoGiveAward = false, AutoClearDataGA = false, AutoClearData = false, StoreKey = "", StoreID = "", Store = 1, PluginName = "Economics", HookName = "Deposit", HookDataType = 0, Currency = "$"
                    }
                    , PluginsStats = new PluginsStatsSetting {
                        RBOwner = true, RBRaiders = true, RBIntruders = false
                    }
                    , Category = new CategoryGUISetting {
                        OffsetMinX = 0, OffsetMinY = 0, OffsetMaxX = 0, OffsetMaxY = 0
                    }
                    , GUI = new GUISetting {
                        CloseUI = false, BColor1 = "0 0 0 0.95", BColor2 = "0.517 0.521 0.509 0.95", BColor3 = "0.217 0.221 0.209 0.95", BColor4 = "0.217 0.221 0.209 1", СBColor = "0.317 0.321 0.309 0.75", SСBColor = "0.467 0.471 0.459 1", CTPBColor = "0.367 0.371 0.359 1", CTCBColor = "0.267 0.271 0.259 1", ImCTBColor = "0.567 0.571 0.559 1", IconColor = "1 1 1 0.75", ProgressColor = "0.68 1 0.57 0.5", FProgressColor = "1 0.5 0 0.5", ActiveNextResetColor = "0.35 0.45 0.25 1", InactiveNextResetColor = "0.35 0.45 0.25 0.4", ActiveNextResetColorText = "0.75 0.95 0.41 1", InactiveNextResetColorText = "0.75 0.95 0.41 0.4", ActiveBackColor = "0.65 0.29 0.24 1", InactiveBackColor = "0.65 0.29 0.24 0.4", ActiveBackColorText = "0.92 0.79 0.76 1", InactiveBackColorText = "0.92 0.79 0.76 0.4"
                    }
                    , TOPChat = new ChatTOPSetting {
                        UseCustomTOPChat = false, UseSubTOPChat = true, IntervalCustomTOPChat = 1100, IntervalSubTOPChat = 850, ListCustomTOPChat = new List<string> {
                            "farmDesc", "killDesc", "online"
                        }
                        , ListSubTOPChat = new List<string> {
                            "wood", "stones", "boar"
                        }
                    }
                    , TOP = new Dictionary<string, TOPSetting> {
                        ["farmDesc"]
                        = new TOPSetting {
                            CategoryList = new Dictionary<string, double> {
                                ["wood"]
                                = 0.1, ["stones"] = 0.25, ["metal.ore"] = 0.35
                            }
                            , AwardList = new Dictionary<int, double> {
                                [1]
                                = 30.0, [2] = 25.0, [3] = 20.0, [4] = 10.0, [5] = 5.0
                            }
                        }
                        , ["craftDesc"] = new TOPSetting {
                            CategoryList = new Dictionary<string, double> {
                                ["explosive.timed"]
                                = 1.0, ["ammo.rocket.basic"] = 1.0, ["explosive.satchel"] = 1.0
                            }
                            , AwardList = new Dictionary<int, double> {
                                [1]
                                = 30.0, [2] = 25.0, [3] = 20.0, [4] = 10.0, [5] = 5.0
                            }
                        }
                        , ["killDesc"] = new TOPSetting {
                            CategoryList = new Dictionary<string, double> {
                                ["diesel_barrel"]
                                = 0.2, ["skull.human"] = 1.5, ["skull.wolf"] = 1.0
                            }
                            , AwardList = new Dictionary<int, double> {
                                [1]
                                = 30.0, [2] = 25.0, [3] = 20.0, [4] = 10.0, [5] = 5.0
                            }
                        }
                        , ["online"] = new TOPSetting {
                            CategoryList = new Dictionary<string, double>(), AwardList = new Dictionary<int, double> {
                                [1]
                                = 30.0, [2] = 25.0, [3] = 20.0, [4] = 10.0, [5] = 5.0
                            }
                        }
                    }
                    , CategoryItem = new Dictionary<string, Dictionary<string, CategorySetting>> {
                        ["Resource"]
                        = new Dictionary<string, CategorySetting> {
                            ["resource"]
                            = new CategorySetting {
                                OffsetMinX = -137.5f, OffsetMinY = 209.0f, OffsetMaxX = -137.5f, OffsetMaxY = 209.0f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("wood", "wood", 10000, "", new List<string> {
                                        "wood"
                                    }
                                    , null), new ItemSetting("stones", "stones", 10000, "", new List<string> {
                                        "stones"
                                    }
                                    , null), new ItemSetting("metal.ore", "metal.ore", 10000, "", new List<string> {
                                        "metal.ore"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Pickup"] = new Dictionary<string, CategorySetting> {
                            ["pickup"]
                            = new CategorySetting {
                                OffsetMinX = 137.5f, OffsetMinY = 209.0f, OffsetMaxX = 137.5f, OffsetMaxY = 209.0f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("clone.potato", "clone.potato", 50, "", new List<string> {
                                        "potato-collectable"
                                    }
                                    , null), new ItemSetting("clone.hemp", "clone.hemp", 50, "", new List<string> {
                                        "hemp-collectable"
                                    }
                                    , null), new ItemSetting("mushroom", "mushroom", 50, "", new List<string> {
                                        "mushroom-cluster-5", "mushroom-cluster-6"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Kill"] = new Dictionary<string, CategorySetting> {
                            ["kill"]
                            = new CategorySetting {
                                OffsetMinX = -137.5f, OffsetMinY = 77.5f, OffsetMaxX = -137.5f, OffsetMaxY = 77.5f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("diesel_barrel", "diesel_barrel", 250, "", new List<string> {
                                        "oil_barrel", "loot-barrel-1", "loot-barrel-2", "loot_barrel_1", "loot_barrel_2"
                                    }
                                    , null), new ItemSetting("skull.human", "skull.human", 50, "", new List<string> {
                                        "player"
                                    }
                                    , null), new ItemSetting("skull.wolf", "skull.wolf", 100, "", new List<string> {
                                        "boar", "bear", "stag", "wolf", "chicken"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Craft"] = new Dictionary<string, CategorySetting> {
                            ["craft"]
                            = new CategorySetting {
                                OffsetMinX = 137.5f, OffsetMinY = 77.5f, OffsetMaxX = 137.5f, OffsetMaxY = 77.5f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("explosive.timed", "explosive.timed", 75, "", new List<string> {
                                        "explosive.timed"
                                    }
                                    , null), new ItemSetting("ammo.rocket.basic", "ammo.rocket.basic", 100, "", new List<string> {
                                        "ammo.rocket.basic"
                                    }
                                    , null), new ItemSetting("explosive.satchel", "explosive.satchel", 150, "", new List<string> {
                                        "explosive.satchel"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Loot"] = new Dictionary<string, CategorySetting> {
                            ["loot"]
                            = new CategorySetting {
                                OffsetMinX = 137.5f, OffsetMinY = -54.0f, OffsetMaxX = 137.5f, OffsetMaxY = -54.0f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("cratecostume", "cratecostume", 50, "", new List<string> {
                                        "crate_normal_2"
                                    }
                                    , null), new ItemSetting("box.wooden", "box.wooden", 50, "", new List<string> {
                                        "foodbox", "crate_tools"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Growable"] = new Dictionary<string, CategorySetting> {
                            ["growable"]
                            = new CategorySetting {
                                OffsetMinX = -95.0f, OffsetMinY = -54.0f, OffsetMaxX = -95.0f, OffsetMaxY = -54.0f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("pumpkin", "pumpkin", 125, "", new List<string> {
                                        "pumpkin"
                                    }
                                    , null), new ItemSetting("potato", "potato", 125, "", new List<string> {
                                        "potato"
                                    }
                                    , null), new ItemSetting("corn", "corn", 125, "", new List<string> {
                                        "corn"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Fish"] = new Dictionary<string, CategorySetting> {
                            ["fish"]
                            = new CategorySetting {
                                OffsetMinX = 0, OffsetMinY = -185.5f, OffsetMaxX = 0, OffsetMaxY = -185.5f, NumPage = 1, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("fish.smallshark", "fish.smallshark", 10, "", new List<string> {
                                        "fish.smallshark"
                                    }
                                    , null), new ItemSetting("fish.troutsmall", "fish.troutsmall", 30, "", new List<string> {
                                        "fish.troutsmall"
                                    }
                                    , null), new ItemSetting("fish.salmon", "fish.salmon", 30, "", new List<string> {
                                        "fish.salmon"
                                    }
                                    , null)
                                }
                            }
                        }
                        , ["Explosive"] = new Dictionary<string, CategorySetting> {
                            ["explosive"]
                            = new CategorySetting {
                                OffsetMinX = -52.5f, OffsetMinY = 8.0f, OffsetMaxX = -52.5f, OffsetMaxY = 8.0f, NumPage = 2, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("rocket_basic", "ammo.rocket.basic", 20, "", new List<string> {
                                        "rocket_basic"
                                    }
                                    , null), new ItemSetting("rocket_hv", "ammo.rocket.hv", 30, "", new List<string> {
                                        "rocket_hv"
                                    }
                                    , null), new ItemSetting("rocket_fire", "ammo.rocket.fire", 10, "", new List<string> {
                                        "rocket_fire"
                                    }
                                    , null), new ItemSetting("explosive.timed.deployed", "explosive.timed", 10, "", new List<string> {
                                        "explosive.timed.deployed"
                                    }
                                    , null), new ItemSetting("explosive.satchel.deployed", "explosive.satchel", 30, "", new List<string> {
                                        "explosive.satchel.deployed"
                                    }
                                    , null), new ItemSetting("grenade.f1.deployed", "grenade.f1", 20, "", new List<string> {
                                        "grenade.f1.deployed"
                                    }
                                    , null)
                                }
                            }
                            , ["drone"] = new CategorySetting {
                                OffsetMinX = 265.25f, OffsetMinY = 8.0f, OffsetMaxX = 265.25f, OffsetMaxY = 8.0f, NumPage = 2, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("xkamikazefpvdrone", "drone", 12, "", new List<string>(), null)
                                }
                            }
                        }
                        , ["Upgrade"] = new Dictionary<string, CategorySetting> {
                            ["upgrade"]
                            = new CategorySetting {
                                OffsetMinX = 0, OffsetMinY = 139.5f, OffsetMaxX = 0, OffsetMaxY = 139.5f, NumPage = 2, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("foundation", "wood", 20, "", new List<string> {
                                        "foundation"
                                    }
                                    , new List<string> {
                                        "Wood"
                                    }
                                    ), new ItemSetting("wall", "stones", 20, "", new List<string> {
                                        "wall"
                                    }
                                    , new List<string> {
                                        "Stone"
                                    }
                                    ),
                                }
                            }
                        }
                        , ["Built"] = new Dictionary<string, CategorySetting> {
                            ["built"]
                            = new CategorySetting {
                                OffsetMinX = 0, OffsetMinY = -123.5f, OffsetMaxX = 0, OffsetMaxY = -123.5f, NumPage = 2, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("barricade.wood.cover", "barricade.wood.cover", 10, "", new List<string> {
                                        "barricade.cover.wood"
                                    }
                                    , null), new ItemSetting("barricade.metal", "barricade.metal", 10, "", new List<string> {
                                        "barricade.metal"
                                    }
                                    , null),
                                }
                            }
                        }
                        , ["Plugins"] = new Dictionary<string, CategorySetting> {
                            ["RaidableBases"]
                            = new CategorySetting {
                                OffsetMinX = -52.5f, OffsetMinY = 77.5f, OffsetMaxX = -52.5f, OffsetMaxY = 77.5f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("raidablebasesLVL1", "door.hinged.wood", 5, "", new List<string> {
                                        "namebase1"
                                    }
                                    , null), new ItemSetting("raidablebasesLVL2", "door.hinged.metal", 5, "", new List<string> {
                                        "namebase2"
                                    }
                                    , null), new ItemSetting("raidablebasesLVL3", "door.hinged.toptier", 5, "", new List<string> {
                                        "namebase3"
                                    }
                                    , null)
                                }
                            }
                            , ["RaidableBasesNPC"] = new CategorySetting {
                                OffsetMinX = 137.5f, OffsetMinY = 77.5f, OffsetMaxX = 137.5f, OffsetMaxY = 77.5f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("raidablebasesNPC", "hazmatsuit_scientist", 30, "", new List<string> {
                                        "scientistnpc_heavy"
                                    }
                                    , null)
                                }
                            }
                            , ["Trivia"] = new CategorySetting {
                                OffsetMinX = -52.5f, OffsetMinY = -54.0f, OffsetMaxX = -52.5f, OffsetMaxY = -54.0f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("triviaEast", "carburetor1", 5, "", new List<string> {
                                        "East"
                                    }
                                    , null), new ItemSetting("triviaMedium", "carburetor2", 5, "", new List<string> {
                                        "Medium"
                                    }
                                    , null), new ItemSetting("triviaHard", "carburetor3", 5, "", new List<string> {
                                        "Hard"
                                    }
                                    , null)
                                }
                            }
                            , ["XBarrelEvent"] = new CategorySetting {
                                OffsetMinX = 137.5f, OffsetMinY = -54.0f, OffsetMaxX = 137.5f, OffsetMaxY = -54.0f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("xBarrelDeath", "diesel_barrel", 25, "", null, null)
                                }
                            }
                            , ["KpucTaJlPlugins"] = new CategorySetting {
                                OffsetMinX = 0.0f, OffsetMinY = 209.0f, OffsetMaxX = 0.0f, OffsetMaxY = 209.0f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("supermarketEvent", "battery.small", 10, "", null, null), new ItemSetting("triangulationEvent", "battery.small", 10, "", null, null), new ItemSetting("gasStationEvent", "battery.small", 10, "", null, null), new ItemSetting("arcticBaseEvent", "battery.small", 10, "", null, null), new ItemSetting("junkyardEvent", "battery.small", 10, "", null, null), new ItemSetting("airEvent", "battery.small", 10, "", null, null), new ItemSetting("satDishEvent", "battery.small", 10, "", null, null), new ItemSetting("harborEvent", "battery.small", 10, "", null, null), new ItemSetting("powerPlantEvent", "battery.small", 10, "", null, null), new ItemSetting("waterEvent", "battery.small", 10, "", null, null)
                                }
                            }
                            , ["AdemPlugins"] = new CategorySetting {
                                OffsetMinX = 0.0f, OffsetMinY = -185.5f, OffsetMaxX = 0.0f, OffsetMaxY = -185.5f, NumPage = 3, UsePage = false, CountPage = 0, GUI = new List<ItemSetting> {
                                    new ItemSetting("caravanEvent", "megaphone", 10, "", null, null), new ItemSetting("convoyEvent", "megaphone", 10, "", null, null), new ItemSetting("sputnikEvent", "megaphone", 10, "", null, null)
                                }
                            }
                        }
                    }
                }
                ;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<StatsConfig>();
            }
            catch {
                PrintWarning(LanguageEnglish ? "Configuration read error! Creating a default configuration!" : "Ошибка чтения конфигурации! Создание дефолтной конфигурации!");
                LoadDefaultConfig();
            }
            if(!config.Setting.DeleteStats) config.Setting.DeleteGlobalStats = false;
            if(config.Setting.NumberOfDays < 1) config.Setting.NumberOfDays = 5;
            if(string.IsNullOrEmpty(config.DB.TableName1)) config.DB.TableName1 = "StoredData";
            if(string.IsNullOrEmpty(config.DB.TableName2)) config.DB.TableName2 = "StoredDataT";
            if(config.TOP.Count == 0 && config.DB.UseGlobalTOP) config.DB.UseGlobalTOP = false;
            if(config.Setting.CommandList == null) config.Setting.CommandList = new List<string> {
                "stat", "stats", "statistic", "statistics"
            }
            ;
            if(config.Setting.CommandListTOP == null) config.Setting.CommandListTOP = new List<string> {
                "stop", "statstops"
            }
            ;
            SaveConfig();
        }
        protected override void LoadDefaultConfig() => config = StatsConfig.GetNewConfiguration();
        protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region Data
        private class Data {
            public Dictionary<string, long> ListStats = new Dictionary<string, long>();
            public int PlayTimeWipe;
            public int KillWipe;
            public int DeathWipe;
        }
        private class DataT {
            public bool ActStats;
            public int PlayTimeAll;
            public int KillAll;
            public int DeathAll;
            public int FirstCon;
            public int LastCon;
            public string UserName;
            public bool ActTOPChat;
            public DataT(bool actstats, int playtimeall, int killall, int deathall, int firstcon, int lastcon, string username, bool acttopchat) {
                ActStats = actstats;
                PlayTimeAll = playtimeall;
                KillAll = killall;
                DeathAll = deathall;
                FirstCon = firstcon;
                LastCon = lastcon;
                UserName = username;
                ActTOPChat = acttopchat;
            }
        }
        private class GlobalData {
            public Dictionary<string, long> ListStats = new Dictionary<string, long>();
            public string UserName;
            public string ServerName;
            public int PlayTimeWipe;
            public int KillWipe;
            public int DeathWipe;
        }
        private Dictionary<ulong, Data> StoredData = new Dictionary<ulong, Data>();
        private Dictionary<ulong, DataT> StoredDataT = new Dictionary<ulong, DataT>();
        private Dictionary<ulong, GlobalData> GlobalStoredData = new Dictionary<ulong, GlobalData>();
        private void SaveData(bool isUnload = false, bool isClearData = false) {
            if(config.DB.UseDB) {
                if(config.DB.MySQLorSQLite) {
                    if(isClearData) _mySql.ExecuteNonQuery(Sql.Builder.Append($"DELETE FROM {config.DB.TableName1}"), _mySqlConnection);
                }
                else {
                    if(isClearData) _sqlite.ExecuteNonQuery(Sql.Builder.Append("DELETE FROM StoredData"), _sqliteConnection);
                }
            }
            else {
                if(_fullInitialization) {
                    if(StoredData != null) Interface.Oxide.DataFileSystem.WriteObject("XDataSystem/XStatistics/Statistics", StoredData);
                    if(StoredDataT != null) Interface.Oxide.DataFileSystem.WriteObject("XDataSystem/XStatistics/ActiveStatistics", StoredDataT);
                }
            }
            if(isUnload) {
                foreach(var player in BasePlayer.activePlayerList) OnPlayerDisconnected(player);
                //_sqlite.CloseDb(_sqliteConnection);
                //_mySql.CloseDb(_mySqlConnection);
            }
        }
#endregion
#region SQLite
        private readonly Core.SQLite.Libraries.SQLite _sqlite = Interface.Oxide.GetLibrary<Core.SQLite.Libraries.SQLite>();
        private Connection _sqliteConnection;
        private void SQLiteConnectionDB() {
            try {
                _sqliteConnection = _sqlite.OpenDb("XDataSystem/XStatistics/xstatistics.db", this);
                if(_sqliteConnection == null || _sqliteConnection.Con == null) PrintError(LanguageEnglish ? $"Error! Failed to get a connection to the database: {_sqliteConnection.Con.State}" : $"Ошибка! Не удалось получить подключение к базе данных: {_sqliteConnection.Con.State}");
                else {
                    _sqlite.ExecuteNonQuery(Sql.Builder.Ap
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху