var aLimit = 0;
var aCount = 0;

if (pinv.getSlotContainingItem(290) != -1 || pinv.getSlotContainingItem(291) || pinv.getSlotContainingItem(292) != -1)
{
	aLimit = 20;
	if (pinv.getSlotContainingItem(291) != -1)
	{
		aLimit = 40;
		if (pinv.getSlotContainingItem(292) != -1)
		{
			aLimit = 80;
		}
	}

	if (pinv.getSlotContainingItem(262) != -1) {
		for(i=0;i<=35;i++)
		{
			if(pinv.getItemInSlot(i) != null)
			{
				var curItem = pinv.getItemInSlot(i);
				if (curItem.getItemID() == 262) {
					aCount += curItem.getQuantity();
				}
			}
		}
	}
}
if(aCount > aLimit) {
	player.dropItem(Item(262, (aCount - aLimit)));
	pinv.consumeItemAmount(262, 0, (aCount - aLimit));
}