1. How to check inventory full?
    İf inventory full player not Take kit or raise items
     
    Last edited by a moderator: Jul 23, 2016
  2. player.inventory.AllItems().Length
     
  3. How to check player inventory full?
    An example of when he filled out the inventory he will not be able to take KIT.
     
  4. Well there are 36 slots in a players inventory so...
    if (player.inventory.AllItems().Length == 36)
    You would also need to take into account seperate containers though, a user may not have a full "wear" container and if the kit item is not wearable you will loose it. So you would need to get the amount of items in the kit and check if the players inventory has enough slots in the right containers to take all the items
     
  5. I already know that.But do not know where to write him that is void ... ?

    Code:
    void CanAcceptItem(ItemContainer container, Item item)
    {
    Puts("CanAcceptItem works!");
    }
    CanAcceptİtem how to use in Baseplayer ?
     

  6. What are you trying to do?
     
  7. Code:
    void CanAcceptItem(ItemContainer container, Item item)
            {
                var player = container.GetOwnerPlayer();
            }
    But that isn't going to stop players from getting a kit when their inventory is full, the kit will still be processed whether the player receive's the items or not. You need to write your own function in kits to check the players inventory and not give the kit if the requirements aren't met, or if your giving the kit from another plugin you need to get the kit items from Kits and write the same function in your own plugin
     
  8. Actually, for kits I think he can use the API.

    Code:
    object canRedeemKit(BasePlayer player)
            {
                if(player.inventory.AllItems().Length == 36) return "Something.";
                else return null;
            }
     
  9. Yes, but like I mentioned above, that is only very basically covering it. If the user has no 'wear' items on his total items will be 30, if the kit doesn't have 'wear' items it will still be allowed yet the player will lose all its contents. If you want proper coverage you need to do a lot more than that
     
  10. Thanks.
     
  11. This is actually not a very good way to check if an inventory is full, in my opinion the GiveItem method should be used using its full potential. With that check it a player will fail to redeem something like an ammo or resources kit when all inventory slots are full but only has like 10 of all ammo/resources in his inventory which would technically allow the items to be added to those stacks.

    The GiveItem (on PlayerLoot) method actually returns a bool (true when the item was given and false when it failed), it would actually be better if that return value is actually used in the plugin and when it fails to give an item, all items already given from the same kit at that time which succeeded should be taken away again and a message could then be displayed to the user stating that there is not enough room to redeem the kit.

    Code:
        public bool GiveItem(Item item, ItemContainer container = null)
        {
            if (item == null)
            {
                return false;
            }
            int num = -1;
            this.GetIdealPickupContainer(item, ref container, ref num);
            if (container != null && item.MoveToContainer(container, num, true))
            {
                return true;
            }
            if (item.MoveToContainer(this.containerMain, -1, true))
            {
                return true;
            }
            if (item.MoveToContainer(this.containerBelt, -1, true))
            {
                return true;
            }
            return false;
        }