Make sure trader has enough stock before selling (!278)
Make sure trader has enough stock before selling Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/278 Co-authored-by: Leaves <mwarciel@gmail.com> Co-committed-by: Leaves <mwarciel@gmail.com>
This commit is contained in:
parent
35e48add20
commit
3be1768672
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user