Exemplo n.º 1
0
        internal void OnChestItemChange(object sender, ChestItemEventArgs args)
        {
            Item item = new Item();

            item.netDefaults(args.Type);


            if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(item.type), args.Player))
            {
                SendCorrectiveMessage(args.Player, item.Name);
                args.Handled = true;
                return;
            }

            args.Handled = false;
            return;
        }
Exemplo n.º 2
0
        public void OnChestItemChange(object sender, ChestItemEventArgs e)
        {
            TSPlayer tSPlayer = e.Player;
            Player   player   = tSPlayer.TPlayer;

            e.Handled = true;
            Main.chest[e.ID].item[e.Slot] = new Item();
            tSPlayer.SendData(PacketTypes.ChestItem, "", e.ID, e.Slot, e.Stacks, e.Prefix, e.Type);

            string itemName = TShock.Utils.GetItemById(e.Type).Name;

            int  index = Item.NewItem(player.position, new Vector2(32, 48), e.Type, e.Stacks);
            Item item  = Main.item[index];

            var data = Plugin.Instance.item_data;

            if (data.BlockExists(itemName))
            {
                Block block = data.GetBlock(itemName);

                int.TryParse(block.GetValue(Parameters[Damage].TrimEnd(':', '0')), out item.damage);
                int.TryParse(block.GetValue(Parameters[Crit].TrimEnd(':', '0')), out item.crit);
                float.TryParse(block.GetValue(Parameters[KB].TrimEnd(':', '0')), out item.knockBack);
                byte.TryParse(block.GetValue(Parameters[Prefix].TrimEnd(':', '0')), out item.prefix);
                int.TryParse(block.GetValue(Parameters[ReuseDelay].TrimEnd(':', '0')), out item.reuseDelay);
                int.TryParse(block.GetValue(Parameters[Shoot].TrimEnd(':', '0')), out item.shoot);
                float.TryParse(block.GetValue(Parameters[ShootSpeed].TrimEnd(':', '0')), out item.shootSpeed);
                int.TryParse(block.GetValue(Parameters[UseAmmo].TrimEnd(':', '0')), out item.useAmmo);
                int.TryParse(block.GetValue(Parameters[UseTime].TrimEnd(':', '0')), out item.useTime);
                int.TryParse(block.GetValue(Parameters[Width].TrimEnd(':', '0')), out item.width);
                int.TryParse(block.GetValue(Parameters[Height].TrimEnd(':', '0')), out item.height);
                bool.TryParse(block.GetValue(Parameters[AutoReuse].TrimEnd(':', '0')), out item.autoReuse);
                int.TryParse(block.GetValue(Parameters[Ammo].TrimEnd(':', '0')), out item.ammo);
                float.TryParse(block.GetValue(Parameters[Scale].TrimEnd(':', '0')), out item.scale);

                TSPlayer.All.SendData(PacketTypes.TweakItem, "", index, 255, 63);
            }
        }
Exemplo n.º 3
0
        private static bool OnChestItemChange(short id, byte slot, short stacks, byte prefix, short type)
        {
            if (ChestItemChange == null)
                return false;

            var args = new ChestItemEventArgs
            {
                ID = id,
                Slot = slot,
                Stacks = stacks,
                Prefix = prefix,
                Type = type,
            };
            ChestItemChange.Invoke(null, args);
            return args.Handled;
        }