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

FREE ozProtect : 0.3.4 0.3.4

Нет прав для скачивания
C#:
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Oxide.Core.Libraries.Covalence;
using System;
using System.Globalization;
using UnityEngine.UI;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Net;
using Network;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("ozProtect", "Company ozLiginus", "0.3.4")]
    [Description("ozProtect for Rust")]
    class ozProtect : RustPlugin {
        //////////////////////////////////////////////////////////////////////////////////////////
        ///// Configuration
        //////////////////////////////////////////////////////////////////////////////////////////
        int action = 2;
        // Что делать если игрок забанен на других серверах? (0 ничего, 1 уведомлять, 2 кикать, 3 банить)
        int timebanhours = 1000;
        // На сколько часов банить? (Если action = 3)
        bool serverbroadcast = true;
        // Использовать Server Broadcast?
        private void Init() {
            permission.RegisterPermission("ozprotect.check", this);
            // Пермишен для использования команнды /cc (name) open/close (Для администрации и модераторов)
            permission.RegisterPermission("ozprotect.nokick", this);
            // Пермишен антикика (Для администрации и модераторов)
            permission.RegisterPermission("ozprotect.nokickbloody", this);
            // Пермишен антикика для владельцев Bloody
        }
        private object OnEacKickMouse(Connection connection) {
            Puts("OnEacKickMouse: " + BasePlayer.FindByID(connection.userid).IPlayer.Name);
            if (!BasePlayer.FindByID(connection.userid).IPlayer.HasPermission("ozprotect.nokickbloody")) {
                BasePlayer.FindByID(connection.userid).IPlayer.Kick("Чтобы играть с Bloody купите подписку в магазине сервера.");
            }
            else {
                return null;
            }
            return true;
        }
        private void Unload() {
            foreach (BasePlayer player in BasePlayer.activePlayerList) {
                DestroyUI(player);
            }
        }
#region CUI
        [PluginReference]
        private Plugin ImageLibrary;
        //private Plugin ozfix, ozpanel, NoteUI;
        private string GetImg(string name) {
            return (string) ImageLibrary?.Call("GetImage", name);
        }
        private void Loaded() {
            Server.Broadcast($"<color=#FFFB00>The server is secure. Base cheaters updated</color>", "<color=#FF6A00>ozProtect</color>");
            string sURL = "https://ozprotect.ozliginus.ru/api/magicbans";
            // Обновить баны с магика
            webrequest.EnqueueGet(sURL, (cod, reason) => MagicBans(cod, reason), this);
        }
        private void MagicBans(int code, string response) {
            Server.Broadcast($"<color=#FFFB00>Link to Ban List: ozprotect.ozliginus.ru/banlog</color>", "<color=#FF6A00>ozProtect</color>");
        }
        // Layers
        private string Layer = "check_body";
        // Materials
        private string Sharp = "assets/content/ui/ui.background.tile.psd";
        private string Blur = "assets/content/ui/uibackgroundblur.mat";
        private string radial = "assets/content/ui/ui.background.transparent.radial.psd";
        private string regular = "robotocondensed-regular.ttf";
        // Отрисовка менюшки
        private void DrawUI(BasePlayer player, BasePlayer pr) {
            if (player.HasFlag(BaseEntity.Flags.Reserved4)) return;
            player.SetFlag(BaseEntity.Flags.Reserved4, true);
            CuiElementContainer container = new CuiElementContainer();
            // Body
            container.Add(new CuiPanel {
                Image = {
                    FadeIn = 0.2f, Color = "0 0 0 0"
                }
                , RectTransform = {
                    AnchorMin = "0 0.861", AnchorMax = "1 1"
                }
                , CursorEnabled = false
            }
            , "Overlay", Layer);
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0.5", Material = "assets/content/ui/uibackgroundblur.mat", Command = "check.close"
                }
                , Text = {
                    Text = ""
                }
            }
            , Layer);
            container.Add(new CuiLabel {
                Text = {
                    FadeIn = 0.2f, Text = "Вы подозреваетесь в использовании читов. Пройдите проверку на наличие читов. Напишите свой дискорд через команду /pm " + pr.IPlayer.Name + ". \nЕсли Вы покините сервер, Вы будете забанены на всех серверах zRust. У вас есть 5 минут. Удачи :)", FontSize = 16, Align = TextAnchor.MiddleCenter, Color = HexToRustFormat("#FFFFFF") , Font = "robotocondensed-bold.ttf"
                }
                , RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
            }
            , Layer, Layer + ".text");
            // ============================================================= Отрисовка
            CuiHelper.AddUi(player, container);
        }
        // Закрытие менюшки
        private void DestroyUI(BasePlayer player) {
            CuiHelper.DestroyUi(player, Layer);
            player.SetFlag(BaseEntity.Flags.Reserved4, false);
        }
#endregion
#region Commands
        [ChatCommand("check")]
        private void cmdMenu(BasePlayer player, string command, string[] args) {
            CheckFunc(player, command, args);
        }
        [ChatCommand("cc")]
        private void cmdMenucc(BasePlayer player, string command, string[] args) {
            CheckFunc(player, command, args);
        }
        private void CheckFunc(BasePlayer player, string command, string[] args) {
            if (player.IPlayer.HasPermission("ozprotect.check")) {
                if (args.Length > 0) {
                    var target = FindPlayer(args[0]);
                    if (target.IsConnected) {
                        if(args[1] == "close") {
                            DestroyUI(target);
                            player.IPlayer.Message("ozProtect: <color=#77FF00>Игрок " + target.IPlayer.Name + " прошёл проверку</color>");
                            target.IPlayer.Message("ozProtect: <color=#77FF00>Вы прошли проверку. Приятной игры!</color>");
                            Puts("ozProtect: <color=#77FF00>Игрок " + target.IPlayer.Name + " прошёл проверку</color>");
                            if(serverbroadcast == true) {
                                Server.Broadcast($"<color=#77FF00>Игрок " + target.IPlayer.Name + " прошёл проверку</color>", "<color=#FF6A00>ozProtect</color>");
                            }
                        }
                        else if (args[1] == "open") {
                            DrawUI(target, player);
                            player.IPlayer.Message("ozProtect: <color=#FFFB00>Игрок " + target.IPlayer.Name + " вызван на проверку</color>");
                            target.IPlayer.Message("ozProtect: <color=#FFFB00>Вас вызвали на проверку</color>");
                            Puts("ozProtect: <color=#FFFB00>Игрок " + target.IPlayer.Name + " вызван на проверку</color>");
                            if(serverbroadcast == true) {
                                Server.Broadcast($"<color=#FFFB00>Игрок " + target.IPlayer.Name + " вызван на проверку</color>", "<color=#FF6A00>ozProtect</color>");
                            }
                        }
                    }
                    else {
                        player.IPlayer.Message("ozProtect: Игрок <color=#FF0000>Оффлайн</color>");
                    }
                }
                else {
                    player.IPlayer.Message("Используйте: <color=#BEF781>/check or /cc [Nickname] [open/close]</color>");
                }
            }
        }
        /*[ChatCommand("connecttest")]
		private void GetRequest(BasePlayer player, string command, string[] args)
		{
			string sURL = "https://ozprotect.ozliginus.ru/api/getuser?steamid=" + player.userID + "&param=ban"; // Получить только 1 или 0 (1 забанен, 0 нет)
			//string sURL = "https://ozprotect.ozliginus.ru/api/user?steamid=" + player.userID; // Получить информацию о пользователе в виде json
			webrequest.EnqueueGet(sURL, (code, response) => CheckBan(code, response, player), this);
		}*/
        private void CheckBan(int code, string response, BasePlayer player) {
            if(response == "1") {
                string sURL = "https://ozprotect.ozliginus.ru/api/getuser?steamid=" + player.userID + "&param=reasonban";
                // Получить только reasonban
                webrequest.EnqueueGet(sURL, (cod, reason) => Reason(cod, reason, player), this);
            }
        }
        private void Reason(int cod, string reason, BasePlayer player) {
            Puts("Игрок " + player.IPlayer.Name + " был забанен на других серверах. Причина: " + reason);
            Server.Broadcast($"<color=#FFFB00>Игрок {player.displayName} был забанен на других серверах.</color>", "<color=#FF0000>Внимание!</color>");
            Server.Broadcast($"<color=#FFFB00>{reason}</color>", "<color=#FF0000>Причина</color>");
            if(action == 1) {
                // Уведомлять
                player.IPlayer.Message("ozProtect: <color=#FF0000>Вы забанены на других серверах</color>");
                player.IPlayer.Message("Причина: <color=#FFFB00>" + reason + "</color>");
            }
            else if(action == 2) {
                // Кикать
                if (!player.IPlayer.HasPermission("ozprotect.nokick")) {
                    player.IPlayer.Kick(reason);
                }
            }
            else if(action == 3) {
                // Банить
                player.IPlayer.Ban(reason, new TimeSpan(timebanhours, 0, 0));
            }
        }
        private void Banned(int cod, string reason, BasePlayer player) {
            Puts("ozProtect ban: " + reason);
            player.IPlayer.Message("ozProtect: <color=#FF0000>Игрок занесён в базу</color>");
        }
#endregion
#region Functions
        private static string GET(string Url, string Data) {
            System.Net.WebRequest req = System.Net.WebRequest.Create(Url + "?" + Data);
            System.Net.WebResponse resp = req.GetResponse();
            System.IO.Stream stream = resp.GetResponseStream();
            System.IO.StreamReader sr = new System.IO.StreamReader(stream);
            string Out = sr.ReadToEnd();
            sr.Close();
            return Out;
        }
        private static string HexToRustFormat(string hex) {
            if (string.IsNullOrEmpty(hex)) {
                hex = "#FFFFFFFF";
            }
            var str = hex.Trim('#');
            if (str.Length == 6) str += "FF";
            if (str.Length != 8) {
                throw new Exception(hex);
                throw new InvalidOperationException("Cannot convert a wrong format.");
            }
            var r = byte.Parse(str.Substring(0, 2), NumberStyles.HexNumber);
            var g = byte.Parse(str.Substring(2, 2), NumberStyles.HexNumber);
            var b = byte.Parse(str.Substring(4, 2), NumberStyles.HexNumber);
            var a = byte.Parse(str.Substring(6, 2), NumberStyles.HexNumber);
            Color color = new Color32(r, g, b, a);
            return string.Format("{0:F2} {1:F2} {2:F2} {3:F2}", color.r, color.g, color.b, color.a);
        }
        private static BasePlayer FindPlayer(string nameOrIdOrIp) {
            foreach (var activePlayer in BasePlayer.activePlayerList) {
                if (activePlayer.UserIDString == nameOrIdOrIp) return activePlayer;
                if (activePlayer.displayName.Contains(nameOrIdOrIp, CompareOptions.OrdinalIgnoreCase)) return activePlayer;
                if (activePlayer.net?.connection != null && activePlayer.net.connection.ipaddress == nameOrIdOrIp) return activePlayer;
            }
            return null;
        }
        private static BasePlayer FindPlayer(ulong id) {
            foreach (var activePlayer in BasePlayer.activePlayerList) {
                if (activePlayer.userID == id) return activePlayer;
            }
            return null;
        }
#endregion
#region Hooks
        private void OnPlayerConnected(BasePlayer player) {
            string sURL = "https://ozprotect.ozliginus.ru/api/getuser?steamid=" + player.userID + "&param=ban";
            // Получить только 1 или 0 (1 забанен, 0 нет)
            webrequest.EnqueueGet(sURL, (code, response) => CheckBan(code, response, player), this);
        }
#endregion
    }
}

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