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

FREE AbsolutCombat : 2.3.2 2.3.2

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System.Collections.Generic;
using System;
using System.Linq;
using UnityEngine;
using Oxide.Core.Plugins;
using Oxide.Core.Configuration;
using Oxide.Game.Rust.Cui;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
namespace Oxide.Plugins {
    [Info("AbsolutCombat", "Absolut", "2.3.2", ResourceId = 2103)]
    class AbsolutCombat : RustPlugin {
#region Fields
        [PluginReference]
        Plugin EventManager, ServerRewards, Economics, BetterChat, ImageLibrary;
        Gear_Weapon_Data gwData;
        private DynamicConfigFile GWData;
        SavedPlayer playerData;
        private DynamicConfigFile PlayerData;
        string TitleColor = "<color=orange>";
        string MsgColor = "<color=#A9A9A9>";
        private Dictionary<ulong, Timer> PlayerGearSetTimer = new Dictionary<ulong, Timer>();
        private Dictionary<ulong, Timer> PlayerWeaponSetTimer = new Dictionary<ulong, Timer>();
        private Dictionary<string, Timer> timers = new Dictionary<string, Timer>();
        private Dictionary<ulong, PurchaseItem> PendingPurchase = new Dictionary<ulong, PurchaseItem>();
        private Dictionary<ulong, PurchaseItem> SetSelection = new Dictionary<ulong, PurchaseItem>();
        Dictionary<string, List<ulong>> ItemSkins = new Dictionary<string, List<ulong>>();
        private Dictionary<ulong, GearCollectionCreation> NewGearCollection = new Dictionary<ulong, GearCollectionCreation>();
        private Dictionary<ulong, WeaponCollectionCreation> NewWeaponCollection = new Dictionary<ulong, WeaponCollectionCreation>();
        private Dictionary<ulong, string> SavingCollection = new Dictionary<ulong, string>();
        private Dictionary<ulong, screen> ACUIInfo = new Dictionary<ulong, screen>();
        class screen {
            public bool open;
            public bool admin;
            public bool weapon;
            public bool gear;
            public string GearSet;
            public string WeaponSet;
            public int GearIndex;
            public int WeaponIndex;
            public int page;
        }
        //corpses///
        private readonly string corpsePrefab = "assets/prefabs/player/player_corpse.prefab";
        private uint corpsePrefabId;
#endregion
#region Hooks
        void Loaded() {
            GWData = Interface.Oxide.DataFileSystem.GetFile("AbsolutCombat_GWData");
            PlayerData = Interface.Oxide.DataFileSystem.GetFile("AbsolutCombat_PlayerData");
            lang.RegisterMessages(messages, this);
        }
        void Unload() {
            foreach (var player in BasePlayer.activePlayerList) DestroyACPlayer(player);
            foreach (var timer in timers) timer.Value.Destroy();
            timers.Clear();
            SaveData();
        }
        void OnServerInitialized() {
            try {
                ImageLibrary.Call("isLoaded", null);
            }
            catch (Exception) {
                PrintWarning("No Image Library..load ImageLibrary to use this Plugin", Name);
                Interface.Oxide.UnloadPlugin(Name);
                return;
            }
            LoadVariables();
            if (configData.UseServerRewards) {
                try {
                    ServerRewards.Call("isLoaded", null);
                }
                catch (Exception) {
                    PrintWarning(GetMSG("NOSR", Name));
                    Interface.Oxide.UnloadPlugin(Name);
                    return;
                }
            }
            if (configData.UseEconomics) {
                try {
                    Economics.Call("isLoaded", null);
                    if (configData.UseServerRewards && configData.UseEconomics) {
                        PrintWarning(GetMSG("BOTHERROR", Name));
                        Interface.Oxide.UnloadPlugin(Name);
                        return;
                    }
                }
                catch (Exception) {
                    PrintWarning(GetMSG("NOECO", Name));
                    Interface.Oxide.UnloadPlugin(Name);
                    return;
                }
            }
            LoadData();
            AddImage("http://i.imgur.com/OjuRPqa.png", "down", (ulong)ResourceId);
            AddImage("http://i.imgur.com/Eu9QHKr.png", "up", (ulong)ResourceId);
            InitializeSkins();
            foreach (BasePlayer p in BasePlayer.activePlayerList) {
                OnPlayerInit(p);
            }
            timers.Add("info", timer.Once(900, () => InfoLoop()));
            timers.Add("save", timer.Once(600, () => SaveLoop()));
            timers.Add("cond", timer.Once(120, () => CondLoop()));
        }
        private void InitializeSkins() {
            foreach (var itemDef in ItemManager.GetItemDefinitions()) {
                List<ulong> skins;
                skins = new List<ulong> {
                    0
                }
                ;
                skins.AddRange(ItemSkinDirectory.ForItem(itemDef).Select(skin => Convert.ToUInt64(skin.id)));
                List<ulong> templist = GetImageList(itemDef.shortname);
                if (templist != null && templist.Count >= 1) foreach (var entry in templist.Where(k => !skins.Contains(k))) skins.Add(entry);
                ItemSkins.Add(itemDef.shortname, skins);
            }
        }
        private void OnPlayerInit(BasePlayer player) {
            if (player != null) {
                player.Command($"bind {configData.MenuKeyBinding} \"OpenACUI\"");
                InitializeACPlayer(player);
                GetSendMSG(player, "ACInfo", configData.MenuKeyBinding.ToUpper());
            }
        }
        private void OnPlayerRespawned(BasePlayer player) {
            if (EventManager) {
                object isPlaying = EventManager?.Call("isPlaying", new object[] {
                    player
                }
                );
                if (isPlaying is bool) if ((bool)isPlaying) return;
            }
            DestroyUI(player);
            if (!playerData.players.ContainsKey(player.userID)) {
                InitializeACPlayer(player);
                return;
            }
            CheckCollections(player);
            GiveGearCollection(player);
            GiveWeaponCollection(player);
            player.health = 100f;
        }
        private bool DataCheck (BasePlayer player) {
            if (!playerData.players.ContainsKey(player.userID)) return false;
            return true;
        }
        private void OnEntityDeath(BaseEntity entity, HitInfo hitInfo) {
            try {
                var attacker = hitInfo.Initiator.ToPlayer() as BasePlayer;
                var victim = entity.ToPlayer();
                if (entity is BasePlayer && hitInfo.Initiator is BasePlayer) {
                    if (entity as BasePlayer == null || hitInfo == null) return;
                    if (!DataCheck(attacker) || !DataCheck(victim)) return;
                    if (victim.userID != attacker.userID) {
                        if (EventManager) {
                            object isPlaying = EventManager?.Call("isPlaying", new object[] {
                                attacker
                            }
                            );
                            if (isPlaying is bool) if ((bool)isPlaying) return;
                        }
                        playerData.players[attacker.userID].kills += 1;
                        playerData.players[attacker.userID].TotalKills += 1;
                        playerData.players[victim.userID].deaths += 1;
                        playerData.players[victim.userID].TotalDeaths += 1;
                        if (configData.UseServerRewards) SRAction(attacker.userID, configData.KillReward, "ADD");
                        else if (configData.UseEconomics) ECOAction(attacker.userID, configData.KillReward, "ADD");
                        else playerData.players[attacker.userID].money += configData.KillReward;
                        playerData.players[attacker.userID].GearCollectionKills[playerData.players[attacker.userID].Gear.collectionname] += 1;
                        playerData.players[attacker.userID].WeaponCollectionKills[playerData.players[attacker.userID].Weapons.collectionname] += 1;
                        SendDeathNote(attacker, victim);
                        PlayerHUD(attacker);
                    }
                }
            }
            catch (Exception) {
            }
        }
        private void SRAction(ulong ID, int amount, string action) {
            if (action == "ADD") ServerRewards?.Call("AddPoints", new object[] {
                ID, amount
            }
            );
            if (action == "REMOVE") ServerRewards?.Call("TakePoints", new object[] {
                ID, amount
            }
            );
        }
        private void ECOAction(ulong ID, int amount, string action) {
            if (action == "ADD") Economics.Call("DepositS", ID.ToString(), amount);
            if (action == "REMOVE") Economics.Call("WithdrawS", ID.ToString(), amount);
        }
        object OnBetterChat(IPlayer iplayer, string message) {
            var player = iplayer.Object as BasePlayer;
            if (player == null) return message;
            if (SavingCollection.ContainsKey(player.userID)) {
                CollectionCreationChat(player, message.Split(' '));
                return true;
            }
            return message;
        }
        private object OnPlayerChat(ConsoleSystem.Arg arg) {
            if (BetterChat) return null;
            var player = arg.Connection.player as BasePlayer;
            if (player == null) return null;
            if (SavingCollection.ContainsKey(player.userID)) {
                CollectionCreationChat(player, arg.Args);
                return true;
            }
            return null;
        }
        private void CollectionCreationChat(BasePlayer player, string[] Args) {
            if (Args.Contains("quit")) {
                ExitSetCreation(player);
                return;
            }
            var args = string.Join(" ", Args);
            var name = args;
            if (SavingCollection[player.userID] == "gear") NewGearCollection[player.userID].setname = name;
            else if (SavingCollection[player.userID] == "weapon") NewWeaponCollection[player.userID].setname = name;
            SaveCollect(player);
        }
        //void OnEntitySpawned(BaseNetworkable entity)
        //{
        //    if (entity != null)
        //    {
        //        corpsePrefabId = StringPool.Get(corpsePrefab);
        //        if (configData.UseEnviroControl)
        //        {
        //            if (entity.prefabID == corpsePrefabId)
        //            {
        //                entity.Kill();
        //            }
        //            var collectible = entity as CollectibleEntity;
        //            if (collectible != null)
        //            {
        //                collectible.itemList = null;
        //            }
        //            var worldItem = entity as WorldItem;
        //            if (worldItem != null)
        //            {
        //                worldItem.allowPickup = false;
        //            }
        //            var Heli = entity as BaseHelicopter;
        //            if (Heli != null)
        //            {
        //                Heli.Kill();
        //            }
        //            var Plane = entity as CargoPlane;
        //            if (Plane != null)
        //            {
        //                Plane.Kill();
        //            }
        //        }
        //    }
        //}
        //private void OnLootEntity(BasePlayer looter, BaseEntity target)
        //{
        //    if (configData.UseEnviroControl && !isAuth(looter))
        //    {
        //        if ((target as StorageContainer)?.transform.position == Vector3.zero) return;
        //        timer.Once(0.01f, looter.EndLooting);
        //    }
        //}
        //void OnPlantGather(PlantEntity Plant, Item item, BasePlayer player)
        //{
        //    if (configData.UseEnviroControl && !isAuth(player))
        //    {
        //        item.amount = 0;
        //    }
        //}
        //void OnCollectiblePickup(Item item, BasePlayer player)
        //{
        //    if (configData.UseEnviroControl && !isAuth(player))
        //    {
        //        item.amount = 0;
        //    }
        //}
        //void OnDispenserGather(ResourceDispenser Dispenser, BaseEntity entity, Item item)
        //{
        //    BasePlayer player = entity.ToPlayer();
        //    if (configData.UseEnviroControl && !isAuth(player))
        //    {
        //        item.amount = 0;
        //    }
        //}
        //object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
        //{
        //    if (configData.UseEnviroControl && !isAuth(crafter))
        //    {
        //        task.cancelled = true;
        //    }
        //    return null;
        //}
#endregion
#region Functions
        private string TryForImage(string shortname, ulong skin = 99) {
            if (shortname.Contains("http")) return shortname;
            if (skin == 99) skin = (ulong)ResourceId;
            return GetImage(shortname, skin, true);
        }
        public string GetImage(string shortname, ulong skin = 0, bool returnUrl = false) => (string)ImageLibrary.Call("GetImage", shortname.ToLower(), skin, returnUrl);
        public bool HasImage(string shortname, ulong skin = 0) => (bool)ImageLibrary.Call("HasImage", shortname.ToLower(), skin);
        public bool AddImage(string url, string shortname, ulong skin = 0) => (bool)ImageLibrary?.Call("AddImage", url, shortname.ToLower(), skin);
        public List<ulong> GetImageList(string shortname) => (List<ulong>)ImageLibrary.Call("GetImageList", shortname.ToLower());
        public bool isReady() => (bool)ImageLibrary?.Call("IsReady");
        private void InitializeACPlayer(BasePlayer player) {
            if (!playerData.players.ContainsKey(player.userID)) playerData.players.Add(player.userID, new Player {
                deaths = 0, kills = 0, TotalDeaths = 0, TotalKills = 0, money = 0, GearCollectionKills = new Dictionary<string, int>(), WeaponSelection = new Dictionary<string, Dictionary<string, List<string>>>(), Gear = new CurrentGear(), Weapons = new CurrentWeapons(), GearCollections = new Dictionary<string, List<string>>(), WeaponCollections = new Dictionary<string, Dictionary<string, List<string>>>(), WeaponCollectionKills = new Dictionary<string, int>()
            }
            );
            else {
                playerData.players[player.userID].kills = 0;
                playerData.players[player.userID].deaths = 0;
            }
            CheckCollections(player);
        }
        void CheckCollections(BasePlayer player) {
            if (!playerData.players.ContainsKey(player.userID)) {
                InitializeACPlayer(player);
                return;
            }
            //if (gwData.GearSets != null || gwData.GearSets.Count() == 0)
            foreach (var entry in gwData.GearSets.Where(kvp => kvp.Value.cost == 0)) if (!playerData.players[player.userID].GearCollections.ContainsKey(entry.Key)) {
                playerData.players[player.userID].GearCollections.Add(entry.Key, new List<string>());
                playerData.players[player.userID].GearCollectionKills.Add(entry.Key, 0);
                foreach (var gear in gwData.GearSets[entry.Key].set.Where(kvp => kvp.free == true)) playerData.players[player.userID].GearCollections[entry.Key].Add(gear.shortname);
            }
            //if (gwData.WeaponSets != null || gwData.WeaponSets.Count() == 0)
            foreach (var entry in gwData.WeaponSets.Where(kvp => kvp.Value.cost == 0)) if (!playerData.players[player.userID].WeaponCollections.ContainsKey(entry.Key)) {
                playerData.players[player.userID].WeaponCollections.Add(entry.Key, new Dictionary<string, List<string>>());
                playerData.players[player.userID].WeaponCollectionKills.Add(entry.Key, 0);
                foreach (var weapons in gwData.WeaponSets[entry.Key].set.Where(kvp => kvp.free == true)) {
                    playerData.players[player.userID].WeaponCollections[entry.Key].Add(weapons.shortname, new List<string>());
                    foreach (var attachment in weapons.attachments.Where(kvp=>kvp.Value.free == true)) playerData.players[player.userID].WeaponCollections[entry.Key][weapons.shortname].Add(attachment.Value.shortname);
                }
            }
            List<string> gearset = new List<string>();
            List<string> weaponset = new List<string>();
            //Puts("1");
            foreach (var entry in playerData.players[player.userID].GearCollections) if (!gwData.GearSets.ContainsKey(entry.Key)) {
                gearset.Add(entry.Key);
                if (playerData.players[player.userID].Gear.collectionname == entry.Key) {
                    StripGear(player);
                    playerData.players[player.userID].Gear = null;
                }
            }
            //Puts("2");
            foreach (var entry in playerData.players[player.userID].WeaponCollections) if (!gwData.WeaponSets.ContainsKey(entry.Key)) {
                weaponset.Add(entry.Key);
                if (playerData.players[player.userID].Weapons.collectionname == entry.Key) {
                    StripWeapons(player);
                    playerData.players[player.userID].Weapons = null;
                }
            }
            //Puts("3");
            if (gearset != null) foreach (var entry in gearset) {
                playerData.players[player.userID].GearCollections.Remove(entry);
                playerData.players[player.userID].GearCollectionKills.Remove(entry);
            }
            //Puts("4");
            if (weaponset != null) foreach (var entry in weaponset) {
                playerData.players[player.userID].WeaponCollections.Remove(entry);
                playerData.players[player.userID].WeaponCollectionKills.Remove(entry);
            }
            //Puts("5");
            if (playerData.players[player.userID].Gear != null) {
                if (string.IsNullOrEmpty(playerData.players[player.userID].Gear.collectionname)) playerData.players[player.userID].Gear.gear = null;
                else if (!gwData.GearSets.ContainsKey(playerData.players[player.userID].Gear.collectionname)) {
                    playerData.players[player.userID].Gear.collectionname = null;
                    playerData.players[player.userID].Gear.gear = null;
                }
                if (string.IsNullOrEmpty(playerData.players[player.userID].Gear.collectionname) && playerData.players[player.userID].GearCollections.Count() > 0) {
                    playerData.players[player.userID].Gear.collectionname = playerData.players[player.userID].GearCollections.First().Key;
                    GiveGearCollection(player);
                }
            }
            //Puts("6");
            if (playerData.players[player.userID].Weapons != null) {
                if (string.IsNullOrEmpty(playerData.players[player.userID].Weapons.collectionname)) playerData.players[player.userID].Weapons.weapons = null;
                else if (!gwData.WeaponSets.ContainsKey(playerData.players[player.userID].Weapons.collectionname)) {
                    playerData.players[player.userID].Weapons.collectionname = null;
                    playerData.players[player.userID].Weapons.weapons = null;
                }
                if (string.IsNullOrEmpty(playerData.players[player.userID].Weapons.collectionname) && playerData.players[player.userID].WeaponCollections.Count() > 0 || playerData.players[player.userID].Weapons.weapons == null && playerData.players[player.userID].WeaponCollections.Count() > 0) {
                    if (playerData.players[player.userID].WeaponSelection.ContainsKey(playerData.players[player.userID].WeaponCollections.First().Key)) {
                        playerData.players[player.userID].Weapons.collectionname = "N00b";
                        playerData.players[player.userID].WeaponSelection.Add(playerData.players[player.userID].Weapons.collectionname, new Dictionary<string, List<string>>());
                        foreach (var entry in playerData.players[player.userID].WeaponCollections[playerData.players[player.userID].Weapons.collectionname]) playerData.players[player.userID].WeaponSelection[playerData.players[player.userID].Weapons.collectionname].Add(entry.Key, new List<string>());
                        GiveWeaponCollection(player);
                    }
                }
            }
            //Puts("7");
            PlayerHUD(player);
        }
        private object CheckPoints(ulong ID) => ServerRewards?.Call("CheckPoints", ID);
        void DestroyACPlayer(BasePlayer player) {
            if (player == null) return;
            {
                DestroyUI(player);
                player.Command($"bind {configData.MenuKeyBinding} \"\"");
                player.Command($"bind tab \"inventory.toggle\"");
                ACUIInfo.Remove(player.userID);
            }
        }
        private void OnPlayerDisconnected(BasePlayer player) {
            DestroyACPlayer(player);
            SaveData();
        }
        private string GetLang(string msg) {
            if (messages.ContainsKey(msg)) return lang.GetMessage(msg, this);
            else return msg;
        }
        private void GetSendMSG(BasePlayer player, string message, string arg1 = "", string arg2 = "", string arg3 = "") {
            string msg = string.Format(GetLang(message), arg1, arg2, arg3);
            SendReply(player, TitleColor + lang.GetMessage("title", this, player.UserIDString) + "</color>" + MsgColor + msg + "</color>");
        }
        private string GetMSG(string message, string arg1 = "", string arg2 = "", string arg3 = "") {
            string msg = string.Format(lang.GetMessage(message, this), arg1, arg2, arg3);
            return msg;
        }
        static void TPPlayer(BasePlayer player, Vector3 destination) {
            if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "StartLoading", null, null, null, null, null);
            StartSleeping(player);
            player.MovePosition(destination);
            if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "ForcePositionTo", destination);
            if (player.net?.connection != null) player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true);
            player.UpdateNetworkGroup();
            player.SendNetworkUpdateImmediate(false);
            if (player.net?.connection == null) return;
            try {
                player.ClearEntityQueue(null);
            }
            catch {
            }
            player.SendFullSnapshot();
        }
        static void StartSleeping(BasePlayer player) {
            if (player.IsSleeping()) return;
            player.SetPlayerFlag(BasePlayer.PlayerFlags.Sleeping, true);
            if (!BasePlayer.sleepingPlayerList.Contains(player)) BasePlayer.sleepingPlayerList.Add(player);
            player.CancelInvoke("InventoryUpdate");
        }
        [ConsoleCommand("OpenACUI")]
        private void cmdOpenACUI(ConsoleSystem.Arg arg) {
            var player = arg.Connection.player as BasePlayer;
            if (player == null) return;
            if (ACUIInfo.ContainsKey(player.userID)) if (!ACUIInfo[player.userID].open) {
                ACUIInfo[player.userID].open = true;
                OpenACUI(player);
            }
            else DestroyACPanel(player);
            else OpenACUI(player);
        }
        private void OpenACUI(BasePlayer player) {
            if (!ACUIInfo.ContainsKey(player.userID)) ACUIInfo.Add(player.userID, new screen {
                admin = false, open = true, GearIndex = 0, GearSet = "", WeaponIndex = 0, WeaponSet = "", page = 0
            }
            );
            ACPanel(player);
            GearListPanel(player);
            WeaponListPanel(player);
            if (ACUIInfo[player.userID].weapon) WeaponPanel(player);
            else if (ACUIInfo[player.userID].gear) GearPanel(player);
        }
        public void DestroyUI(BasePlayer player) {
            DestroyACPanel(player);
            CuiHelper.DestroyUi(player, PanelOnScreen);
            CuiHelper.DestroyUi(player, PanelPurchaseConfirmation);
            CuiHelper.DestroyUi(player, PanelStats);
        }
        [ConsoleCommand("UI_DestroyACPanel")]
        private void cmdUI_DestroyACPanel(ConsoleSystem.Arg arg) {
            var player = arg.Connection.player as BasePlayer;
            if (player == null) return;
            DestroyACPanel(player);
        }
        public void DestroyACPanel(BasePlayer player) {
            if (ACUIInfo.ContainsKey(player.userID)) ACUIInfo[player.userID].open = false;
            CuiHelper.DestroyUi(player, PanelAC);
            CuiHelper.DestroyUi(player, GPanel);
            CuiHelper.DestroyUi(player, WPanel);
            CuiHelper.DestroyUi(player, GLPanel);
            CuiHelper.DestroyUi(player, WLPanel);
            CuiHelper.DestroyUi(player, APanel);
        }
        public void Broadcast(string message, string userid = "0") => PrintToChat(message);
        private void SendDeathNote(BasePlayer player, BasePlayer victim) {
            string colorAttacker = "";
            string colorVictim = "";
            colorAttacker = "<color=#e60000>";
            colorVictim = "<color=#3366ff>";
            if (configData.BroadcastDeath) {
                string formatMsg = colorAttacker + player.displayName + "</color>" + GetLang("DeathMessage") + colorVictim + victim.displayName + "</color>";
                Broadcast(formatMsg);
            }
        }
        private void SaveCollect(BasePlayer player) {
            if (!SavingCollection.ContainsKey(player.userID)) return;
            var index = 0;
            var name = "";
            bool used = true;
            var type = SavingCollection[player.userID];
            if (type == "gear") {
                if (gwData.GearSets.Count == 0) index = 0;
                else {
                    List<int> AllIndexes = new List<int>();
                    foreach (var entry in gwData.GearSets) AllIndexes.Add(entry.Value.index);
                    while (used == true) {
                        if (AllIndexes.Contains(index)) index++;
                        else used = false;
                    }
                }
                List<Gear> gearlist = new List<Gear>();
                foreach (var entry in NewGearCollection[player.userID].collection.set) gearlist.Add(entry.Value);
                name = NewGearCollection[player.userID].setname;
                var newset = new GearSet {
                    cost = NewGearCollection[player.userID].collection.cost, killsrequired = NewGearCollection[player.userID].collection.killsrequired, set = gearlist, index = index
                }
                ;
                gwData.GearSets.Add(name, newset);
                NewGearCollection.Remove(player.userID);
            }
            else if(type == "weapon") {
                if (gwData.WeaponSets.Count == 0) index = 0;
                else {
                    List<int> AllIndexes = new List<int>();
                    foreach (var entry in gwData.WeaponSets) AllIndexes.Add(entry.Value.index);
                    while (used == true) {
                        if (AllIndexes.Contains(index)) index++;
                        else used = false;
                    }
                }
                List<Weapon> gearlist = new List<Weapon>();
                foreach (var entry in NewWeaponCollection[player.userID].collection.set) gearlist.Add(entry.Value);
                name = NewWeaponCollection[player.userID].setname;
                var newset = new WeaponSet {
                    cost = NewWeaponCollection[player.userID].collection.cost, killsrequired = NewWeaponCollection[player.userID].collection.killsrequired, set = gearlist, index = index
                }
                ;
                gwData.WeaponSets.Add(name, newset);
                NewWeaponCollection.Remove(player.userID);
            }
            SavingCollection.Remove(player.userID);
            GetSendMSG(player, "NewCollectionCreated", type.ToUpper(), name);
            DestroyACPanel(player);
            SaveData();
            foreach (var p in BasePlayer.activePlayerList) CheckCollections(p);
        }
        private void ExitSetCreation(BasePlayer player) {
            if (!SavingCollection.ContainsKey(player.userID)) return;
            SavingCollection.Remove(player.userID);
            DestroyACPanel(player);
        }
        bool isAuth(BasePlayer player) {
            if (player.net.connection != null) if (player.net.connection.authLevel < 1) return false;
            return true;
        }
        private List<BasePlayer> FindPlayer(string arg) {
            var foundPlayers = new List<BasePlayer>();
            ulong steamid;
            ulong.TryParse(arg, out steamid);
            string lowerarg = arg.ToLower();
            foreach (var p in BasePlayer.activePlayerList) if (p != null) {
                if (steamid != 0L) if (p.userID == steamid) {
                    foundPlayers.Add(p);
                    return foundPlayers;
                }
                string lowername = p.displayName.ToLower();
                if (lowername.Contains(lowerarg)) foundPlayers.Add(p);
            }
            return foundPlayers;
        }
        [ConsoleCommand("addmoney")]
        private void cmdaddmoney(ConsoleSystem.Arg arg) {
            if (arg.Connection != null) if (arg.Connection.authLevel < 1) {
                if (arg.Connection.player != null) {
                    var player = arg.Connection.player as BasePlayer;
                    GetSendMSG(player, "NotAuthorized");
                }
                return;
            }
            chatAddMoney(null, "addmoney", arg.Args);
        }
        [ConsoleCommand("takemoney")]
        private void cmdtakemoney(ConsoleSystem.Arg arg) {
            if (arg.Connection != null) if (arg.Connection.authLevel < 1) {
                if (arg.Connection.player != null) {
                    var player = arg.Connection.player as BasePlayer;
                    GetSendMSG(player, "NotAuthorized");
                }
                return;
            }
            chattakemoney(null, "takemoney", arg.Args);
        }
        [ConsoleCommand("addkills")]
        private void cmdaddkills(ConsoleSystem.Arg arg) {
            if (arg.Connection != null) if (arg.Connection.authLevel < 1) {
                if (arg.Connection.player != null) {
                    var player = arg.Connection.player as BasePlayer;
                    GetSendMSG(player, "NotAuthorized");
                }
                return;
            }
            chatAddKills(null, "addkills", arg.Args);
        }
        [ConsoleCommand("takekills")]
        private void cmdtakekills(ConsoleSystem.Arg arg) {
            if (arg.Connection != null) if (arg.Connection.authLevel < 1) {
                if (arg.Connection.player != null) {
                    var player = arg.Connection.player as BasePlayer;
                    GetSendMSG(player, "NotAuthorized");
                }
                return;
            }
            chatTakeKills(null, "takekills", arg.Args);
        }
        [ChatCommand("addmoney")]
        private void chatAddMoney(BasePlayer player, string command, string[] args) {
            if (player != null) {
                if (!isAuth(player)) {
                    GetSendMSG(player, "NotAuthorized");
                    return;
                }
            }
            if (args.Length == 2) {
                int amount;
                if (!int.TryParse(args[1], out amount)) {
                    if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
                    else GetSendMSG(player, "INVALIDENTRY", args[1]);
                    return;
                }
                var partialPlayerName = args[0];
                var foundPlayers = FindPlayer(partialPlayerName);
                if (foundPlayers.Count() == 0) {
                    if (player == null) Puts(GetMSG("NoPlayers", args[0]));
                    else GetSendMSG(player, "NoPlayers", args[0]);
                    return;
                }
                if (foundPlayers.Count() > 1) {
                    if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
                    else GetSendMSG(player, "MultiplePlayers", args[0]);
                    return;
                }
                if (foundPlayers[0] != null) {
                    ulong requestor = 0;
                    if (player != null) requestor = player.userID;
                    AddMoney(foundPlayers[0].userID, amount, true, requestor);
                    PlayerHUD(foundPlayers[0]);
                }
            }
            else {
                if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/addmoney PLAYERNAME AMOUNT", "/addmoney Absolut 20"));
                else GetSendMSG(player, "ArgumentsIncorrect", "/addmoney PLAYERNAME AMOUNT", "/addmoney Absolut 20");
            }
        }
        [ChatCommand("addkills")]
        private void chatAddKills(BasePlayer player, string command, string[] args) {
            if (player != null) {
                if (!isAuth(player)) {
                    GetSendMSG(player, "NotAuthorized");
                    return;
                }
            }
            if (args.Length == 4) {
                int amount;
                if (!int.TryParse(args[3], out amount)) {
                    if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
                    else GetSendMSG(player, "INVALIDENTRY", args[1]);
                    return;
                }
                var partialPlayerName = args[0];
                var type = args[1];
                var collection = args[2];
                var foundPlayers = FindPlayer(partialPlayerName);
                if (foundPlayers.Count() == 0) {
                    if (player == null) Puts(GetMSG("NoPlayers", args[0]));
                    else GetSendMSG(player, "NoPlayers", args[0]);
                    return;
                }
                if (foundPlayers.Count() > 1) {
                    if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
                    else GetSendMSG(player, "MultiplePlayers", args[0]);
                    return;
                }
                if (foundPlayers[0] != null) {
                    ulong requestor = 0;
                    if (player != null) requestor = player.userID;
                    if (type == "weapon") {
                        if (gwData.WeaponSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].WeaponCollections.ContainsKey(collection)) AddKills(foundPlayers[0].userID, amount, type, collection, requestor);
                    }
                    else if (type == "gear") {
                        if (gwData.GearSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].GearCollections.ContainsKey(collection)) AddKills(foundPlayers[0].userID, amount, type, collection, requestor);
                    }
                    PlayerHUD(foundPlayers[0]);
                }
            }
            else {
                if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/addkills PLAYERNAME TYPE COLLECTION AMOUNT", "/addkills Absolut weapon starter 20"));
                else GetSendMSG(player, "ArgumentsIncorrect", "/addkills PLAYERNAME TYPE COLLECTION AMOUNT", "/addkills Absolut weapon starter 20");
            }
        }
        [ChatCommand("takekills")]
        private void chatTakeKills(BasePlayer player, string command, string[] args) {
            if (player != null) {
                if (!isAuth(player)) {
                    GetSendMSG(player, "NotAuthorized");
                    return;
                }
            }
            if (args.Length == 4) {
                int amount;
                if (!int.TryParse(args[3], out amount)) {
                    if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
                    else GetSendMSG(player, "INVALIDENTRY", args[1]);
                    return;
                }
                var partialPlayerName = args[0];
                var type = args[1];
                var collection = args[2];
                var foundPlayers = FindPlayer(partialPlayerName);
                if (foundPlayers.Count() == 0) {
                    if (player == null) Puts(GetMSG("NoPlayers", args[0]));
                    else GetSendMSG(player, "NoPlayers", args[0]);
                    return;
                }
                if (foundPlayers.Count() > 1) {
                    if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
                    else GetSendMSG(player, "MultiplePlayers", args[0]);
                    return;
                }
                if (foundPlayers[0] != null) {
                    ulong requestor = 0;
                    if (player != null) requestor = player.userID;
                    if (type == "weapon") {
                        if (gwData.WeaponSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].WeaponCollections.ContainsKey(collection)) TakeKills(foundPlayers[0].userID, amount, type, collection, requestor);
                    }
                    else if (type == "gear") {
                        if (gwData.GearSets.ContainsKey(collection) && playerData.players[foundPlayers[0].userID].GearCollections.ContainsKey(collection)) TakeKills(foundPlayers[0].userID, amount, type, collection, requestor);
                    }
                    PlayerHUD(foundPlayers[0]);
                }
            }
            else {
                if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/takekills PLAYERNAME TYPE COLLECTION AMOUNT", "/takekills Absolut weapon starter 20"));
                else GetSendMSG(player, "ArgumentsIncorrect", "/takekills PLAYERNAME TYPE COLLECTION AMOUNT", "/takekills Absolut weapon starter 20");
            }
        }
        [ChatCommand("takemoney")]
        private void chattakemoney(BasePlayer player, string command, string[] args) {
            if (player != null) {
                if (!isAuth(player)) {
                    GetSendMSG(player, "NotAuthorized");
                    return;
                }
            }
            if (args.Length == 2) {
                int amount;
                if (!int.TryParse(args[1], out amount)) {
                    if (player == null) Puts(GetMSG("INVALIDENTRY", args[1]));
                    else GetSendMSG(player, "INVALIDENTRY", args[1]);
                    return;
                }
                var partialPlayerName = args[0];
                var foundPlayers = FindPlayer(partialPlayerName);
                if (foundPlayers.Count() == 0) {
                    if (player == null) Puts(GetMSG("NoPlayers", args[0]));
                    else GetSendMSG(player, "NoPlayers", args[0]);
                    return;
                }
                if (foundPlayers.Count() > 1) {
                    if (player == null) Puts(GetMSG("MultiplePlayers", args[0]));
                    else GetSendMSG(player, "MultiplePlayers", args[0]);
                    return;
                }
                if (foundPlayers[0] != null) {
                    ulong requestor = 0;
                    if (player != null) requestor = player.userID;
                    TakeMoney(foundPlayers[0].userID, amount, true, requestor);
                    PlayerHUD(foundPlayers[0]);
                }
            }
            else {
                if (player == null) Puts(GetMSG("ArgumentsIncorrect", "/takemoney PLAYERNAME AMOUNT", "/takemoney Absolut 20"));
                else GetSendMSG(player, "ArgumentsIncorrect", "/takemoney PLAYERNAME AMOUNT", "/takemoney Absolut 20");
            }
        }
#endregion
#region UI Creation
        private string PanelAC = "PanelAC";
        private string GLPanel = "GLPanel";
        private string WLPanel = "WLPanel";
        private string GPanel = "GPanel";
        private string WPanel = "WPanel";
        private string APanel = "APanel";
        private string PanelOnScreen = "OnScreen";
        private string PanelPurchaseConfirmation = "PurchaseConfirmation";
        private string PanelStats = "StatsPanel";
        public class UI {
            static public CuiElementContainer CreateElementContainer(string panelName, string color, string aMin, string aMax, bool cursor = false) {
                var NewElement = new CuiElementContainer() {
                    {
                        new CuiPanel {
                            Image = {
                                Color = color
                            }
                            , RectTransform = {
                                AnchorMin = aMin, AnchorMax = aMax
                            }
                            , CursorEnabled = cursor
                        }
                        , new CuiElement().Parent, panelName
                    }
                }
                ;
                return NewElement;
            }
            static public void CreatePanel(ref CuiElementContainer container, string panel, string color, string aMin, string aMax, bool cursor = false) {
                container.Add(new CuiPanel {
                    Image = {
                        Color = color
                    }
                    , RectTransform = {
                        AnchorMin = aMin, AnchorMax = aMax
                    }
                    , CursorEnabled = cursor
                }
                , panel);
            }
            static public void CreateLabel(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter) {
                container.Add(new CuiLabel {
                    Text = {
                        Color = color, FontSize = size, Align = align, FadeIn = 1.0f, Text = text
                    }
                    , RectTransform = {
                        AnchorMin = aMin, AnchorMax = aMax
                    }
                }
                , panel);
            }
            static public void CreateButton(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, string command, TextAnchor align = TextAnchor.MiddleCenter) {
                container.Add(new CuiButton {
                    Button = {
                        Color = color, Command = command, FadeIn = 1.0f
                    }
                    , RectTransform = {
                        AnchorMin = aMin, AnchorMax = aMax
                    }
                    , Text = {
                        Text = text, FontSize = size, Align = align
                    }
                }
                , panel);
            }
            static public void LoadImage(ref CuiElementContainer container, string panel, string img, string aMin, string aMax) {
                if (img.StartsWith("http") || img.StartsWith("www")) {
                    container.Add(new CuiElement {
                        Parent = panel, Components = {
                            new CuiRawImageComponent {
                                Url = img, Sprite = "assets/content/textures/generic/fulltransparent.tga"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = aMin, AnchorMax = aMax
                            }
                        }
                    }
                    );
                }
                else container.Add(new CuiElement {
                    Parent = panel, Components = {
                        new CuiRawImageComponent {
                            Png = img, Sprite = "assets/content/textures/generic/fulltransparent.tga"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = aMin, AnchorMax = aMax
                        }
                    }
                }
                );
            }
            static public void CreateTextOverlay(ref CuiElementContainer container, string panel, string text, string color, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter, float fadein = 1.0f) {
                //if (configdata.DisableUI_FadeIn)
                //    fadein = 0;
                container.Add(new CuiLabel {
                    Text = {
                        Color = color, FontSize = size, Align = align, FadeIn = fadein, Text = text
                    }
                    , RectTransform = {
                        AnchorMin = aMin, AnchorMax = aMax
                    }
                }
                , panel);
            }
            static public void CreateTextOutline(ref CuiElementContainer element, string panel, string colorText, string colorOutline, string text, int size, string DistanceA, string DistanceB, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter) {
                element.Add(new CuiElement {
                    Parent = panel, Components = {
                        new CuiTextComponent {
                            Color = colorText, FontSize = size, Align = align, Text = text
                        }
                        , new CuiOutlineComponent {
                            Distance = DistanceA + " " + DistanceB, Color = colorOutline
                        }
                        , new CuiRectTransformComponent {
                            AnchorMax = aMax, AnchorMin = aMin
                        }
                    }
                }
                );
            }
        }
        private Dictionary<string, string> UIColors = new Dictionary<string, string> {
            {
                "black", "0 0 0 1.0"
            }
            , {
                "dark", "0.1 0.1 0.1 0.98"
            }
            , {
                "header", "1 1 1 0.3"
            }
            , {
                "light", ".564.564.564 1.0"
            }
            , {
                "grey1", "0.6 0.6 0.6 1.0"
            }
            , {
                "brown", "0.3 0.16 0.0 1.0"
            }
            , {
                "yellow", "0.9 0.9 0.0 1.0"
            }
            , {
                "orange", "1.0 0.65 0.0 1.0"
            }
            , {
                "blue", "0.2 0.6 1.0 1.0"
            }
            , {
                "red", "1.0 0.1 0.1 1.0"
            }
            , {
                "white", "1 1 1 1"
            }
            , {
                "limegreen", "0.42 1.0 0 1.0"
            }

// ... [Code preview truncated due to length. Full source in attached file] ...

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