diff --git a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs index 71cc491f..5469f2a0 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs @@ -69,7 +69,12 @@ public class PaymentService( else { // If the item is money, add its count to the currencyAmounts object. - currencyAmounts.TryAdd(item.Template, currencyAmounts.GetValueOrDefault(item.Template, 0) + itemRequest.Count); + // sometimes the currency can be in two parts, so it fails to tryadd the second part + if (!currencyAmounts.TryAdd(item.Template, currencyAmounts.GetValueOrDefault(item.Template, 0) + itemRequest.Count)) + { + // if it fails, add the amount to the existing amount + currencyAmounts[item.Template] += itemRequest.Count; + } } } else @@ -77,7 +82,12 @@ public class PaymentService( // Used by `SptInsure` // Handle differently, `id` is the money type tpl var currencyTpl = itemRequest.Id; - currencyAmounts.TryAdd(currencyTpl, currencyAmounts.GetValueOrDefault(currencyTpl, 0) + itemRequest.Count); + // sometimes the currency can be in two parts, so it fails to tryadd the second part + if (!currencyAmounts.TryAdd(currencyTpl, currencyAmounts.GetValueOrDefault(currencyTpl, 0) + itemRequest.Count)) + { + // if it fails, add the amount to the existing amount + currencyAmounts[currencyTpl] += itemRequest.Count; + } } }