コード例 #1
0
ファイル: CommandSave.cs プロジェクト: Ex-Presidents/Loadout
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, Syntax);
                return;
            }

            #region vars

            UnturnedPlayer player = (UnturnedPlayer)caller;

            ulong id = player.CSteamID.m_SteamID;

            List <LItem> itemList = new List <LItem>();

            PlayerClothing clo = player.Player.clothing;

            bool DebugMode = Loadout.Instance.Configuration.Instance.DebugMode;

            #endregion vars

            #region items

            if (DebugMode)
            {
                Logger.Log("Beginning item saves");
            }

            for (byte p = 0; p < PlayerInventory.PAGES - 1; p++)
            {
                for (byte i = 0; i < player.Inventory.getItemCount(p); i++)
                {
                    Item item = player.Inventory.getItem(p, i).item;
                    if (Loadout.Instance.Configuration.Instance.ItemBlacklist.Contains(item.id))
                    {
                        if (Loadout.Instance.Configuration.Instance.DenyOnBlacklist)
                        {
                            UnturnedChat.Say(caller, Loadout.Instance.Translate("denied", item.id));
                            return;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, Loadout.Instance.Translate("blacklisted", item.id));
                            continue;
                        }
                    }
                    itemList.Add(new LItem(item.id, item.metadata));
                }
            }

            if (DebugMode)
            {
                Logger.Log("Beginning blacklist check");
            }

            if (itemList.Count > Loadout.Instance.Configuration.Instance.ItemLimit)
            {
                UnturnedChat.Say(caller, Loadout.Instance.Translate("too_much", Loadout.Instance.Configuration.Instance.ItemLimit, itemList.Count));
                return;
            }

            if (DebugMode)
            {
                Logger.Log("Item saves complete");
                if (itemList == null)
                {
                    Logger.Log("Null");
                }
            }

            #endregion items

            #region clothing

            if (DebugMode)
            {
                Logger.Log("Beginning clothing save");
            }

            LoadoutClothing hat      = new LoadoutClothing(clo.hat, clo.hatQuality, clo.hatState);
            LoadoutClothing glasses  = new LoadoutClothing(clo.glasses, clo.glassesQuality, clo.glassesState);
            LoadoutClothing mask     = new LoadoutClothing(clo.mask, clo.maskQuality, clo.maskState);
            LoadoutClothing shirt    = new LoadoutClothing(clo.shirt, clo.shirtQuality, clo.shirtState);
            LoadoutClothing vest     = new LoadoutClothing(clo.vest, clo.vestQuality, clo.vestState);
            LoadoutClothing backpack = new LoadoutClothing(clo.backpack, clo.backpackQuality, clo.backpackState);
            LoadoutClothing pants    = new LoadoutClothing(clo.pants, clo.pantsQuality, clo.pantsState);

            LoadoutClothes clothes = new LoadoutClothes(hat, glasses, mask, shirt, vest, backpack, pants);

            if (DebugMode)
            {
                Logger.Log("Clothing save complete");
                if (clothes == null)
                {
                    Logger.Log("Null");
                }
            }

            #endregion clothing

            #region dictionary

            if (DebugMode)
            {
                Logger.Log("Beginning final dictionary save");
                if (Loadout.Instance.playerInvs == null)
                {
                    Logger.Log("Null");
                }
            }

            if (!Loadout.Instance.playerInvs.ContainsKey(id))
            {
                Loadout.Instance.playerInvs.Add(id, new LoadoutList(new Dictionary <string, LoadoutInventory>()));
                Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes));
                UnturnedChat.Say(caller, Loadout.Instance.Translate("saved"));

                if (DebugMode)
                {
                    Logger.Log("Player has no saves, adding to dictionary");
                }
            }
            else
            {
                if (DebugMode)
                {
                    Logger.Log("Player has saves");
                }

                if (!Loadout.Instance.playerInvs[id].inventories.ContainsKey(command[0]))
                {
                    Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes));
                    UnturnedChat.Say(caller, Loadout.Instance.Translate("saved"));

                    if (DebugMode)
                    {
                        Logger.Log("Player saved a unique kit");
                    }
                }
                else
                {
                    Loadout.Instance.playerInvs[id].inventories.Remove(command[0]);
                    Loadout.Instance.playerInvs[id].inventories.Add(command[0], new LoadoutInventory(itemList, clothes));
                    UnturnedChat.Say(caller, Loadout.Instance.Translate("replaced"));

                    if (DebugMode)
                    {
                        Logger.Log("Player has replaced a kit");
                    }
                }
            }

            #endregion dictionary
        }
コード例 #2
0
ファイル: CommandLoad.cs プロジェクト: Ex-Presidents/Loadout
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length != 1)
            {
                UnturnedChat.Say(caller, Syntax);
                return;
            }

            if (command[0].ToUpperInvariant() == "AUTO")
            {
                if (Loadout.Instance.Autos.Contains(player.CSteamID.m_SteamID))
                {
                    Loadout.Instance.Autos.Remove(player.CSteamID.m_SteamID);
                    UnturnedChat.Say(player, "Auto loading toggled off.");
                    return;
                }
                else
                {
                    Loadout.Instance.Autos.Add(player.CSteamID.m_SteamID);
                    UnturnedChat.Say(player, "Auto loading toggled on.");
                    return;
                }
            }

            if (!Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories.ContainsKey(command[0]))
            {
                UnturnedChat.Say(player, Loadout.Instance.Translate("no_kit"));
                return;
            }

            #region clothing

            PlayerClothing clo     = player.Player.clothing;
            LoadoutClothes clothes = Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].clothes;

            LoadoutClothing hat      = clothes.hat;
            LoadoutClothing glasses  = clothes.glasses;
            LoadoutClothing mask     = clothes.mask;
            LoadoutClothing shirt    = clothes.shirt;
            LoadoutClothing vest     = clothes.vest;
            LoadoutClothing backpack = clothes.backpack;
            LoadoutClothing pants    = clothes.pants;

            if (hat != null)
            {
                clo.askWearHat(hat.id, hat.quality, hat.state, true);
            }
            if (glasses != null)
            {
                clo.askWearGlasses(glasses.id, glasses.quality, glasses.state, true);
            }
            if (mask != null)
            {
                clo.askWearMask(mask.id, mask.quality, mask.state, true);
            }
            if (shirt != null)
            {
                clo.askWearShirt(shirt.id, shirt.quality, shirt.state, true);
            }
            if (vest != null)
            {
                clo.askWearVest(vest.id, vest.quality, vest.state, true);
            }
            if (backpack != null)
            {
                clo.askWearBackpack(backpack.id, backpack.quality, backpack.state, true);
            }
            if (pants != null)
            {
                clo.askWearPants(pants.id, pants.quality, pants.state, true);
            }

            #endregion clothing

            #region items

            for (int i = 0; i < Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].items.Count; i++)
            {
                LItem item  = Loadout.Instance.playerInvs[player.CSteamID.m_SteamID].inventories[command[0]].items[i];
                Item  item2 = new Item(item.ID, true)
                {
                    metadata = item.Meta
                };
                player.Inventory.tryAddItem(item2, true);
            }

            #endregion items

            UnturnedChat.Say(caller, Loadout.Instance.Translate("loaded"));
        }
コード例 #3
0
ファイル: Loadout.cs プロジェクト: Ex-Presidents/Loadout
        public void OnRevive(UnturnedPlayer Player, Vector3 Place, byte idk)
        {
            if (Autos.Contains(Player.CSteamID.m_SteamID) && ((IRocketPlayer)Player).HasPermission("loadout.autoload"))
            {
                LoadoutList List = playerInvs[Player.CSteamID.m_SteamID];
                if (List.inventories.ContainsKey("default"))
                {
                    LoadoutInventory Inventory = List.inventories["default"];

                    #region clothing

                    PlayerClothing clo     = Player.Player.clothing;
                    LoadoutClothes clothes = Inventory.clothes;

                    LoadoutClothing hat      = clothes.hat;
                    LoadoutClothing glasses  = clothes.glasses;
                    LoadoutClothing mask     = clothes.mask;
                    LoadoutClothing shirt    = clothes.shirt;
                    LoadoutClothing vest     = clothes.vest;
                    LoadoutClothing backpack = clothes.backpack;
                    LoadoutClothing pants    = clothes.pants;

                    if (hat != null)
                    {
                        clo.askWearHat(hat.id, hat.quality, hat.state, true);
                    }
                    if (glasses != null)
                    {
                        clo.askWearGlasses(glasses.id, glasses.quality, glasses.state, true);
                    }
                    if (mask != null)
                    {
                        clo.askWearMask(mask.id, mask.quality, mask.state, true);
                    }
                    if (shirt != null)
                    {
                        clo.askWearShirt(shirt.id, shirt.quality, shirt.state, true);
                    }
                    if (vest != null)
                    {
                        clo.askWearVest(vest.id, vest.quality, vest.state, true);
                    }
                    if (backpack != null)
                    {
                        clo.askWearBackpack(backpack.id, backpack.quality, backpack.state, true);
                    }
                    if (pants != null)
                    {
                        clo.askWearPants(pants.id, pants.quality, pants.state, true);
                    }

                    #endregion clothing

                    #region items

                    for (int i = 0; i < Inventory.items.Count; i++)
                    {
                        LItem item  = Inventory.items[i];
                        Item  item2 = new Item(item.ID, true)
                        {
                            metadata = item.Meta
                        };
                        Player.Inventory.tryAddItem(item2, true);
                    }

                    #endregion items
                    UnturnedChat.Say(Player, Instance.Translate("auto_loaded"));
                }
                else
                {
                    UnturnedChat.Say(Player, Instance.Translate("no_default"));
                }
            }
        }
コード例 #4
0
 public LoadoutInventory(List <LItem> items, LoadoutClothes clothes)
 {
     this.items   = items;
     this.clothes = clothes;
 }