diff --git a/project/src/helpers/TradeHelper.ts b/project/src/helpers/TradeHelper.ts index 59d9bd1c..358860e0 100644 --- a/project/src/helpers/TradeHelper.ts +++ b/project/src/helpers/TradeHelper.ts @@ -158,6 +158,14 @@ export class TradeHelper ); } + // Check if trader has enough stock + if (itemPurchased.upd.StackObjectsCount < buyCount) + { + throw new Error( + `Unable to purchase ${buyCount} items, this would exceed the remaining stock left ${itemPurchased.upd.StackObjectsCount} from the traders assort: ${buyRequestData.tid} this refresh`, + ); + } + // Decrement trader item count itemPurchased.upd.StackObjectsCount -= buyCount;