On high gather rate servers, it's possible for players to generate a ton of scrap and then spam purchase items from vendors to flood the server with entities. Even with fast despawn rates, multiple players working together can often manage to overwhelm the server and crash it.
I added a check that cancels the purchase if the player's inventory is full and blocks the purchase if so (to keep the item from spilling out onto the ground). Modified code snippet is below
private object OnBuyVendingItem(VendingMachine machine, BasePlayer player, int sellOrderID, int amount)
{
if (machine == null || player == null) return null;
var slots = FreeSlots(player);
if (slots < 1) return false;
if (!permission.UserHasPermission(player.UserIDString, permUse)) return null;
machine.ClientRPC<int>(null, "CLIENT_StartVendingSounds", sellOrderID);
machine.DoTransaction(player, sellOrderID, amount);
return false;
}
private int FreeSlots(BasePlayer player)
{
var slots = player.inventory.containerMain.capacity + player.inventory.containerBelt.capacity;
var taken = player.inventory.containerMain.itemList.Count + player.inventory.containerBelt.itemList.Count;
return slots - taken;
}