Stack Size Controller

Allows you to set the max stack size of every item.

Total Downloads: 39,408 - First Release: Feb 10, 2017 - Last Update: Oct 27, 2017

5/5, 50 likes
  1. Nice work. Can you add another permission like stacksizecontroller.canuse to only allow the players who have the permission to use this function?
     
  2. Roughly thinking about it, I don't think this would work. When the plugin is loaded, the stacksize value is changed for all items in the config.
     
  3. I see.... Appreciate anyway.
     
  4. this plugin does not work. is there an update?
     
  5. It does work
     
  6. Hi is there a default file so I can save it a backup
     
  7. Also no working for me,just nothing happend i use .json from last page and nothing :/
     
  8. Any errors in your log?
    You can backup your original config, generate a new one for the default stack sizes, back that one up and then restore your original.
     
  9. Cannot get the controller to work, the stack sizes just stay vanilla sizes. Any help would be appreciated :)
     
  10. download config edit it then before uploading the new config unload plugin first upload config then reload plugin
     
  11. How can I contact you privately?
     
  12. You cant unless I pm you but just say what you need here if it needs pm or skype then can go down that road
     
    Last edited by a moderator: Jun 28, 2017
  13. @Canopy Sheep Here's a fix for moving over max stack, and splitting stack *in half* with the new modified hooks :)

    Code:
           object CanMoveItem(Item item, PlayerInventory inventory, uint container, int slot, uint amount)
            {
                bool aboveMaxStack = false;
                int configAmount = (int)Config[item.info.displayName.english];
                if (item.amount > configAmount)
                {
                    aboveMaxStack = true;
                }            if (item.amount < UInt16.MaxValue) //Moving normal amount of items
                {
                    return null;
                }
                if (amount + item.amount / UInt16.MaxValue == item.amount % UInt16.MaxValue) //Moving max stacks
                {
                    ItemContainer itemContainer = inventory.FindContainer(container);
                    if (itemContainer == null)
                    {
                        return true;
                    }
                    if (aboveMaxStack)
                    {
                        //Split Items (Config Amount)
                        Item item2 = item.SplitItem(configAmount);
                        if (!item2.MoveToContainer(itemContainer, slot, true))
                        {
                            item.amount += item2.amount;
                            item2.Remove(0f);
                        }
                        ItemManager.DoRemoves();
                        inventory.ServerUpdate(0f);
                        return true;
                    }                item.MoveToContainer(itemContainer, slot, true);
                    return true;
                }
                else if (amount + (item.amount / 2) / UInt16.MaxValue == (item.amount / 2) % UInt16.MaxValue + item.amount % 2) //Moving half stack
                {
                    ItemContainer itemContainer = inventory.FindContainer(container);
                    if (itemContainer == null)
                    {
                        return true;
                    }
                    if (aboveMaxStack)
                    {
                        //Split Items (Config Amount) (Copy paste from above)
                        Item split = item.SplitItem(configAmount);
                        if (!split.MoveToContainer(itemContainer, slot, true))
                        {
                            item.amount += split.amount;
                            split.Remove(0f);
                        }
                        ItemManager.DoRemoves();
                        inventory.ServerUpdate(0f);
                        return true;
                    }
                    //Split Items (Half of stack)
                    Item item2 = item.SplitItem(item.amount / 2);
                    if (!item2.MoveToContainer(itemContainer, slot, true))
                    {
                        item.amount += item2.amount;
                        item2.Remove(0f);
                    }
                    ItemManager.DoRemoves();
                    inventory.ServerUpdate(0f);
                    return true;
                }            return null;
            }
    It doesn't work for stupid high stack sizes when moving half amount, as the inventory interface doesn't show the correct half amount.

    Gyazo - 55d742f68a2b2252108b0a04c486b4e4.png

    Perhaps just split stacks in half if item.amount > 10,000,000 or so.

    It still needs a tiny bit of tweaking, as when splitting stacks in half it will round different each time.
     

    Attached Files:

    Last edited by a moderator: Jun 29, 2017
  14. Thanks for this, I was poking around with this a few days ago thinking about stack size dragging issues. You beat me to it! Just for record purposes, do I have your permission to take the code, test (possibly modify) and implement into the plugin with credit given? It'll be at least tomorrow if anyone's wondering, I don't think I can code and run Rust on a phone.
     
  15. Yea yea go ahead and use whatever you want. Credits are optional :p
     
  16. Good day,

    If I once the stack size has fixed and then restart the server this is reset
     
  17. upload plugin
    upload config
    reload plugin
    But some things are meant to be set to 1 (items that cant be stacked) and that cant be changed
     
  18. Since the last update of rust, when I reset my server the plugin stops working and I have to uninstall it and reinstall it to work correctly
     
  19. Canopy Sheep updated Stack Size Controller with a new update entry:

    1.9.5

     
  20. Edit: Double update, oops