Exemplo n.º 1
0
        public void ItemEffect(UnturnedPlayer p, ushort ID)
        {
            var i = Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == ID);

            if (i != null)
            {
                TShopComponent cp   = p.GetComponent <TShopComponent>();
                Asset          a    = Assets.find(EAssetType.ITEM, ID);
                string         cost = Translate("Buy_Price") + i.BuyCost + "|" + Translate("Sell_Price") + i.SellCost;
                cost = cost.Replace("|", "" + System.Environment.NewLine);

                string description = ((ItemAsset)a).itemDescription;

                string amt = cp.amt.ToString();
                cp.lookingid = i.Id;
                EffectManager.askEffectClearByID(Configuration.Instance.Main2ID, p.CSteamID);
                EffectManager.askEffectClearByID(Configuration.Instance.Main1ID, p.CSteamID);
                EffectManager.sendUIEffect(Configuration.Instance.BuySellID, 700, p.CSteamID, true, ((ItemAsset)a).itemName.ToString() + " (ID:" + ID + ")", cost, description, amt);
            }
            else
            {
                UnturnedChat.Say(p, Translate("item_isn't_added", Assets.find(EAssetType.ITEM, search).name, search), color: ErrorColor);
                return;
            }
        }
Exemplo n.º 2
0
        public void Key(Player player, uint simulation, byte key, bool state)
        {
            if (Configuration.Instance.AllowOpenUIWithKey)
            {
                int.TryParse(Configuration.Instance.Button, out int num);

                if (key == num && state)
                {
                    if (!Configuration.Instance.UIEnabled)
                    {
                        return;
                    }

                    TShopComponent cp = player.GetComponent <TShopComponent>();
                    if (!cp.UIOpened)
                    {
                        player.serversideSetPluginModal(true);
                        MainEffect(UnturnedPlayer.FromPlayer(player));
                        cp.UIOpened = true;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void MainEffect(UnturnedPlayer p)
        {
            TShopComponent cp = p.GetComponent <TShopComponent>();

            cp.amt = 1;
            ItemShop sh0 = null;
            ItemShop sh1 = null;
            ItemShop sh2 = null;
            ItemShop sh3 = null;
            ItemShop sh4 = null;
            ItemShop sh5 = null;
            ItemShop sh6 = null;
            ItemShop sh7 = null;

            if (cp.item0 < Configuration.Instance.ItemShop.Count)
            {
                sh0 = Configuration.Instance.ItemShop[cp.item0];
            }
            if (cp.item1 < Configuration.Instance.ItemShop.Count)
            {
                sh1 = Configuration.Instance.ItemShop[cp.item1];
            }
            if (cp.item2 < Configuration.Instance.ItemShop.Count)
            {
                sh2 = Configuration.Instance.ItemShop[cp.item2];
            }
            if (cp.item3 < Configuration.Instance.ItemShop.Count)
            {
                sh3 = Configuration.Instance.ItemShop[cp.item3];
            }
            if (cp.item4 < Configuration.Instance.ItemShop.Count)
            {
                sh4 = Configuration.Instance.ItemShop[cp.item4];
            }
            if (cp.item5 < Configuration.Instance.ItemShop.Count)
            {
                sh5 = Configuration.Instance.ItemShop[cp.item5];
            }
            if (cp.item6 < Configuration.Instance.ItemShop.Count)
            {
                sh6 = Configuration.Instance.ItemShop[cp.item6];
            }
            if (cp.item7 < Configuration.Instance.ItemShop.Count)
            {
                sh7 = Configuration.Instance.ItemShop[cp.item7];
            }

            string i0 = null;
            string i1 = null;
            string i2 = null;
            string i3 = null;
            string i4 = null;
            string i5 = null;
            string i6 = null;
            string i7 = null;

            if (sh0 != null)
            {
                i0 = Assets.find(EAssetType.ITEM, sh0.Id).name.ToString() + " (ID:" + sh0.Id + ")";
            }
            else
            {
                i0 = Translate("no_more_products");
            }

            if (sh1 != null)
            {
                i1 = Assets.find(EAssetType.ITEM, sh1.Id).name.ToString() + " (ID:" + sh1.Id + ")";
            }
            else
            {
                i1 = Translate("no_more_products");
            }

            if (sh2 != null)
            {
                i2 = Assets.find(EAssetType.ITEM, sh2.Id).name.ToString() + " (ID:" + sh2.Id + ")";
            }
            else
            {
                i2 = Translate("no_more_products");
            }

            if (sh3 != null)
            {
                i3 = Assets.find(EAssetType.ITEM, sh3.Id).name.ToString() + " (ID:" + sh3.Id + ")";
            }
            else
            {
                i3 = Translate("no_more_products");
            }

            if (sh4 != null)
            {
                i4 = Assets.find(EAssetType.ITEM, sh4.Id).name.ToString() + " (ID:" + sh4.Id + ")";
            }
            else
            {
                i4 = Translate("no_more_products");
            }

            if (sh5 != null)
            {
                i5 = Assets.find(EAssetType.ITEM, sh5.Id).name.ToString() + " (ID:" + sh5.Id + ")";
            }
            else
            {
                i5 = Translate("no_more_products");
            }

            if (sh6 != null)
            {
                i6 = Assets.find(EAssetType.ITEM, sh6.Id).name.ToString() + " (ID:" + sh6.Id + ")";
            }
            else
            {
                i6 = Translate("no_more_products");
            }

            if (sh7 != null)
            {
                i7 = Assets.find(EAssetType.ITEM, sh7.Id).name.ToString() + " (ID:" + sh7.Id + ")";
            }
            else
            {
                i7 = Translate("no_more_products");
            }

            EffectManager.askEffectClearByID(Configuration.Instance.OpenID, p.CSteamID);
            EffectManager.sendUIEffect(Configuration.Instance.Main1ID, 700, p.CSteamID, false, i0, i1, i2, i3);
            EffectManager.sendUIEffect(Configuration.Instance.Main2ID, 710, p.CSteamID, false, i4, i5, i6, i7);
        }
Exemplo n.º 4
0
        public void button(Player player, string buttonName)
        {
            if (!Configuration.Instance.UIEnabled)
            {
                return;
            }

            UnturnedPlayer p  = UnturnedPlayer.FromPlayer(player);
            TShopComponent cp = p.GetComponent <TShopComponent>();

            if (buttonName == "tshop_open")
            {
                p.Player.serversideSetPluginModal(true);
                MainEffect(p);
            }
            if (buttonName == "tshop_b")
            {
                EffectManager.askEffectClearByID(Configuration.Instance.BuySellID, p.CSteamID);
                MainEffect(p);
            }
            if (buttonName == "tshop_exit")
            {
                EffectManager.askEffectClearByID(Configuration.Instance.Main2ID, p.CSteamID);
                EffectManager.askEffectClearByID(Configuration.Instance.Main1ID, p.CSteamID);
                EffectManager.askEffectClearByID(Configuration.Instance.BuySellID, p.CSteamID);
                p.Player.serversideSetPluginModal(false);
                EffectManager.sendUIEffect(Configuration.Instance.OpenID, 700, p.CSteamID, false);
            }

            #region Shop
            if (buttonName.ToLower() == "tshop_next")
            {
                if (cp.item0 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item0 = cp.item0 + 8;
                }
                if (cp.item1 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item1 = cp.item1 + 8;
                }
                if (cp.item2 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item2 = cp.item2 + 8;
                }
                if (cp.item3 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item3 = cp.item3 + 8;
                }
                if (cp.item4 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item4 = cp.item4 + 8;
                }
                if (cp.item5 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item5 = cp.item5 + 8;
                }
                if (cp.item6 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item6 = cp.item6 + 8;
                }
                if (cp.item7 < Configuration.Instance.ItemShop.Count)
                {
                    cp.item7 = cp.item7 + 8;
                }

                MainEffect(p);
            }
            if (buttonName.ToLower() == "tshop_back")
            {
                if (cp.item0 >= 8)
                {
                    cp.item0 = cp.item0 - 8;
                }
                if (cp.item1 >= 9)
                {
                    cp.item1 = cp.item1 - 8;
                }
                if (cp.item2 >= 10)
                {
                    cp.item2 = cp.item2 - 8;
                }
                if (cp.item3 >= 11)
                {
                    cp.item3 = cp.item3 - 8;
                }
                if (cp.item4 >= 12)
                {
                    cp.item4 = cp.item4 - 8;
                }
                if (cp.item5 >= 13)
                {
                    cp.item5 = cp.item5 - 8;
                }
                if (cp.item6 >= 14)
                {
                    cp.item6 = cp.item6 - 8;
                }
                if (cp.item7 >= 15)
                {
                    cp.item7 = cp.item7 - 8;
                }

                MainEffect(p);
            }
            if (buttonName.ToLower() == "tshop_search")
            {
                if (search != null)
                {
                    if (Assets.find(EAssetType.ITEM, Convert.ToUInt16(search)) == null)
                    {
                        UnturnedChat.Say(p, Translate("item_isn't_found", search), color: ErrorColor);
                        return;
                    }

                    ushort   id = Convert.ToUInt16(search);
                    ItemShop i  = Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id);

                    if (i == null)
                    {
                        UnturnedChat.Say(p, Translate("item_isn't_added", Assets.find(EAssetType.ITEM, id).name, id), color: ErrorColor);
                        return;
                    }
                    else
                    {
                        ItemEffect(p, i.Id);
                    }
                }
                else
                {
                    UnturnedChat.Say(p, Translate("search_empty"));
                    return;
                }
            }
            if (buttonName.ToLower() == "tshop_item_0")
            {
                if (cp.item0 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item0];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_1")
            {
                if (cp.item1 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item1];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_2")
            {
                if (cp.item2 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item2];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_3")
            {
                if (cp.item3 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item3];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_4")
            {
                if (cp.item4 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item4];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_5")
            {
                if (cp.item5 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item5];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_6")
            {
                if (cp.item6 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item6];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_item_7")
            {
                if (cp.item7 < Configuration.Instance.ItemShop.Count)
                {
                    var i = Configuration.Instance.ItemShop[cp.item7];
                    ItemEffect(p, i.Id);
                }
            }
            if (buttonName.ToLower() == "tshop_buy")
            {
                if (cp.lookingid != 0 && cp.amt != 0)
                {
                    ChatManager.instance.askChat(p.CSteamID, (byte)EChatMode.LOCAL, string.Join(" ", "/shopbuy " + cp.lookingid + " " + cp.amt));
                }
            }
            if (buttonName.ToLower() == "tshop_sell")
            {
                if (cp.lookingid != 0 && cp.amt != 0)
                {
                    ChatManager.instance.askChat(p.CSteamID, (byte)EChatMode.LOCAL, string.Join(" ", "/shopsell " + cp.lookingid + " " + cp.amt));
                }
            }
            if (buttonName.ToLower() == "tshop_+")
            {
                cp.amt = cp.amt + 1;
                ItemEffect(p, cp.lookingid);
            }
            if (buttonName.ToLower() == "tshop_-")
            {
                if (cp.amt > 1)
                {
                    cp.amt = cp.amt - 1;
                    ItemEffect(p, cp.lookingid);
                }
            }
            #endregion
        }