Esempio n. 1
0
        private object CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
        {
            var player = itemCrafter.GetComponent <BasePlayer>();
            var item   = bp.GetComponent <ItemDefinition>();

            if (permission.UserHasPermission(player.UserIDString, Perm))
            {
                return(null);
            }

            if (CFile.BlockAll.Enabled)
            {
                if (CFile.BlockAll.SendMessage)
                {
                    PrintToChat(player, Lang(Msg.CraftingDisabled, player.UserIDString));
                }
                return(false);
            }

            if (CFile.BlockedItems.ContainsKey(item.shortname))
            {
                if (CFile.BlockedItems[item.shortname])
                {
                    PrintToChat(player, Lang(Msg.CantCraft, player.UserIDString, item.displayName.english));
                }
                return(false);
            }

            return(null);
        }
Esempio n. 2
0
        bool CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
        {
            var player = itemCrafter.GetComponent <BasePlayer>();
            var item   = bp.GetComponent <ItemDefinition>();

            if (player == null || item == null)
            {
                return(false);
            }

            if (permission.UserHasPermission(player.UserIDString, perm1))
            {
                return(true);
            }

            if (permission.UserHasPermission(player.UserIDString, perm2))
            {
                SendReply(player, "You are not allowed to craft at all");
                return(false);
            }

            if (blacklist.Contains(item.shortname))
            {
                SendReply(player, "You are not allowed to craft <color=#eb4034>" + item.shortname + "</color>");
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        private void CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
        {
            var oplayer = itemCrafter?.GetComponent <BasePlayer>();

            if (oplayer != null && TrackedPlayers.ContainsKey(oplayer.userID))
            {
                TrackedPlayers[oplayer.userID].ResetAFKTime();
            }
        }
Esempio n. 4
0
        private void ForceUsableItem(ItemCrafter itemCrafter, int itemid, int required)
        {
            var  player = itemCrafter.GetComponent <BasePlayer>();
            Item item   = ItemManager.CreateByItemID(itemid, required);

            if (item != null)
            {
                player.GiveItem(item);
            }
        }
        bool CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
        {
            BasePlayer player = itemCrafter.GetComponent <BasePlayer>();

            if (InWorkbenchRadius.Contains(player.userID) == false)
            {
                if ((bool)Config["ShowMessages"] == true)
                {
                    player.IPlayer.Reply(lang.GetMessage("outofrange", this, player.IPlayer.Id));
                }
                return(false);
            }
            return(true);
        }
Esempio n. 6
0
        object CanCraft(ItemCrafter itemCrafter, ItemBlueprint bp, int amount)
        {
            var player = itemCrafter.GetComponent <BasePlayer>();

            if (!allPlayerSettings[player.userID].enabled)
            {
                return(null);
            }
            var transferItems = new Dictionary <Item, int>();
            var hasIngredient = new List <ItemAmount>();
            int check         = 0;

            if (player != null)
            {
                if (!IsInBuildingZone(player) && !allPlayerSettings[player.userID].fp)
                {
                    player.ChatMessage(string.Format(lang.GetMessage("NotInBuildingZone", this, player.UserIDString)));
                    return(null);
                }
                if (!HasPerm(player))
                {
                    player.ChatMessage(string.Format(lang.GetMessage("NoPermissions", this, player.UserIDString)));
                    return(null);
                }
                if (IsFull(player))
                {
                    player.ChatMessage(string.Format(lang.GetMessage("PlayerFull", this, player.UserIDString)));
                    return(null);
                }

                foreach (var itemAmount in bp.ingredients)
                {
                    if (HasIngredient(itemCrafter, itemAmount, amount))
                    {
                        check++;
                        hasIngredient.Add(itemAmount);
                        if (hasIngredient.Count >= bp.ingredients.Count)
                        {
                            return(null);
                        }
                        continue;
                    }
                    else
                    {
                        int required = (int)itemAmount.amount;

                        if (!allPlayerSettings[player.userID].fp || !CanForcePull(player))
                        {
                            // Gets Item info from Containers in Building Area
                            var possibleItems = GetUsableItems(player, itemAmount.itemid, required);
                            if (possibleItems != null)
                            {
                                check++;
                                foreach (var Item in possibleItems)
                                {
                                    transferItems.Add(Item.Key, Item.Value);
                                }
                            }
                            else
                            {
                                player.ChatMessage(string.Format(lang.GetMessage("MissingItem", this, player.UserIDString), itemAmount.itemDef.displayName.english));
                                break;
                            }
                        }
                        else
                        {
                            ForceUsableItem(itemCrafter, itemAmount.itemid, required);
                        }
                    }
                }
                if (check >= bp.ingredients.Count)
                {
                    foreach (var Item in transferItems)
                    {
                        if (Item.Value != 0)
                        {
                            Item.Key.SplitItem(Item.Value).MoveToContainer(player.inventory.containerMain);
                        }
                        else
                        {
                            Item.Key.MoveToContainer(player.inventory.containerMain);
                        }
                    }
                    player.ChatMessage(string.Format(lang.GetMessage("ItemsPulled", this, player.UserIDString)));
                    if (!allPlayerSettings[player.userID].autocraft)
                    {
                        return(false);
                    }
                }
                else if (allPlayerSettings[player.userID].fp)
                {
                    player.ChatMessage(string.Format(lang.GetMessage("ForcePulled", this, player.UserIDString)));
                    if (!allPlayerSettings[player.userID].autocraft)
                    {
                        return(false);
                    }
                }
            }
            return(null);
        }