diff --git a/project/src/controllers/InventoryController.ts b/project/src/controllers/InventoryController.ts index 018abd19..c4129809 100644 --- a/project/src/controllers/InventoryController.ts +++ b/project/src/controllers/InventoryController.ts @@ -401,13 +401,20 @@ export class InventoryController sessionID: string, ): IItemEventRouterResponse { - const itemOne = pmcData.Inventory.items.find((x) => x._id === request.item); + // During post-raid scav transfer, the swap may be in the scav inventory + let playerData = pmcData; + if (request.fromOwner?.type === "Profile" && request.fromOwner.id !== playerData._id) + { + playerData = this.profileHelper.getScavProfile(sessionID); + } + + const itemOne = playerData.Inventory.items.find((x) => x._id === request.item); if (!itemOne) { this.logger.error(`Unable to find item: ${request.item} to swap positions with: ${request.item2}`); } - const itemTwo = pmcData.Inventory.items.find((x) => x._id === request.item2); + const itemTwo = playerData.Inventory.items.find((x) => x._id === request.item2); if (!itemTwo) { this.logger.error(`Unable to find item: ${request.item2} to swap positions with: ${request.item}`); @@ -457,7 +464,7 @@ export class InventoryController let playerData = pmcData; // We may be folding data on scav profile, get that profile instead - if (request.fromOwner && request.fromOwner.type === "Profile" && request.fromOwner.id !== playerData._id) + if (request.fromOwner?.type === "Profile" && request.fromOwner.id !== playerData._id) { playerData = this.profileHelper.getScavProfile(sessionID); } @@ -495,7 +502,7 @@ export class InventoryController let playerData = pmcData; // Fix for toggling items while on they're in the Scav inventory - if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id) + if (body.fromOwner?.type === "Profile" && body.fromOwner.id !== playerData._id) { playerData = this.profileHelper.getScavProfile(sessionID); }