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

FREE XAntiCheat : 0.3.79 0.3.79

Нет прав для скачивания
C#:
using System;
using System.Collections.Generic;
using Facepunch;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using System.Linq;
using UnityEngine;
using Oxide.Core;
using Random = UnityEngine.Random;
using Rust;
using ProtoBuf;
namespace Oxide.Plugins {
    [Info("XAntiCheat", "fermens", "0.3.79")]
    public class XAntiCheat : RustPlugin {
        const string ipinnfourl = "https://ipinfo.io/{ip}/privacy?token={token}";
        const bool enablefull = true;
        const string ipinfosingup = "https://ipinfo.io/signup";
#region CODE LOCK
        private static bool IsBanned(ulong userid) {
            return ServerUsers.Is(userid, ServerUsers.UserGroup.Banned);
        }
        private static bool IsImprisoned(ulong userid) {
            if (ins.PrisonBitch == null) return false;
            return ins.PrisonBitch.Call<bool>("ISIMPRISONED", userid);
        }
        private void OnCodeEntered(CodeLock codeLock, BasePlayer player, string code) {
            if (player == null) return;
            ulong owner = codeLock.OwnerID;
            if (owner == 0UL || code != codeLock.code) return;
            bool bann = IsBanned(owner);
            bool unprisoned = IsImprisoned(owner);
            if(bann || unprisoned) {
                ADDLOG($"{player.displayName}({player.UserIDString}) ввёл пароль от кодового замка {(bann ? "забанненого" : "заключенного")} игрока({owner})!", 2);
                if (config.cODELOCK.enable) {
                    timer.Once(config.cODELOCK.seconds, () => {
                        BAN(player.UserIDString, config.cODELOCK.reason, config.cODELOCK.hours, player.displayName);
                    }
                    );
                }
            }
        }
#endregion
#region КОНФИГ
        private static PluginConfig config;
        protected override void LoadDefaultConfig() {
            config = PluginConfig.DefaultConfig();
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            config = Config.ReadObject<PluginConfig>();
        }
        protected override void SaveConfig() {
            Config.WriteObject(config);
        }
        class SILENT {
            [JsonProperty("Автобан (не знаешь, не трогай!)")]
            public int xdetects;
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class SPIDER {
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class FLY {
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class HITMOD {
            [JsonProperty("Банить?")]
            public bool enable;
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class CODELOCK {
            [JsonProperty("Банить?")]
            public bool enable;
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("Задержка в секундах перед баном, после детекта")]
            public float seconds;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class TEAMBAN {
            [JsonProperty("Банить?")]
            public bool enable;
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("Банить, если в команде N забаненных")]
            public int num;
            [JsonProperty("Учитывать бан за макрос?")]
            public bool macros;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class SMARTBAN {
            [JsonProperty("Банить?")]
            public bool enable;
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("Fly: очков")]
            public int fly;
            [JsonProperty("EspStash: очков")]
            public int espstash;
            [JsonProperty("Macro: очков")]
            public int macro;
            [JsonProperty("HitMod: очков")]
            public int hitmod;
            [JsonProperty("Spider: очков")]
            public int spider;
            [JsonProperty("Silent: очков")]
            public int silent;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        class ESPSTASH {
            [JsonProperty("Количество")]
            public int amount;
            [JsonProperty("Возможный лут")]
            public Dictionary<string, int> loots;
        }
        class MACROS {
            [JsonProperty("Причина бана")]
            public string reason;
            [JsonProperty("Количество выстрелов")]
            public int shoots;
            [JsonProperty("Количество детектов")]
            public int amount;
            [JsonProperty("На сколько часов бан?")]
            public int hours;
        }
        private class PluginConfig {
            [JsonProperty("SteamAPI")]
            public string steampi;
            [JsonProperty("Silent Aim: настройка")]
            public SILENT sILENT;
            [JsonProperty("Spider: настройка")]
            public SPIDER sPIDER;
            [JsonProperty("ESP SmallStash: настройка")]
            public ESPSTASH ESPStash;
            [JsonProperty("FLY: настройка")]
            public FLY fLY;
            [JsonProperty("TEAMBAN: настройка")]
            public TEAMBAN tEAMBAN;
            [JsonProperty("CODELOCK: настройка")]
            public CODELOCK cODELOCK;
            [JsonProperty("HITMOD: настройка")]
            public HITMOD hITMOD;
            [JsonProperty("MACROS: настройка")]
            public MACROS mACROS;
            [JsonProperty("Debug camera: Банить?")]
            public bool debugcamera;
            [JsonProperty("Отображать данные при подключении игрока?")]
            public bool show;
            [JsonProperty("Не банить Steam игроков?")]
            public bool steamplayer;
            [JsonProperty("Отправлять в тюрьму, если есть плагин PrisonBitch")]
            public bool prison;
            [JsonProperty("Банить не настроеные аккаунты?")]
            public bool bannensatroyen;
            [JsonProperty("Банить аккаунты, которым меньше X дней")]
            public int banday;
            [JsonProperty("На сколько часов банить новые аккаунты")]
            public int bannewaccountday;
            [JsonProperty("Кикать не настроенные аккаунты")]
            public bool kicknenastoyen;
            [JsonProperty("Кикать приватные аккаунты")]
            public bool kickprivate;
            [JsonProperty("Кикать игроков использующих VPN")]
            public bool kickvpn;
            [JsonProperty("Не кикать лицухи?")]
            public bool steamkick;
            [JsonProperty("Не банить лицушников за новые аккаунты?")]
            public bool steam;
            [JsonProperty("Писать/сохранять логи [0 - нет | 1 - только баны | 2 - все]")]
            public int logspriority;
            [JsonProperty("Discord: ID канала")]
            public string discordid;
            [JsonProperty(" Логи попаданий с огнестрела в консоль")]
            public bool logs;
            [JsonProperty("IPINFO ТОКЕН")]
            public string ipinfotoken;
            [JsonProperty("tt")]
            public string tt;
            [JsonProperty("Сообщения")]
            public Dictionary<string, string> messages;
            [JsonProperty("Шаблоны банов")]
            public Dictionary<string, string> pattern;
            public static PluginConfig DefaultConfig() {
                return new PluginConfig() {
                    ipinfotoken = ipinfosingup, kickvpn = false, tEAMBAN = new TEAMBAN {
                        enable = true, hours = 168, reason = "\"bb with teammates\"", num = 2
                    }
                    , cODELOCK = new CODELOCK {
                        enable = true, hours = 336, reason = "\"Ban Detected! (1)\"", seconds = 75
                    }
                    , sPIDER = new SPIDER {
                        hours = 720, reason = "\"Cheat Detected! (2)\""
                    }
                    , sILENT = new SILENT {
                        xdetects = 7, hours = 1440, reason = "\"Cheat Detected! (1)\""
                    }
                    , fLY = new FLY {
                        hours = 720, reason = "\"Cheat Detected! (3)\""
                    }
                    , hITMOD = new HITMOD {
                        enable = true, hours = 720, reason = "\"Cheat Detected! (6)\""
                    }
                    , mACROS = new MACROS {
                        amount = 5, hours = 168, reason = "\"Macros Detected!\"", shoots = 10
                    }
                    , prison = true, steamkick = true, debugcamera = true, logs = false, steam = true, steampi = defaultsteamapi, banday = 5, kicknenastoyen = true, kickprivate = true, tt = "nothing", bannensatroyen = false, show = true, bannewaccountday = 120, steamplayer = false, messages = new Dictionary<string, string> {
                        {
                            "NEW.ACCOUNT", "\"Подозрительный аккаунт\""
                        }
                        , {
                            "KICK.PRIVATE", "\"Откройте профиль, что бы играть на этом сервере! (Make your Steam profile public to play on this server)\""
                        }
                        , {
                            "KICK.NENASTROYEN", "\"Настройте профиль, что бы играть на этом сервере! (Make your Steam profile public to play on this server)\""
                        }
                        , {
                            "KICK.VPN", "\"На сервере запрещено играть с VPN! (VPN DETECTED)\""
                        }
                    }
                    , pattern = new Dictionary<string, string> {
                        {
                            "BAN.ACCOUNT", "ban {steamid} {reason} {time}"
                        }
                        , {
                            "PRISON.ACCOUNT", "prison.add {steamid} {time} {reason}"
                        }
                        ,
                    }
                    , logspriority = 2, ESPStash = new ESPSTASH {
                        amount = 100, loots = new Dictionary<string, int> {
                            {
                                "rifle.ak", 1
                            }
                            , {
                                "rifle.bolt", 1
                            }
                            , {
                                "rifle.l96", 1
                            }
                            , {
                                "rifle.lr300", 1
                            }
                            , {
                                "rifle.semiauto", 1
                            }
                            , {
                                "wood", 10000
                            }
                            , {
                                "stones", 10000
                            }
                            , {
                                "metal.refined", 50
                            }
                            , {
                                "metal.fragments", 10000
                            }
                            , {
                                "metal.facemask", 1
                            }
                            , {
                                "scrap", 500
                            }
                            ,
                        }
                    }
                    , discordid = ""
                }
                ;
            }
        }
#endregion
        int nsnext = 0;
        [ChatCommand("ns")]
        private void COMMANSTASH(BasePlayer player, string command, string[] args) {
            if (!player.IsAdmin) return;
            player.Teleport(stashContainers[nsnext].transform.position + Vector3.up * 1.5f);
            nsnext++;
            if (stashContainers.Count >= nsnext) nsnext = 0;
        }
        Vector3 lastshash;
        [ChatCommand("ls")]
        private void COMMALS(BasePlayer player, string command, string[] args) {
            if (!player.IsAdmin) return;
            if(lastshash == Vector3.zero) {
                player.ChatMessage("<color=yellow>Еще не раскопали ни одного стеша!</color>");
                return;
            }
            player.Teleport(lastshash + Vector3.up * 1.5f);
        }
        [ChatCommand("testaim")]
        private void COMMANDERAIM(BasePlayer player, string command, string[] args) {
            if (!player.IsAdmin) return;
            TESTAIM(player);
        }
        [ConsoleCommand("test.aim")]
        private void cmdtest(ConsoleSystem.Arg arg) {
            if (!arg.IsAdmin || !arg.HasArgs()) return;
            ulong ID;
            if(!ulong.TryParse(arg.Args[0], out ID)) {
                arg.ReplyWith("ЭТО НЕ СТИМ ИД!");
                return;
            }
            BasePlayer player = BasePlayer.FindByID(ID);
            if(player == null) {
                arg.ReplyWith("ИГРОК НЕ НАЙДЕН!");
                return;
            }
            TESTAIM(player);
        }
        /* Dictionary<BasePlayer, DateTime> lastbowtime = new Dictionary<BasePlayer, DateTime>();
        void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles)
        {
            if (player == null || projectile == null || mod == null || projectiles == null)  return;
            Item item = player.GetActiveItem();
            if (item == null || item.info.itemid != 1443579727)  return;
            DateTime dateTime;
            if (!lastbowtime.TryGetValue(player, out dateTime))
            {
                lastbowtime[player] = DateTime.Now;
                return;
            }
            Debug.Log(player.displayName + " - " + (DateTime.Now- dateTime).TotalMilliseconds);
            lastbowtime[player] = DateTime.Now;
        }*/
        private void TESTAIM(BasePlayer player) {
            int i = 0;
            Vector3 head = player.eyes.MovementForward();
            Debug.Log($"{i}.{player.displayName} - {player.eyes.HeadForward()} - {player.eyes.MovementForward()}");
            Vector3 pos = new Vector3(player.transform.position.x + (10f * player.eyes.MovementForward().x), 500f, player.transform.position.z + (10f * head.z));
            //  Vector3 vector3 = player.eyes.BasePlayer npc = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", new Vector3(pos.x, TerrainMeta.HeightMap.GetHeight(pos) - 2f, pos.z), new Quaternion(), true) as BasePlayer;
            if (npc == null) return;
            npc.enableSaving = false;
            npc.Spawn();
            NextTick(() => {
                PlayerInventory inv = npc.GetComponent<PlayerInventory>();
                inv.Strip();
            }
            );
            timer.Repeat(0.1f, 20, () => {
                i++;
                Debug.Log($"{i}.{player.displayName} - {player.eyes.HeadForward()}");
            }
            );
            timer.Once(2.5f, () => {
                if (!npc.IsDead()) npc.Kill();
            }
            );
        }
        [ChatCommand("testfly")]
        private void COMMANDER(BasePlayer player, string command, string[] args) {
            if (player.IsAdmin) {
                List<BaseEntity> list = Pool.GetList<BaseEntity>();
                Vis.Entities<BaseEntity>(player.transform.position, 2f, list);
                List<TreeEntity> list2 = Pool.GetList<TreeEntity>();
                Vis.Entities<TreeEntity>(player.transform.position, 8.5f, list2);
                string elements = "";
                bool pl = false;
                foreach (var z in list) {
                    if (z is BasePlayer && (z as BasePlayer) != player) pl = true;
                    elements += z.ShortPrefabName + (list.Count > 1 ? " | " : "");
                }
                RaycastHit hit;
                var raycast = Physics.Raycast(player.transform.position, Vector3.down, out hit, 500f);
                if (raycast) {
                    bool spider = false;
                    RaycastHit hit2;
                    var raycast2 = Physics.Raycast(player.transform.position, player.eyes.BodyForward(), out hit2, 1f);
                    if (raycast2) {
                        spider = hit2.collider.name.Contains("wall");
                        Debug.Log(hit2.collider.name);
                    }
                    bool ins = hit.collider.name.Contains("assets/prefabs/building core");
                    float distance = player.Distance(hit.point);
                    Debug.Log($"-[TEST]- {player.displayName}({player.UserIDString}) - [{elements}] - высота: {distance.ToString("F1")} м.({hit.collider.name}) | Дерево: {(list2.Count > 0 ? "Да" : "Нет")} | Игрок: {(pl ? "Да" : "Нет")} | В здании: {(ins ? "Да" : "Нет")} | Спайдер: {(spider ? "Да" : "Нет")}");
                }
            }
        }
        [PluginReference]
        private Plugin PrisonBitch;
        private static void BAN(string steamid, string reason, int time, string displayname, bool checkteam = true) {
            if (!enablefull) return;
            ulong usteam = Convert.ToUInt64(steamid);
            if (config.steamplayer) {
                BasePlayer pl = BasePlayer.FindByID(usteam);
                if(pl != null) {
                    if (ins.ISSTEAM(pl.Connection)) {
                        ADDLOG($"{pl.displayName}({pl.UserIDString}) отмазали от бана.", 2);
                        return;
                    }
                }
            }
            ulong usteamid = Convert.ToUInt64(steamid);
            if (checkteam && (reason != config.mACROS.reason || config.tEAMBAN.macros)) {
                if (config.tEAMBAN.enable) {
                    BasePlayer basePlayer = BasePlayer.FindByID(usteam);
                    if (basePlayer != null && basePlayer.Team != null && basePlayer.Team.members.Count > 1) {
                        int banned = basePlayer.Team.members.Count(x => IsBanned(x) || IsImprisoned(x));
                        if (banned >= config.tEAMBAN.num - 1) {
                            foreach (var z in basePlayer.Team.members) {
                                if (basePlayer.userID == z) continue;
                                string strid = z.ToString();
                                BasePlayer basePlayer2 = BasePlayer.FindByID(z);
                                string name = basePlayer2 != null ? basePlayer2.displayName : strid;
                                ins.timer.Once(1f, () => BAN(z.ToString(), config.tEAMBAN.reason, config.tEAMBAN.hours, name, false));
                            }
                        }
                    }
                }
            }
            if (config.prison && prison) {
                if (!IsImprisoned(usteamid)) {
                    ADDLOG($"Отправили в тюрьму {displayname}({steamid}) на {(time * 1f / 24f).ToString("F1")} дней [{reason}]", 1);
                    time = (int)(time * 60f);
                    ins.Server.Command(config.pattern["PRISON.ACCOUNT"].Replace("{steamid}", steamid).Replace("{time}", time.ToString()).Replace("{reason}", reason));
                }
            }
            else {
                if (!IsBanned(usteamid)) {
                    ins.Server.Command(config.pattern["BAN.ACCOUNT"].Replace("{steamid}", steamid).Replace("{time}", time.ToString()).Replace("{reason}", reason));
                    ADDLOG($"Забанили {displayname}({steamid}) на {(time * 1f / 24f).ToString("F1")} дней [{reason}]", 1);
                }
            }
        }
        const int flylimit = 2;
        const int spiderlimit = 2;
        private static Dictionary<ulong, int> macros = new Dictionary<ulong, int>();
        class ANTICHEAT : MonoBehaviour {
            private int stash;
            private int silent;
            private int spider;
            private int fly;
            BasePlayer player;
            private DateTime lastban;
            private DateTime firsthit;
            private DateTime hitmod;
            string lasthit;
            int hits;
            float distancehit;
            string weaponhit;
            public DateTime LastFires;
            public int fires;
            string weaponfire;
            float posfire;
            float posfirel;
            float posfirer;
            private int numdetecthit;
            bool macromove;
            Vector3 startshoots;
            private void Awake() {
                player = GetComponent<BasePlayer>();
                if (player == null || enablefull && (player.IsAdmin || ins.permission.UserHasPermission(player.UserIDString, "xanticheat.allow"))) {
                    Destroy(this);
                    return;
                }
                //      if (!enablefull) Debug.Log(player.displayName + " добавили в античит.");
                lasthit = "";
                silent = 0;
                weaponhit = "";
                weaponfire = "";
                if (config.debugcamera) InvokeRepeating(nameof(TICK), 0f, 10f);
                InvokeRepeating(nameof(SILENTCLEAR), 120f, 120f);
                // InvokeRepeating(nameof(WH), 0f, 1f);
            }
            private void SILENTCLEAR() {
                spider = 0;
                silent = 0;
                fly = 0;
            }
            public void ADDFLY() {
                fly++;
                ADDLOG($"-[Fly]- {player.displayName}({player.UserIDString}) детектов {fly}/{flylimit}", 2);
                if (fly >= flylimit && lastban < DateTime.Now) {
                    BAN(player.UserIDString, config.fLY.reason, config.fLY.hours, player.displayName);
                    lastban = DateTime.Now.AddSeconds(10f);
                    fly = 0;
                    return;
                }
            }
            public void ADDFIRE(string weapon) {
                if (weapon == "ak47u.item") {
                    Vector3 vector3 = player.transform.position;
                    double sec = (DateTime.Now - LastFires).TotalSeconds;
                    Vector3 current = player.eyes.HeadForward();
                    if (fires == 0) {
                        startshoots = vector3;
                        macromove = false;
                        sec = 0;
                        posfire = current.y;
                        posfirel = current.x;
                        posfirer = current.z;
                    }
                    else {
                        if (!macromove && startshoots != vector3) {
                            macromove = true;
                        }
                    }
                    float razn = Mathf.Abs(posfire - current.y);
                    float raznl = Mathf.Abs(posfirel - current.x);
                    float raznr = Mathf.Abs(posfirer - current.z);
                    if (current.y < 0.9f && current.y > -0.9f && sec < 0.2f && razn <= 0.009f && raznl <= 0.009f && raznr <= 0.009f) {
                        fires++;
                        LastFires = DateTime.Now;
                        weaponfire = weapon;
                        if (IsInvoking(nameof(FIREEND))) CancelInvoke(nameof(FIREEND));
                        Invoke(nameof(FIREEND), 0.21f);
                    }
                }
            }
            private void FIREEND() {
                if (fires >= config.mACROS.shoots) {
                    if (!macros.ContainsKey(player.userID)) macros.Add(player.userID, 1);
                    else macros[player.userID] += 1;
                    if(macros[player.userID] >= config.mACROS.amount) {
                        BAN(player.UserIDString, config.mACROS.reason, config.mACROS.hours, player.displayName);
                        lastban = DateTime.Now.AddSeconds(10f);
                    }
                    ADDLOG($"-[Macro]- {player.displayName}({player.UserIDString}) | выстрелов {fires} | использовал {weaponfire} | двигался: {(macromove ? "да" : "нет")} | детект #{macros[player.userID]}", 2);
                }
                fires = 0;
            }
            public void ADDHIT(string hitbone, string weapon, float distance) {
                if (hitbone == "N/A" || distance < 30f) return;
                if(hitbone != lasthit && lasthit != "") {
                    CLEARHIT();
                    return;
                }
                if (hits == 0) {
                    hitmod = DateTime.Now;
                    firsthit = DateTime.Now;
                }
                hits++;
                //  if (!enablefull) Debug.Log(player.displayName + " - " + hits);
                lasthit = hitbone;
                distancehit += distance;
                if(hits >= 2) distancehit /= 2;
                if(!weaponhit.Contains(weapon)) weaponhit += (hits >= 2 ? ", " : string.Empty) + weapon;
                if (hits >= 5) {
                    ADDLOG($"-[HitMod]- {player.displayName}({player.UserIDString}) | {hitbone} | средняя дистанция {distancehit.ToString("F1")} | использовал {weaponhit} | ({(DateTime.Now-firsthit).TotalMinutes.ToString("F1")})", 2);
                    if (distancehit > 100 && (weaponhit.Contains("bow_hunting.entity") || weaponhit.Contains("crossbow.entity") || weaponhit.Contains("bow.compound") || weaponhit.Contains("pistol_eoka.entity")) || distancehit > 65 && (weaponhit == "bow_hunting.entity" || weaponhit == "crossbow.entity" || weaponhit == "bow.compound") || distancehit > 40 && weaponhit == "pistol_eoka.entity") {
                        BAN(player.UserIDString, config.hITMOD.reason, config.hITMOD.hours, player.displayName);
                        lastban = DateTime.Now.AddSeconds(10f);
                    }
                    if(!weapon.Contains("l96.entity")) {
                        if ((DateTime.Now - hitmod).TotalMinutes < 10f) {
                            numdetecthit++;
                            if (numdetecthit >= 3) {
                                BAN(player.UserIDString, config.hITMOD.reason, config.hITMOD.hours, player.displayName);
                                lastban = DateTime.Now.AddSeconds(10f);
                            }
                        }
                        else {
                            numdetecthit = 0;
                        }
                    }
                    hitmod = DateTime.Now;
                    CLEARHIT();
                }
            }
            /*
            private void WH()
            {
                RaycastHit hitInfo;
                if (GamePhysics.Trace(new Ray(player.eyes.position, player.eyes.HeadForward()), 0.0f, out hitInfo, 300f, 1219701521, QueryTriggerInteraction.UseGlobal))
                {
                    //targetPos = hitInfo.point;
                    if ((bool)((UnityEngine.Object)hitInfo.collider))
                    {
                        BaseEntity entity = hitInfo.GetEntity();
                        if ((bool)((UnityEngine.Object)entity))
                        {
                            BaseCombatEntity baseCombatEntity = entity as BaseCombatEntity;
                            if (baseCombatEntity is BasePlayer)
                            {
                                BasePlayer basePlayer = baseCombatEntity as BasePlayer;
                                RaycastHit hitInfo2;
                                if (GamePhysics.Trace(new Ray(player.eyes.position, player.eyes.HeadForward()), 0.0f, out hitInfo2, 300f, 1218652417, QueryTriggerInteraction.UseGlobal))
                                {
                                    BaseEntity entity2 = hitInfo2.GetEntity();
                                    if ((bool)((UnityEngine.Object)entity2))
                                    {
                                        BaseCombatEntity baseCombatEntity2 = entity as BaseCombatEntity;
                                        if (!(baseCombatEntity2 is BasePlayer))
                                        {
                                            ADDLOG($"[#] {player.displayName} -> {basePlayer.displayName} [{player.Distance(basePlayer)} м.| {(basePlayer.eyes.transform.position.y - hitInfo.point.y).ToString("F1")} м.| {baseCombatEntity2.ShortPrefabName}]", 2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            */
            private void CLEARHIT() {
                hits = 0;
                lasthit = "";
                weaponhit = "";
                distancehit = 0;
            }
            public void ADDSTASH() {
                stash++;
                if (stash >= 2 && lastban < DateTime.Now) {
                    BAN(player.UserIDString, "\"CheatDetected (6)\"", config.fLY.hours, player.displayName);
                    lastban = DateTime.Now.AddSeconds(10f);
                    stash = 0;
                    return;
                }
            }
            public void ADDSPIDER() {
                spider++;
                ADDLOG($"-[Spider]- {player.displayName}({player.UserIDString}) детектов {spider}/{spiderlimit}", 2);
                if (spider >= spiderlimit && lastban < DateTime.Now) {
                    BAN(player.UserIDString, config.sPIDER.reason, config.sPIDER.hours, player.displayName);
                    lastban = DateTime.Now.AddSeconds(10f);
                    spider = 0;
                    return;
                }
            }
            public void ADDSILENT(int amount) {
                silent += amount;
                ADDLOG($"-[SAim]- {player.displayName}({player.UserIDString}) детектов {silent}/{config.sILENT.xdetects}", 2);
                if (silent >= config.sILENT.xdetects && lastban < DateTime.Now) {
                    BAN(player.UserIDString, config.sILENT.reason, config.sILENT.hours, player.displayName);
                    lastban = DateTime.Now.AddSeconds(10f);
                    silent = 0;
                    return;
                }
            }
            private void TICK() {
                /*    if (player.IsFlying)
                    {
                        if (!IsInvoking(nameof(FLYTICK)))
                        {
                            height = player.transform.position.y;
                            InvokeRepeating(nameof(FLYTICK), 1f, 1f);
                        }
                    }*/
                if (enablefull) {
                    player.SendConsoleCommand("noclip");
                    player.SendConsoleCommand("camspeed 0");
                }
                /* if (player.modelState.flying && !player.IsAdmin && !player.IsDeveloper)
                {
                    BAN(player.UserIDString, "\"Cheat Detected! (4)\"", 60, player.displayName);
                    lastban = DateTime.Now.AddSeconds(10f);
                }*/
            }
            /*   private float height;
            private void FLYTICK()
            {
                if (!player.IsFlying)
                {
                    fly = 0;
                    CancelInvoke(nameof(FLYTICK));
                }

                fly++;
                if (fly >= 5)
                {
                    ADDLOG($"[Fly] {player.displayName}({player.UserIDString}) возможно флай.", 2);
                    fly = 0;
                    CancelInvoke(nameof(FLYTICK));
                }
            }*/
            public void DoDestroy() => Destroy(this);
            private void OnDestroy() {
                if (IsInvoking(nameof(TICK))) CancelInvoke(nameof(TICK));
                // if (IsInvoking(nameof(WH))) CancelInvoke(nameof(WH));
                if (IsInvoking(nameof(FIREEND))) CancelInvoke(nameof(FIREEND));
                //  if (IsInvoking(nameof(FLYTICK))) CancelInvoke(nameof(FLYTICK));
            }
        }
        /*  private void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile mod, ProtoBuf.ProjectileShoot projectiles)
        {
            if (player == null || projectile == null || mod == null || projectiles == null) return;
            RaycastHit hitInfo;
            if (GamePhysics.Trace(new Ray(player.eyes.position, player.eyes.HeadForward()), 0.0f, out hitInfo, 300f, 1219701521, QueryTriggerInteraction.UseGlobal))
            {
                //targetPos = hitInfo.point;
                if ((bool)((UnityEngine.Object)hitInfo.collider))
                {
                    BaseEntity entity = hitInfo.GetEntity();
                    if ((bool)((UnityEngine.Object)entity))
                    {
                        BaseCombatEntity baseCombatEntity = entity as BaseCombatEntity;
                        if (baseCombatEntity is BasePlayer)
                        {
                            BasePlayer basePlayer = baseCombatEntity as BasePlayer;
                          //  if(basePlayer)
                            Debug.Log($"{player.displayName} -> {basePlayer.displayName} [{player.Distance(basePlayer)} м.| {(basePlayer.eyes.transform.position.y - hitInfo.point.y).ToString("F1")} м.]");
                        }
                    }
                }
            }
        }*/
        private void OnPlayerBanned(string name, ulong id, string address, string reason) {
            if (reason == "Cheat Detected!") ADDLOG($"Забанили {name}({id}) [FakeAdmin/DebugCamera]", 1);
        }
        const string defaultsteamapi = "https://steamcommunity.com/dev/apikey";
        class resp {
            public avatar response;
        }
        class avatar {
            public List<Players> players;
        }
        class Players {
            public int? profilestate;
            public int? timecreated;
        }
        class INFO {
            public DateTime dateTime;
            public bool profilestate;
            public bool steam;
            public Dictionary<string, Dictionary<string, int>> hitinfo;
        }
        Dictionary<ulong, INFO> PLAYERINFO = new Dictionary<ulong, INFO>();
        static XAntiCheat ins;
        private void Init() {
            ins = this;
            //   Unsubscribe(nameof(OnPlayerConnected));
        }
#region Grid
        Dictionary<string, Vector3> Grids = new Dictionary<string, Vector3>();
        const float calgon = 0.0066666666666667f;
        void CreateSpawnGrid() {
            var worldSize = (ConVar.Server.worldsize);
            float offset = worldSize / 2;
            var gridWidth = (calgon * worldSize);
            float step = worldSize / gridWidth;
            string start = "";
            char letter = 'A';
            int number = 0;
            for (float zz = offset; zz > -offset; zz -= step) {
                for (float xx = -offset; xx < offset; xx += step) {
                    Grids.Add($"{start}{letter}{number}", new Vector3(xx - 55f, 0, zz));
                    if (letter.ToString().ToUpper() == "Z") {
                        start = "A";
                        letter = 'A';
                    }
                    else {
                        letter = (char)(((int)letter) + 1);
                    }
                }
                number++;
                start = "";
                letter = 'A';
            }
        }
        private string GetNameGrid(Vector3 pos) {
            return Grids.Where(x => x.Value.x < pos.x && x.Value.x + 150f > pos.x && x.Value.z > pos.z && x.Value.z - 150f < pos.z).FirstOrDefault().Key;
        }
#endregion
        private static bool prison = false;
        private List<StashContainer> stashContainers = new List<StashContainer>();
        private float sizeworldx;
        private float sizeworldz;
        List<Vector3> OntheMap = new List<Vector3>();
        void foundmonuments() {
            OntheMap.Clear();
            foreach (var z in UnityEngine.Object.FindObjectsOfType<MonumentInfo>()) {
                if (z.name.Contains("/cave") || z.name.Contains("/tiny") || z.name.Contains("/power substations") || z.name.Contains("OilrigAI")) continue;
                Vector3 pos = z.transform.position;
                if (!OntheMap.Contains(pos)) OntheMap.Add(pos);
            }
        }
        private Vector3 RANDOMPOS() => new Vector3(Random.Range(-sizeworldx, sizeworldx), 400f, Random.Range(-sizeworldz, sizeworldz));
        List<string> names = new List<string>();
        private Vector3 FINDSPAWNPOINT(int num = 1) {
            if (num >= 300) return Vector3.zero;
            Vector3 pos = RANDOMPOS();
            RaycastHit hitInfo;
            if (!Physics.Raycast(pos, Vector3.down, out hitInfo, 450f, Layers.Solid)) return FINDSPAWNPOINT(num++);
            if (hitInfo.collider == null || hitInfo.collider.name != "Terrain" && hitInfo.collider.name != "Road Mesh") return FINDSPAWNPOINT(num++);
            if (hitInfo.point.y - TerrainMeta.WaterMap.GetHeight(hitInfo.point) < 0) return FINDSPAWNPOINT(num++);
            if (WaterLevel.Test(hitInfo.point)) return FINDSPAWNPOINT(num++);
            if (OntheMap.Any(x => Vector3.Distance(x, hitInfo.point) < 170f)) return FINDSPAWNPOINT(num++);
            if (stashContainers.Any(x => Vector3.Distance(x.transform.position, hitInfo.point) < 30f)) return FINDSPAWNPOINT(num++);
            if (Mathf.Abs((TerrainMeta.HeightMap.GetHeight(hitInfo.point) - hitInfo.point.y)) > 0.1f) return FINDSPAWNPOINT(num++);
            if (Mathf.Abs((TerrainMeta.HeightMap.GetHeight(hitInfo.point + Vector3.left * 0.2f) - hitInfo.point.y)) > 0.01f) return FINDSPAWNPOINT(num++);
            if (Mathf.Abs((TerrainMeta.HeightMap.GetHeight(hitInfo.point + Vector3.right * 0.2f) - hitInfo.point.y)) > 0.01f) return FINDSPAWNPOINT(num++);
            if (Mathf.Abs((TerrainMeta.HeightMap.GetHeight(hitInfo.point + Vector3.forward * 0.2f) - hitInfo.point.y)) > 0.01f) return FINDSPAWNPOINT(num++);
            if (Mathf.Abs((TerrainMeta.HeightMap.GetHeight(hitInfo.point + Vector3.back * 0.2f) - hitInfo.point.y)) > 0.01f) return FINDSPAWNPOINT(num++);
            return hitInfo.point;
        }
        private void CanSeeStash(BasePlayer player, StashContainer stash) {
            if (stash.OwnerID != 0 || !stashContainers.Contains(stash)) return;
            ADDLOG($"-[ESPStash]- {player.displayName}({player.UserIDString}) - квадрат {GetNameGrid(stash.transform.position)}", 2);
            timer.Once(75f, () => {
                if (!player.IsConnected) return;
                ANTICHEAT aNTICHEAT;
                if (!player.TryGetComponent<ANTICHEAT>(out aNTICHEAT)) return;
                aNTICHEAT.ADDSTASH();
            }
            );
            lastshash = stash.transform.position;
            stashContainers.Remove(stash);
        }
        private void OnServerInitialized() {
            SaveConfig();
            if(config.tt == null || config.tt != "nothing") {
                config.tt = "nothing";
                config.hITMOD.enable = true;
                SaveConfig();
            }
            if (config.tEAMBAN == null) {
                config.tEAMBAN = new TEAMBAN {
                    hours = 168, reason = "\"bb with teammates\"", num = 2
                }
                ;
                config.cODELOCK = new CODELOCK {
                    hours = 336, reason = "\"Ban Detected! (1)\"", seconds = 75
                }
                ;
                SaveConfig();
            }
            if(config.tEAMBAN.num == 0) {
                config.tEAMBAN.num = 2;
                SaveConfig();
            }
            if (config.discordid == null) {
                config.discordid = "";
                SaveConfig();
            }
            CreateSpawnGrid();
            if(config.ipinfotoken == null) {
                config.ipinfotoken = ipinfosingup;
                if (!config.messages.ContainsKey("KICK.VPN")) config.messages.Add("KICK.VPN", "\"На сервере запрещено играть с VPN! (VPN DETECTED)\"");
                config.kickvpn = true;
                SaveConfig();
            }
            if(config.mACROS == null) {
                config.hITMOD = new HITMOD {
                    hours = 720, reason = "\"Cheat Detected! (6)\""
                }
                ;
                config.mACROS = new MACROS {
                    amount = 5, hours = 168, shoots = 10, reason = "\"Cheat Detected! (7)\""
                }
                ;
                SaveConfig();
            }
            if(config.mACROS.shoots == 0) {
                config.mACROS.shoots = 10;
                SaveConfig();
            }
            if (config.ESPStash == null)  // патч 04.06
            {
                config.ESPStash = new ESPSTASH {
                    amount = 100, loots = new Dictionary<string, int> {
                        {
                            "rifle.ak", 1
                        }
                        , {
                            "rifle.bolt", 1
                        }
                        , {
                            "rifle.l96", 1
                        }
                        , {
                            "rifle.lr300", 1
                        }
                        , {
                            "rifle.semiauto", 1
                        }
                        , {
                            "wood", 10000
                        }
                        , {
                            "stones", 10000
                        }
                        , {
                            "metal.refined", 50
                        }
                        , {
                            "metal.fragments", 10000
                        }
                        , {
                            "metal.facemask", 1
                        }
                        , {
                            "scrap", 500
                        }
                        ,
                    }
                }
                ;
                config.steam = true;
                SaveConfig();
            }
            if(config.ipinfotoken == ipinfosingup) {
                Debug.LogWarning("Введите в конфиг токен для IPINFO, если хотите включить автоопределение использования игроком VPN!");
            }
            foundmonuments();
            sizeworldx = TerrainMeta.Size.x / 2.5f;
            sizeworldz = TerrainMeta.Size.z / 2.5f;
            namefile = DateTime.Now.ToString("MM/dd");
            LOGS = Interface.Oxide.DataFileSystem.ReadObject<List<string>>("XAC/" + namefile);
            if (config.sPIDER == null) {
                config.sPIDER = new SPIDER {
                    hours = 720, reason = "\"Cheat Detected! (2)\""
                }
                ;
                SaveConfig();
            }
            if (config.sILENT == null) {
                config.sILENT = new SILENT {
                    xdetects = 7, hours = 1440, reason = "\"Cheat Detected! (1)\""
                }
                ;
                config.pattern = new Dictionary<string, string> {
                    {
                        "BAN.ACCOUNT", "ban {steamid} {reason} {time}"
                    }
                    , {
                        "PRISON.ACCOUNT", "prison.add {steamid} {time} {reason}"
                    }
                    ,
                }
                ;
                SaveConfig();
            }
            if(config.fLY == null) {
                config.fLY = new FLY {
                    hours = 720, reason = "\"Cheat Detected! (3)\""
                }
                ;
                SaveConfig();
            }
            if (config.sILENT.xdetects == 0) {
                config.sILENT.xdetects = 7;
                config.debugcamera = true;
                SaveConfig();
            }
            if (!config.messages.ContainsKey("KICK.NENASTROYEN")) {
                config.messages.Add("KICK.NENASTROYEN", "Настройте профиль, что бы играть на этом сервере! (Make your Steam profile public to play on this server)");
                SaveConfig();
            }
            if (string.IsNullOrEmpty(config.steampi) || config.steampi == defaultsteamapi) {
                Debug.LogError("УКАЖИТЕ STEAMAPI В КОНФИГЕ!");
                return;
            }
            foreach (BasePlayer player in BasePlayer.activePlayerList) {
                /*   HeldEntity heldEntity = player.GetHeldEntity();
                if (heldEntity != null)
                {
                    BaseProjectile baseProjectile = heldEntity.GetComponent<BaseProjectile>();
                    if (baseProjectile == null) continue;
                    baseProjectile.recoil.recoilYawMin = -2f;
                    baseProjectile.recoil.recoilPitchMin = -4f;
                    baseProjectile.recoil.recoilYawMax = 8f;
                    baseProjectile.recoil.recoilPitchMax = -30f;
                    baseProjectile.recoil.ADSScale = 0.5f;
                    baseProjectile.recoil.movementPenalty = 0.5f;

                    Debug.Log(player.displayName + " " + baseProjectile.recoil.recoilYawMin + " " + heldEntity.GetComponent<BaseProjectile>().recoil.recoilPitchMin + " " + heldEntity.GetComponent<BaseProjectile>().recoil.recoilYawMax + " " + heldEntity.GetComponent<BaseProjectile>().recoil.recoilPitchMax + " " + heldEntity.GetComponent<BaseProjectile>().recoil.ADSScale + " " + heldEntity.GetComponent<BaseProjectile>().recoil.movementPenalty);
                }*/
                if (player.GetComponent<ANTICHEAT>() == null) player.gameObject.AddComponent<ANTICHEAT>();
            }
            timer.Once(5f, () => {
                if (PrisonBitch != null) prison = true;
            }
            );
            permission.RegisterPermission("xanticheat.allow", this);
            permission.RegisterPermission("xanticheat.skip", this);
            permission.RegisterPermission("xanticheat.command", this);
            permission.RegisterPermission("xanticheat.chat", this);
            // Subscribe(nameof(OnPlayerConnected));
            timer.Every(3600f, () => Save());
            stashContainers.Clear();
            int i = 0;
            while(i < config.ESPStash.amount) {
                Vector3 pos = FINDSPAWNPOINT();
                if (pos == Vector3.zero) continue;
                StashContainer stashContainer = GameManager.server.CreateEntity("assets/prefabs/deployable/small stash/small_stash_deployed.prefab", pos, new Quaternion(), true) as StashContainer;
                stashContainer.enableSaving = false;
                stashContainer.Spawn();
                int max = Random.Range(2, 7);
                int current = 0;
                foreach (var z in config.ESPStash.loots) {
   
// ... [Code preview truncated due to length. Full source in attached file] ...

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