Ejemplo n.º 1
0
        private object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
        {
            var itemname = task.blueprint.targetItem.displayName.english;

            if (AdminInstantCraft && task.owner.net.connection.authLevel == 2)
            {
                task.endTime = 1f;
            }
            if (ModeratorInstantCraft && task.owner.net.connection.authLevel == 1)
            {
                task.endTime = 1f;
            }
            if (!BlockedItems.Contains(itemname))
            {
                return(null);
            }
            task.cancelled = true;
            SendChatMessage(crafter, CraftBlockedItem, itemname);
            foreach (var amount in task.blueprint.ingredients)
            {
                crafter.inventory.GiveItem(ItemManager.CreateByItemID(amount.itemid, (int)amount.amount * task.amount));
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void BlockCommandConsole(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin())
            {
                arg.ReplyWith(NoPermission);
                return;
            }

            if (!arg.HasArgs(1))
            {
                arg.ReplyWith(NoItemSpecified);
                return;
            }

            var item = string.Join(" ", arg.Args);

            if (!Items.Contains(item))
            {
                arg.ReplyWith(string.Format(InvalidItem, item));
                return;
            }

            if (BlockedItems.Contains(item))
            {
                arg.ReplyWith(string.Format(BlockedItem, item));
                return;
            }

            BlockedItems.Add(item);
            SetConfigValue("Options", "BlockedItems", BlockedItems);
            arg.ReplyWith(string.Format(BlockSucces, item));
        }
Ejemplo n.º 3
0
        private void BlockCommandChat(BasePlayer player, string command, string[] args)
        {
            if (!player.IsAdmin())
            {
                SendChatMessage(player, NoPermission);
                return;
            }

            if (args.Length == 0)
            {
                SendChatMessage(player, NoItemSpecified);
                return;
            }

            var item = string.Join(" ", args);

            if (!Items.Contains(item))
            {
                SendChatMessage(player, InvalidItem, item);
                return;
            }

            if (BlockedItems.Contains(item))
            {
                SendChatMessage(player, BlockedItem, item);
                return;
            }

            BlockedItems.Add(item);
            SetConfigValue("Options", "BlockedItems", BlockedItems);
            SendChatMessage(player, BlockSucces, item);
        }
Ejemplo n.º 4
0
 public static bool TransferItem(ShPlayer player, ref byte deltaType, ref int itemIndex, ref int amount, ref bool dispatch)
 {
     try
     {
         if (player != null && BlockedItems.Count > 0 && BlockedItems.Contains(itemIndex))
         {
             player.svPlayer.SendChatMessage(BlockedItemMessage);
             return(true);
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.Run(ex);
     }
     return(false);
 }
Ejemplo n.º 5
0
        private object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
        {
            var   def      = task.blueprint.targetItem;
            var   itemname = def.displayName.english;
            ulong skin     = 0;

            /*if (Skins != null)
             *  skin = (ulong) Skins.Call("GetRandomSkin", task.blueprint.targetItem);*/
            var item = ItemManager.Create(task.blueprint.targetItem, task.amount * task.blueprint.amountToCreate, skin);


            if (!BlockedItems.Contains(itemname))
            {
                task.cancelled = true;
                if (!item.MoveToContainer(crafter.inventory.containerMain.IsFull()
                        ? crafter.inventory.containerBelt
                        : crafter.inventory.containerMain))
                {
                    task.cancelled = true;
                    item.RemoveFromContainer();
                    item.Remove();
                    foreach (var amount in task.blueprint.ingredients)
                    {
                        crafter.inventory.GiveItem(ItemManager.CreateByItemID(amount.itemid, (int)amount.amount * task.amount));
                    }
                    crafter.ChatMessage("Недостаточно места!");
                    return(false);
                }
                return(true);
            }
            task.cancelled = true;
            SendChatMessage(crafter, CraftBlockedItem, itemname);
            foreach (var amount in task.blueprint.ingredients)
            {
                crafter.inventory.GiveItem(ItemManager.CreateByItemID(amount.itemid, (int)amount.amount * task.amount));
            }
            item.RemoveFromContainer();
            item.Remove();
            CancelAllCrafting(crafter);
            return(false);
        }
Ejemplo n.º 6
0
        private void UnblockCommandConsole(ConsoleSystem.Arg arg)
        {
            if (arg.Player() != null && !arg.Player().IsAdmin())
            {
                arg.ReplyWith(NoPermission);
                return;
            }

            if (!arg.HasArgs())
            {
                arg.ReplyWith(NoItemSpecified);
                return;
            }

            var item = string.Join(" ", arg.Args);

            if (item != "*")
            {
                if (!Items.Contains(item))
                {
                    arg.ReplyWith(string.Format(InvalidItem, item));
                    return;
                }

                if (!BlockedItems.Contains(item))
                {
                    arg.ReplyWith(string.Format(UnblockItem, item));
                    return;
                }

                BlockedItems.Remove(item);
            }
            else
            {
                BlockedItems = new List <string>();
            }

            SetConfigValue("Options", "BlockedItems", BlockedItems);
            arg.ReplyWith(string.Format(UnblockSucces, item));
        }
        private void UnblockCommandChat(BasePlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                SendChatMessage(player, NoPermission);
                return;
            }

            if (args.Length == 0)
            {
                SendChatMessage(player, NoItemSpecified);
                return;
            }

            var item = string.Join(" ", args);

            if (item != "*")
            {
                if (!Items.Contains(item))
                {
                    SendChatMessage(player, InvalidItem, item);
                    return;
                }

                if (!BlockedItems.Contains(item))
                {
                    SendChatMessage(player, UnblockItem, item);
                    return;
                }

                BlockedItems.Remove(item);
            }
            else
            {
                BlockedItems = new List <string>();
            }

            SetConfigValue("Options", "BlockedItems", BlockedItems);
            SendChatMessage(player, UnblockSucces, item);
        }
Ejemplo n.º 8
0
        private object OnItemCraft(ItemCraftTask task, BasePlayer crafter)
        {
            var itemname = task.blueprint.targetItem.displayName.english;
            ///
            var player = task.owner;
            var target = task.blueprint.targetItem;
            var name   = target.shortname;
            var stacks = GetStacks(target, task.amount * task.blueprint.amountToCreate);
            var slots  = FreeSlots(player);

            ///
            if (BlockedItems.Contains(itemname))
            {
                task.cancelled = true;
                SendChatMessage(crafter, CraftBlockedItem, itemname);
                foreach (var item in task.takenItems)
                {
                    player.GiveItem(item);
                }
                //foreach (var amount in task.blueprint.ingredients) crafter.inventory.GiveItem(ItemManager.CreateByItemID(amount.itemid, (int)amount.amount * task.amount));
                return(false);
            }

            if (!AllowCraftingWhenInventoryIsFull && !HasPlace(slots, stacks))
            {
                task.cancelled = true;
                SendChatMessage(crafter, NoSlots, stacks.Count, slots);
                foreach (var item in task.takenItems)
                {
                    player.GiveItem(item);
                }
                return(false);
            }

            if (AdminInstantBulkCraft && task.owner.net.connection.authLevel == 2)
            {
                InstantBulkCraft(player, target, stacks, task.skinID);
                task.cancelled = true;
                return(false);
            }

            if (ModeratorInstantBulkCraft && task.owner.net.connection.authLevel == 1)
            {
                InstantBulkCraft(player, target, stacks, task.skinID);
                task.cancelled = true;
                return(false);
            }

            if (AdminInstantCraft && task.owner.net.connection.authLevel == 2)
            {
                task.endTime = 1f;
            }
            if (ModeratorInstantCraft && task.owner.net.connection.authLevel == 1)
            {
                task.endTime = 1f;
            }
            if (PlayerInstantBulkCraft && task.blueprint.time <= 0f)
            {
                InstantBulkCraft(player, target, stacks, task.skinID);
                task.cancelled = true;
                return(false);
            }

            return(null);
        }