diff --git a/project/assets/configs/trader.json b/project/assets/configs/trader.json index 575b8c82..44883d09 100644 --- a/project/assets/configs/trader.json +++ b/project/assets/configs/trader.json @@ -367,7 +367,10 @@ ], "coopExtractGift": { "sendGift": true, - "messageLocaleIds": ["5da89b1886f77439d7741002 0", "5da89b3a86f7742f9026cb83 0"], + "messageLocaleIds": [ + "5da89b1886f77439d7741002 0", + "5da89b3a86f7742f9026cb83 0" + ], "giftExpiryHours": 168, "weaponPresetCount": { "min": 0, @@ -444,5 +447,8 @@ "allowBossItems": false }, "btrDeliveryExpireHours": 240 + }, + "moddedTraders": { + "clothingService": [] } -} +} \ No newline at end of file diff --git a/project/src/callbacks/TraderCallbacks.ts b/project/src/callbacks/TraderCallbacks.ts index 9518070c..d058619c 100644 --- a/project/src/callbacks/TraderCallbacks.ts +++ b/project/src/callbacks/TraderCallbacks.ts @@ -4,6 +4,9 @@ import { OnUpdate } from "@spt/di/OnUpdate"; import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData"; import { ITraderAssort, ITraderBase } from "@spt/models/eft/common/tables/ITrader"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; +import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; +import { ITraderConfig, ModdedTraders } from "@spt/models/spt/config/ITraderConfig"; +import { ConfigServer } from "@spt/servers/ConfigServer"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; import { inject, injectable } from "tsyringe"; @@ -12,6 +15,7 @@ export class TraderCallbacks implements OnLoad, OnUpdate { constructor( @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, // TODO: delay required @inject("TraderController") protected traderController: TraderController, + @inject("ConfigServer") protected configServer: ConfigServer, ) {} public async onLoad(): Promise { @@ -46,4 +50,14 @@ export class TraderCallbacks implements OnLoad, OnUpdate { const traderID = url.replace("/client/trading/api/getTraderAssort/", ""); return this.httpResponse.getBody(this.traderController.getAssort(sessionID, traderID)); } + + /** Handle /singleplayer/moddedTraders */ + public getModdedTraderData( + url: string, + info: IEmptyRequestData, + sessionID: string, + ): IGetBodyResponseData { + const traderConfig = this.configServer.getConfig(ConfigTypes.TRADER) as ITraderConfig; + return this.httpResponse.noBody(traderConfig.moddedTraders); + } } diff --git a/project/src/models/spt/config/ITraderConfig.ts b/project/src/models/spt/config/ITraderConfig.ts index 02de25e5..88516d8a 100644 --- a/project/src/models/spt/config/ITraderConfig.ts +++ b/project/src/models/spt/config/ITraderConfig.ts @@ -11,6 +11,7 @@ export interface ITraderConfig extends IBaseConfig { updateTimeDefault: number; traderPriceMultipler: number; fence: FenceConfig; + moddedTraders: ModdedTraders; } export interface UpdateTime { @@ -69,3 +70,9 @@ export interface DiscountOptions { weaponPresetMinMax: MinMax; equipmentPresetMinMax: MinMax; } + +/** Custom trader data needed client side for things such as the clothing service */ +export interface ModdedTraders { + /** Trader Ids to enable the clothing service for */ + clothingService: string[]; +} diff --git a/project/src/routers/static/TraderStaticRouter.ts b/project/src/routers/static/TraderStaticRouter.ts index 58e985ab..2b38ab7f 100644 --- a/project/src/routers/static/TraderStaticRouter.ts +++ b/project/src/routers/static/TraderStaticRouter.ts @@ -2,6 +2,7 @@ import { TraderCallbacks } from "@spt/callbacks/TraderCallbacks"; import { RouteAction, StaticRouter } from "@spt/di/Router"; import { ITraderBase } from "@spt/models/eft/common/tables/ITrader"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; +import { ModdedTraders } from "@spt/models/spt/config/ITraderConfig"; import { inject, injectable } from "tsyringe"; @injectable() @@ -19,6 +20,17 @@ export class TraderStaticRouter extends StaticRouter { return this.traderCallbacks.getTraderSettings(url, info, sessionID); }, ), + new RouteAction( + "/singleplayer/moddedTraders", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { + return this.traderCallbacks.getModdedTraderData(url, info, sessionID); + }, + ), ]); } }