C#:
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins {
[Info("VKBot", "SkiTles", "1.6.8")]
class VKBot : RustPlugin {
//Данный плагин принадлежит группе vk.com/vkbotrust
//Данный плагин предоставляется в существующей форме,
//"как есть", без каких бы то ни было явных или
//подразумеваемых гарантий, разработчик не несет
//ответственность в случае его неправильного использования.[PluginReference]
Plugin Duel;
#region Variables
private System.Random random = new System.Random();
private string msg;
private string mapfile;
private bool NewWipe = false;
JsonSerializerSettings jsonsettings;
private Dictionary<ulong, ulong> PlayersCheckList = new Dictionary<ulong, ulong>();
private List<string> allowedentity = new List<string>() {
"door", "wall.window.bars.metal", "wall.window.bars.toptier", "wall.external", "gates.external.high", "floor.ladder", "embrasure", "floor.grill", "wall.frame.fence", "wall.frame.cell", "foundation", "floor.frame", "floor.triangle", "floor", "foundation.steps", "foundation.triangle", "roof", "stairs.l", "stairs.u", "wall.doorway", "wall.frame", "wall.half", "wall.low", "wall.window", "wall", "wall.external.high.stone"
}
;
private List<ulong> BDayPlayers = new List<ulong>();
private List<BasePlayer> ConfCods = new List<BasePlayer>();
#endregion
#region Config
private ConfigData config;
private class ConfigData {
[JsonProperty(PropertyName = "Ключи VK API, ID группы")]
public VKAPITokens VKAPIT {
get;
set;
}
[JsonProperty(PropertyName = "Настройки оповещений администраторов")]
public AdminNotify AdmNotify {
get;
set;
}
[JsonProperty(PropertyName = "Настройки оповещений в беседу")]
public ChatNotify ChNotify {
get;
set;
}
[JsonProperty(PropertyName = "Настройки статуса")]
public StatusSettings StatusStg {
get;
set;
}
[JsonProperty(PropertyName = "Оповещения при вайпе")]
public WipeSettings WipeStg {
get;
set;
}
[JsonProperty(PropertyName = "Награда за вступление в группу")]
public GroupGifts GrGifts {
get;
set;
}
[JsonProperty(PropertyName = "Награда для именинников")]
public BDayGiftSet BDayGift {
get;
set;
}
[JsonProperty(PropertyName = "Поддержка нескольких серверов")]
public MultipleServersSettings MltServSet {
get;
set;
}
[JsonProperty(PropertyName = "Проверка игроков на читы")]
public PlayersCheckingSettings PlChkSet {
get;
set;
}
[JsonProperty(PropertyName = "Топ игроки вайпа и промо")]
public TopWPlPromoSet TopWPlayersPromo {
get;
set;
}
[JsonProperty(PropertyName = "Настройки чат команд")]
public CommandSettings CMDSet {
get;
set;
}
[JsonProperty(PropertyName = "Динамическая обложка группы")]
public DynamicGroupLabelSettings DGLSet {
get;
set;
}
public class VKAPITokens {
[JsonProperty(PropertyName = "VK Token группы (для сообщений)")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string VKToken {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "VK Token приложения (для записей на стене и статуса)")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string VKTokenApp {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "VKID группы")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string GroupID {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
}
public class AdminNotify {
[JsonProperty(PropertyName = "VkID администраторов (пример /11111, 22222/)")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string VkID {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "Включить отправку сообщений администратору командой /report ?")]
[DefaultValue(true)]
public bool SendReports {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Очистка базы репортов при вайпе?")]
[DefaultValue(true)]
public bool ReportsWipe {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Предупреждение о злоупотреблении функцией репортов")]
[DefaultValue("Наличие в тексте нецензурных выражений, оскорблений администрации или игроков сервера, а так же большое количество безсмысленных сообщений приведет к бану!")]
public string ReportsNotify {
get;
set;
}
= "Наличие в тексте нецензурных выражений, оскорблений администрации или игроков сервера, а так же большое количество безсмысленных сообщений приведет к бану!";
[JsonProperty(PropertyName = "Отправлять сообщение администратору о бане игрока?")]
[DefaultValue(true)]
public bool UserBannedMsg {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Комментарий в обсуждения о бане игрока?")]
[DefaultValue(false)]
public bool UserBannedTopic {
get;
set;
}
= false;
[JsonProperty(PropertyName = "ID обсуждения")]
[DefaultValue("none")]
public string BannedTopicID {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Отправлять сообщение администратору о нерабочих плагинах?")]
[DefaultValue(true)]
public bool PluginsCheckMsg {
get;
set;
}
= true;
}
public class ChatNotify {
[JsonProperty(PropertyName = "VK Token приложения (лучше использовать отдельную страницу для получения токена)")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string ChNotfToken {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "ID беседы")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string ChatID {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "Включить отправку оповещений в беседу?")]
[DefaultValue(false)]
public bool ChNotfEnabled {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Дополнительная отправка оповещений в личку администраторам?")]
[DefaultValue(false)]
public bool AdmMsg {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Список оповещений отправляемых в беседу (доступно: reports, wipe, bans, plugins)")]
[DefaultValue("reports, wipe, oxideupdate, bans")]
public string ChNotfSet {
get;
set;
}
= "reports, wipe, bans, plugins";
}
public class StatusSettings {
[JsonProperty(PropertyName = "Обновлять статус в группе? Если стоит /false/ статистика собираться не будет")]
[DefaultValue(true)]
public bool UpdateStatus {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Вид статуса (1 - текущий сервер, 2 - список серверов, необходим Rust:IO на каждом сервере)")]
[DefaultValue(1)]
public int StatusSet {
get;
set;
}
= 1;
[JsonProperty(PropertyName = "Онлайн в статусе вида '125/200'")]
[DefaultValue(false)]
public bool OnlWmaxslots {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Таймер обновления статуса (минуты)")]
[DefaultValue(30)]
public int UpdateTimer {
get;
set;
}
= 30;
[JsonProperty(PropertyName = "Формат статуса")]
[DefaultValue("{usertext}.Сервер вайпнут: {wipedate}.Онлайн игроков: {onlinecounter}.Спящих: {sleepers}.Добыто дерева: {woodcounter}.Добыто серы: {sulfurecounter}.Выпущено ракет: {rocketscounter}.Время обновления: {updatetime}.Использовано взрывчатки: {explosivecounter}.Создано чертежей: {blueprintsconter}.{connect}")]
public string StatusText {
get;
set;
}
= "{usertext}.Сервер вайпнут: {wipedate}.Онлайн игроков: {onlinecounter}.Спящих: {sleepers}.Добыто дерева: {woodcounter}.Добыто серы: {sulfurecounter}.Выпущено ракет: {rocketscounter}.Время обновления: {updatetime}.Использовано взрывчатки: {explosivecounter}.Создано чертежей: {blueprintsconter}.{connect}";
[JsonProperty(PropertyName = "Список счетчиков, которые будут отображаться в виде emoji")]
[DefaultValue("onlinecounter, rocketscounter, blueprintsconter, explosivecounter, wipedate")]
public string EmojiCounterList {
get;
set;
}
= "onlinecounter, rocketscounter, blueprintsconter, explosivecounter, wipedate";
[JsonProperty(PropertyName = "Ссылка на коннект сервера вида /connect 111.111.111.11:11111/")]
[DefaultValue("connect 111.111.111.11:11111")]
public string connecturl {
get;
set;
}
= "connect 111.111.111.11:11111";
[JsonProperty(PropertyName = "Текст для статуса")]
[DefaultValue("Сервер 1")]
public string StatusUT {
get;
set;
}
= "Сервер 1";
}
public class WipeSettings {
[JsonProperty(PropertyName = "Отправлять пост в группу после вайпа?")]
[DefaultValue(false)]
public bool WPostB {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Текст поста о вайпе")]
[DefaultValue("Заполните эти поля, и выполните команду o.reload VKBot")]
public string WPostMsg {
get;
set;
}
= "Заполните эти поля, и выполните команду o.reload VKBot";
[JsonProperty(PropertyName = "Добавить изображение к посту о вайпе?")]
[DefaultValue(false)]
public bool WPostAttB {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Ссылка на изображение к посту о вайпе вида 'photo-1_265827614' (изображение должно быть в альбоме группы)")]
[DefaultValue("photo-1_265827614")]
public string WPostAtt {
get;
set;
}
= "photo-1_265827614";
[JsonProperty(PropertyName = "Отправлять сообщение администратору о вайпе?")]
[DefaultValue(true)]
public bool WPostMsgAdmin {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Отправлять игрокам сообщение о вайпе автоматически?")]
[DefaultValue(false)]
public bool WMsgPlayers {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Текст сообщения игрокам о вайпе (сообщение отправляется только тем кто подписался командой /vk wipealerts)")]
[DefaultValue("Сервер вайпнут! Залетай скорее!")]
public string WMsgText {
get;
set;
}
= "Сервер вайпнут! Залетай скорее!";
[JsonProperty(PropertyName = "Игнорировать команду /vk wipealerts? (если включено, сообщение о вайпе будет отправляться всем)")]
[DefaultValue(false)]
public bool WCMDIgnore {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Смена названия группы после вайпа")]
[DefaultValue(false)]
public bool GrNameChange {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Название группы (переменная {wipedate} отображает дату последнего вайпа)")]
[DefaultValue("ServerName | WIPE {wipedate}")]
public string GrName {
get;
set;
}
= "ServerName | WIPE {wipedate}";
}
public class GroupGifts {
[JsonProperty(PropertyName = "Выдавать подарок игроку за вступление в группу ВК?")]
[DefaultValue(true)]
public bool VKGroupGifts {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Подарки за вступление в группу (shortname предмета, количество)")]
[DefaultValue(null)]
public Dictionary<string, object> VKGroupGiftList {
get;
set;
}
= new Dictionary<string, object> {
{
"supply.signal", 1
}
, {
"pookie.bear", 2
}
}
;
[JsonProperty(PropertyName = "Подарок за вступление в группу (команда, если стоит none выдаются предметы из списка выше).Пример: grantperm {steamid} vkraidalert.allow 7d")]
[DefaultValue("none")]
public string VKGroupGiftCMD {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Описание команды")]
[DefaultValue("Оповещения о рейде на 7 дней")]
public string GiftCMDdesc {
get;
set;
}
= "Оповещения о рейде на 7 дней";
[JsonProperty(PropertyName = "Ссылка на группу ВК")]
[DefaultValue("vk.com/1234")]
public string VKGroupUrl {
get;
set;
}
= "vk.com/1234";
[JsonProperty(PropertyName = "Оповещения в общий чат о получении награды")]
[DefaultValue(true)]
public bool GiftsBool {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Включить оповещения для игроков не получивших награду за вступление в группу?")]
[DefaultValue(true)]
public bool VKGGNotify {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Интервал оповещений для игроков не получивших награду за вступление в группу (в минутах)")]
[DefaultValue(30)]
public int VKGGTimer {
get;
set;
}
= 30;
[JsonProperty(PropertyName = "Выдавать награду каждый вайп?")]
[DefaultValue(true)]
public bool GiftsWipe {
get;
set;
}
= true;
}
public class BDayGiftSet {
[JsonProperty(PropertyName = "Включить награду для именинников?")]
[DefaultValue(true)]
public bool BDayEnabled {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Группа для именинников")]
[DefaultValue("bdaygroup")]
public string BDayGroup {
get;
set;
}
= "bdaygroup";
[JsonProperty(PropertyName = "Оповещения в общий чат о имениннках")]
[DefaultValue(false)]
public bool BDayNotify {
get;
set;
}
= false;
}
public class MultipleServersSettings {
[JsonProperty(PropertyName = "Включить поддержку несколько серверов?")]
[DefaultValue(false)]
public bool MSSEnable {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Номер сервера")]
[DefaultValue(1)]
public int ServerNumber {
get;
set;
}
= 1;
[JsonProperty(PropertyName = "Сервер 1 IP:PORT (пример: 111.111.111.111:28015)")]
[DefaultValue("none")]
public string Server1ip {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Название сервера 1 (если стоит none, используется номер)")]
[DefaultValue("none")]
public string Server1name {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Сервер 2 IP:PORT (пример: 111.111.111.111:28015)")]
[DefaultValue("none")]
public string Server2ip {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Название сервера 2 (если стоит none, используется номер)")]
[DefaultValue("none")]
public string Server2name {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Сервер 3 IP:PORT (пример: 111.111.111.111:28015)")]
[DefaultValue("none")]
public string Server3ip {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Название сервера 3 (если стоит none, используется номер)")]
[DefaultValue("none")]
public string Server3name {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Сервер 4 IP:PORT (пример: 111.111.111.111:28015)")]
[DefaultValue("none")]
public string Server4ip {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Название сервера 4 (если стоит none, используется номер)")]
[DefaultValue("none")]
public string Server4name {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Сервер 5 IP:PORT (пример: 111.111.111.111:28015)")]
[DefaultValue("none")]
public string Server5ip {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Название сервера 5 (если стоит none, используется номер)")]
[DefaultValue("none")]
public string Server5name {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Онлайн в emoji?")]
[DefaultValue(true)]
public bool EmojiStatus {
get;
set;
}
= true;
}
public class PlayersCheckingSettings {
[JsonProperty(PropertyName = "Текст уведомления")]
[DefaultValue("<color=#990404>Модератор вызвал вас на проверку.</color> \nНапишите свой скайп с помощью команды <color=#990404>/skype <НИК в СКАЙПЕ>.</color>\nЕсли вы покините сервер, Вы будете забанены на нашем проекте серверов.")]
public string PlCheckText {
get;
set;
}
= "<color=#990404>Модератор вызвал вас на проверку.</color> \nНапишите свой скайп с помощью команды <color=#990404>/skype <НИК в СКАЙПЕ>.</color>\nЕсли вы покините сервер, Вы будете забанены на нашем проекте серверов.";
[JsonProperty(PropertyName = "Размер текста")]
[DefaultValue(17)]
public int PlCheckSize {
get;
set;
}
= 17;
[JsonProperty(PropertyName = "Привилегия для команд /alert и /unalert")]
[DefaultValue("vkbot.checkplayers")]
public string PlCheckPerm {
get;
set;
}
= "vkbot.checkplayers";
[JsonProperty(PropertyName = "Бан игрока при выходе с сервера во время проверки")]
[DefaultValue(false)]
public bool AutoBan {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Позиция GUI AnchorMin (дефолт 0 0.826)")]
[DefaultValue("0 0.826")]
public string GUIAnchorMin {
get;
set;
}
= "0 0.826";
[JsonProperty(PropertyName = "Позиция GUI AnchorMax (дефолт 1 0.965)")]
[DefaultValue("1 0.965")]
public string GUIAnchorMax {
get;
set;
}
= "1 0.965";
}
public class TopWPlPromoSet {
[JsonProperty(PropertyName = "Включить топ игроков вайпа")]
[DefaultValue(true)]
public bool TopWPlEnabled {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Включить отправку промо кодов за топ?")]
[DefaultValue(false)]
public bool TopPlPromoGift {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Пост на стене группы о топ игроках вайпа")]
[DefaultValue(true)]
public bool TopPlPost {
get;
set;
}
= true;
[JsonProperty(PropertyName = "Ссылка на изображение к посту вида 'photo-1_265827614' (изображение должно быть в альбоме группы), оставить 'none' если не нужно")]
[DefaultValue("none")]
public string TopPlPostAtt {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Промо для топ рэйдера")]
[DefaultValue("topraider")]
public string TopRaiderPromo {
get;
set;
}
= "topraider";
[JsonProperty(PropertyName = "Ссылка на изображение к сообщению топ рейдеру вида 'photo-1_265827614' (изображение должно быть в альбоме группы), оставить 'none' если не нужно")]
[DefaultValue("none")]
public string TopRaiderPromoAtt {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Промо для топ килера")]
[DefaultValue("topkiller")]
public string TopKillerPromo {
get;
set;
}
= "topkiller";
[JsonProperty(PropertyName = "Ссылка на изображение к сообщению топ киллеру вида 'photo-1_265827614' (изображение должно быть в альбоме группы), оставить 'none' если не нужно")]
[DefaultValue("none")]
public string TopKillerPromoAtt {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Промо для топ фармера")]
[DefaultValue("topfarmer")]
public string TopFarmerPromo {
get;
set;
}
= "topfarmer";
[JsonProperty(PropertyName = "Ссылка на изображение к сообщению топ фармеру вида 'photo-1_265827614' (изображение должно быть в альбоме группы), оставить 'none' если не нужно")]
[DefaultValue("none")]
public string TopFarmerPromoAtt {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Ссылка на донат магазин")]
[DefaultValue("server.gamestores.ru")]
public string StoreUrl {
get;
set;
}
= "server.gamestores.ru";
[JsonProperty(PropertyName = "Автоматическая генерация промокодов после вайпа")]
[DefaultValue(false)]
public bool GenRandomPromo {
get;
set;
}
= false;
}
public class CommandSettings {
[JsonProperty(PropertyName = "Команда отправки сообщения администратору")]
[DefaultValue("report")]
public string CMDreport {
get;
set;
}
= "report";
[JsonProperty(PropertyName = "Команда вызова игрока на проверку")]
[DefaultValue("alert")]
public string CMDalert {
get;
set;
}
= "alert";
[JsonProperty(PropertyName = "Команда завершения проверки игрока")]
[DefaultValue("unalert")]
public string CMDunalert {
get;
set;
}
= "unalert";
[JsonProperty(PropertyName = "Команда отправки скайпа модератору")]
[DefaultValue("skype")]
public string CMDskype {
get;
set;
}
= "skype";
}
public class DynamicGroupLabelSettings {
[JsonProperty(PropertyName = "Включить динамическую обложку?")]
[DefaultValue(false)]
public bool DLEnable {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Ссылка на скрипт обновления")]
[DefaultValue("none")]
public string DLUrl {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Таймер обновления (в минутах)")]
[DefaultValue(10)]
public int DLTimer {
get;
set;
}
= 10;
[JsonProperty(PropertyName = "Обложка с онлайном нескольких серверов (все настройки ниже игнорируются)")]
[DefaultValue(false)]
public bool DLMSEnable {
get;
set;
}
= false;
[JsonProperty(PropertyName = "Текст блока 1 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText1 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 2 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText2 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 3 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText3 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 4 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText4 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 5 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText5 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 6 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText6 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Текст блока 7 (доступны все переменные как в статусе)")]
[DefaultValue("none")]
public string DLText7 {
get;
set;
}
= "none";
[JsonProperty(PropertyName = "Включить вывод топ игроков на обложку?")]
[DefaultValue(false)]
public bool TPLabel {
get;
set;
}
= false;
}
}
private void LoadVariables() {
bool changed = false;
Config.Settings.DefaultValueHandling = DefaultValueHandling.Populate;
config = Config.ReadObject<ConfigData>();
if (config.AdmNotify == null) {
config.AdmNotify = new ConfigData.AdminNotify();
changed = true;
}
if (config.ChNotify == null) {
config.ChNotify = new ConfigData.ChatNotify();
changed = true;
}
if (config.WipeStg == null) {
config.WipeStg = new ConfigData.WipeSettings();
changed = true;
}
if (config.GrGifts == null) {
config.GrGifts = new ConfigData.GroupGifts();
changed = true;
}
if (config.TopWPlayersPromo == null) {
config.TopWPlayersPromo = new ConfigData.TopWPlPromoSet();
changed = true;
}
if (config.CMDSet == null) {
config.CMDSet = new ConfigData.CommandSettings();
changed = true;
}
if (config.DGLSet == null) {
config.DGLSet = new ConfigData.DynamicGroupLabelSettings();
changed = true;
}
Config.WriteObject(config, true);
if (changed) PrintWarning("Конфигурационный файл обновлен.Добавлены новые настройки.Список изменений в плагине - vk.com/topic-30818042_36264027");
}
protected override void LoadDefaultConfig() {
var configData = new ConfigData {
VKAPIT = new ConfigData.VKAPITokens(), AdmNotify = new ConfigData.AdminNotify(), ChNotify = new ConfigData.ChatNotify(), StatusStg = new ConfigData.StatusSettings(), WipeStg = new ConfigData.WipeSettings(), GrGifts = new ConfigData.GroupGifts(), BDayGift = new ConfigData.BDayGiftSet(), MltServSet = new ConfigData.MultipleServersSettings(), PlChkSet = new ConfigData.PlayersCheckingSettings(), TopWPlayersPromo = new ConfigData.TopWPlPromoSet(), CMDSet = new ConfigData.CommandSettings(), DGLSet = new ConfigData.DynamicGroupLabelSettings()
}
;
Config.WriteObject(configData, true);
PrintWarning("Поддержи разработчика! Вступи в группу vk.com/vkbotrust");
PrintWarning("Инструкция по настройке плагина - goo.gl/xRkEUa");
}
#endregion
#region Datastorage
class DataStorageStats {
public int WoodGath;
public int SulfureGath;
public int Rockets;
public int Blueprints;
public int Explosive;
public int Reports;
public DataStorageStats() {
}
}
class DataStorageUsers {
public Dictionary<ulong, VKUDATA> VKUsersData = new Dictionary<ulong, VKUDATA>();
public DataStorageUsers() {
}
}
class VKUDATA {
public ulong UserID;
public string Name;
public string VkID;
public int ConfirmCode;
public bool Confirmed;
public bool GiftRecived;
public string LastRaidNotice;
public bool WipeMsg;
public string Bdate;
public int Raids;
public int Kills;
public int Farm;
}
class DataStorageReports {
public Dictionary<int, REPORT> VKReportsData = new Dictionary<int, REPORT>();
public DataStorageReports() {
}
}
class REPORT {
public ulong UserID;
public string Name;
public string Text;
}
DataStorageStats statdata;
DataStorageUsers usersdata;
DataStorageReports reportsdata;
private DynamicConfigFile VKBData;
private DynamicConfigFile StatData;
private DynamicConfigFile ReportsData;
void LoadData() {
try {
statdata = Interface.GetMod().DataFileSystem.ReadObject<DataStorageStats>("VKBot");
usersdata = Interface.GetMod().DataFileSystem.ReadObject<DataStorageUsers>("VKBotUsers");
reportsdata = Interface.GetMod().DataFileSystem.ReadObject<DataStorageReports>("VKBotReports");
}
catch {
statdata = new DataStorageStats();
usersdata = new DataStorageUsers();
reportsdata = new DataStorageReports();
}
}
#endregion
#region Oxidehooks
void OnServerInitialized() {
LoadVariables();
VKBData = Interface.Oxide.DataFileSystem.GetFile("VKBotUsers");
StatData = Interface.Oxide.DataFileSystem.GetFile("VKBot");
ReportsData = Interface.Oxide.DataFileSystem.GetFile("VKBotReports");
LoadData();
cmd.AddChatCommand(config.CMDSet.CMDalert, this, "StartCheckPlayer");
cmd.AddChatCommand(config.CMDSet.CMDunalert, this, "StopCheckPlayer");
cmd.AddChatCommand(config.CMDSet.CMDskype, this, "SkypeSending");
cmd.AddChatCommand(config.CMDSet.CMDreport, this, "SendReport");
CheckAdminID();
if (!permission.PermissionExists(config.PlChkSet.PlCheckPerm)) permission.RegisterPermission(config.PlChkSet.PlCheckPerm, this);
if (NewWipe) {
WipeFunctions(mapfile);
}
if (config.StatusStg.UpdateStatus) {
if (config.StatusStg.StatusSet == 1) {
timer.Repeat(config.StatusStg.UpdateTimer * 60, 0, Update1ServerStatus);
}
if (config.StatusStg.StatusSet == 2) {
timer.Repeat(config.StatusStg.UpdateTimer * 60, 0, () => {
UpdateMultiServerStatus("status");
}
);
}
}
if (config.DGLSet.DLEnable && config.DGLSet.DLUrl != "none") {
timer.Repeat(config.DGLSet.DLTimer * 60, 0, () => {
if (config.DGLSet.DLMSEnable) {
UpdateMultiServerStatus("label");
}
else {
UpdateVKLabel();
}
}
);
}
if (config.GrGifts.VKGGNotify) {
timer.Repeat(config.GrGifts.VKGGTimer * 60, 0, GiftNotifier);
}
if (config.AdmNotify.PluginsCheckMsg) {
CheckPlugins();
}
}
void OnServerSave() {
if (config.TopWPlayersPromo.TopWPlEnabled) {
VKBData.WriteObject(usersdata);
}
if (config.StatusStg.UpdateStatus || config.DGLSet.DLEnable) {
StatData.WriteObject(statdata);
}
}
private void Init() {
cmd.AddChatCommand("vk", this, "VKcommand");
cmd.AddConsoleCommand("updatestatus", this, "UStatus");
cmd.AddConsoleCommand("updatelabel", this, "ULabel");
cmd.AddConsoleCommand("sendmsgadmin", this, "MsgAdmin");
cmd.AddConsoleCommand("wipealerts", this, "WipeAlerts");
cmd.AddConsoleCommand("userinfo", this, "GetUserInfo");
cmd.AddConsoleCommand("report.answer", this, "ReportAnswer");
cmd.AddConsoleCommand("report.list", this, "ReportList");
cmd.AddConsoleCommand("report.wipe", this, "ReportClear");
jsonsettings = new JsonSerializerSettings();
jsonsettings.Converters.Add(new KeyValuePairConverter());
}
void Loaded() {
LoadMessages();
}
void Unload() {
if (config.AdmNotify.SendReports) {
ReportsData.WriteObject(reportsdata);
}
if (config.StatusStg.UpdateStatus || config.DGLSet.DLEnable) {
StatData.WriteObject(statdata);
}
if (config.TopWPlayersPromo.TopWPlEnabled) {
VKBData.WriteObject(usersdata);
}
if (PlayersCheckList.Count != 0) {
foreach (var player in PlayersCheckList) {
var target = BasePlayer.FindByID(player.Value);
if (target != null) StopGui(target);
}
PlayersCheckList.Clear();
}
if (config.BDayGift.BDayEnabled && BDayPlayers.Count > 0) {
foreach (var id in BDayPlayers) {
permission.RemoveUserGroup(id.ToString(), config.BDayGift.BDayGroup);
}
BDayPlayers.Clear();
}
if (ConfCods.Count != 0) {
foreach (var pl in ConfCods) {
CuiHelper.DestroyUi(pl, "VKConfGUI");
}
ConfCods.Clear();
}
}
void OnNewSave(string filename) {
NewWipe = true;
mapfile = filename;
}
void OnPlayerInit(BasePlayer player) {
if (usersdata.VKUsersData.ContainsKey(player.userID)) {
if (usersdata.VKUsersData[player.userID].Name != player.displayName) {
usersdata.VKUsersData[player.userID].Name = player.displayName;
VKBData.WriteObject(usersdata);
}
if (usersdata.VKUsersData[player.userID].Bdate == null) {
AddBdate(player);
}
}
}
void OnPlayerSleepEnded(BasePlayer player) {
if (!usersdata.VKUsersData.ContainsKey(player.userID)) return;
if (!config.BDayGift.BDayEnabled) return;
if (config.BDayGift.BDayEnabled && permission.GroupExists(config.BDayGift.BDayGroup)) {
if (permission.UserHasGroup(player.userID.ToString(), config.BDayGift.BDayGroup)) return;
var today = DateTime.Now.ToString("d.M", CultureInfo.InvariantCulture);
var bday = usersdata.VKUsersData[player.userID].Bdate;
if (bday == null || bday == "noinfo") return;
string[] array = bday.Split('.');
if (array.Length == 3) {
bday.Remove(bday.Length - 5, 5);
}
if (bday == today) {
permission.AddUserGroup(player.userID.ToString(), config.BDayGift.BDayGroup);
PrintToChat(player, string.Format(GetMsg("ПоздравлениеИгрока", player)));
Log("bday", $"Игрок {player.displayName} добавлен в группу {config.BDayGift.BDayGroup}");
BDayPlayers.Add(player.userID);
if (config.BDayGift.BDayNotify) {
Server.Broadcast(string.Format(GetMsg("ДеньРожденияИгрока", player), player.displayName));
}
}
}
}
void OnPlayerDisconnected(BasePlayer player, string reason) {
if (PlayersCheckList.Count != 0) {
if (PlayersCheckList.ContainsValue(player.userID)) {
CuiHelper.DestroyUi(player, "AlertGUI");
BasePlayer moder = null;
for (int i = 0; i < PlayersCheckList.Count; i++) {
if (PlayersCheckList.ElementAt(i).Value == player.userID) {
ulong moderid = PlayersCheckList.ElementAt(i).Key;
moder = BasePlayer.FindByID(moderid);
PlayersCheckList.Remove(moderid);
if (moder != null) {
PrintToChat(moder, $"Игрок вызванный на проверку покинул сервер.Причина: {reason}");
}
}
}
if (config.PlChkSet.AutoBan && reason == "Disconnected") {
player.IPlayer.Ban("Отказ от проверки");
if (player.IsConnected) {
player.Kick("banned");
}
}
}
if (PlayersCheckList.ContainsKey(player.userID)) {
ulong targetid;
PlayersCheckList.TryGetValue(player.userID, out targetid);
BasePlayer target = BasePlayer.FindByID(targetid);
if (target != null) {
CuiHelper.DestroyUi(target, "AlertGUI");
PrintToChat(target, string.Format(GetMsg("МодераторОтключился", player)));
}
PlayersCheckList.Remove(player.userID);
}
}
if (config.BDayGift.BDayEnabled && permission.GroupExists(config.BDayGift.BDayGroup)) {
if (BDayPlayers.Contains(player.userID)) {
permission.RemoveUserGroup(player.userID.ToString(), config.BDayGift.BDayGroup);
BDayPlayers.Remove(player.userID);
Log("bday", $"Игрок {player.displayName} удален из группы {config.BDayGift.BDayGroup}");
}
}
if (ConfCods.Count != 0 && ConfCods.Contains(player)) {
CuiHelper.DestroyUi(player, "VKConfGUI");
ConfCods.Remove(player);
}
}
void OnPlayerBanned(string name, ulong id, string address, string reason) {
string msg2 = null;
if (config.MltServSet.MSSEnable) {
msg2 = $"[Сервер {config.MltServSet.ServerNumber.ToString()}] Игрок {name} ({id}) был забанен на сервере.Причина: {reason}.Ссылка на профиль стим: steamcommunity.com/profiles/{id}/";
}
else {
msg2 = $"Игрок {name} ({id}) был забанен на сервере.Причина: {reason}.Ссылка на профиль стим: steamcommunity.com/profiles/{id}/";
}
if (config.AdmNotify.UserBannedTopic && config.AdmNotify.BannedTopicID != "null") {
if (reason == "GAMEBAN" || reason ==
// ... [Code preview truncated due to length. Full source in attached file] ...