1. Hi. I can't find the code to do this:

    Code:
    if (player.inventory.stacksize  (<-- something like that i want to do) > 50)
    {
    // code
    }
    
    If any stack of player inventory is bigger than 50, then do something.

    I tried searching with a decopiler on class PlayerInventory, but i think there is nothing that can help me.

    Calling @Wulf almighty ^^

    Thank you!!
     
    Last edited by a moderator: Dec 4, 2015
  2. Calytic

    Calytic Community Admin Community Mod

    You're going to have to loop through every item in the inventory and check the item.amount.
    Code:
    foreach (Item i in player.inventory.AllItems())
    {
        if (i.amount > 50)
        {
            // do something
        }
    }
    
     
  3. Thank you!

    I still have a problem.

    This is my code:
    Code:
    void Loaded()
            {
                timer.Repeat(10, 0, () =>
                {                foreach (Item i in player.inventory.AllItems())
                    {
                        if (i.amount > 40000)
                        {
                            SendReply(player, "asd");
                        }
                    }            });
            }
    
    But I get: The name `player' does not exist in the current context.

    I know that's because there must be "BasePlayer player" in some place, but i don't know where.

    Thank you!
     
  4. Calytic

    Calytic Community Admin Community Mod

    Code:
    foreach(BasePlayer player in BasePlayer.activePlayerList) {
       // do stuff
    }
    
     
  5. For some reason I always thoght is not possible foreach inside foreach.

    Thank you @Calytic !