diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index fcfae616..8cde850c 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -2,5 +2,6 @@ "akiVersion": "3.5.4", "projectName": "SPT-AKI", "compatibleTarkovVersion": "0.13.0.22173", - "serverName": "SPT Server" + "serverName": "SPT Server", + "profileSaveIntervalSeconds": 15 } diff --git a/project/src/callbacks/SaveCallbacks.ts b/project/src/callbacks/SaveCallbacks.ts index c4495116..b07d22c7 100644 --- a/project/src/callbacks/SaveCallbacks.ts +++ b/project/src/callbacks/SaveCallbacks.ts @@ -1,16 +1,23 @@ import { inject, injectable } from "tsyringe"; + import { OnLoad } from "../di/OnLoad"; import { OnUpdate } from "../di/OnUpdate"; - +import { ConfigTypes } from "../models/enums/ConfigTypes"; +import { ICoreConfig } from "../models/spt/config/ICoreConfig"; +import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; @injectable() export class SaveCallbacks implements OnLoad, OnUpdate { + protected coreConfig: ICoreConfig; + constructor( - @inject("SaveServer") protected saveServer: SaveServer + @inject("SaveServer") protected saveServer: SaveServer, + @inject("ConfigServer") protected configServer: ConfigServer ) { + this.coreConfig = this.configServer.getConfig(ConfigTypes.CORE); } public async onLoad(): Promise @@ -26,7 +33,7 @@ export class SaveCallbacks implements OnLoad, OnUpdate public async onUpdate(secondsSinceLastRun: number): Promise { // run every 15 seconds - if (secondsSinceLastRun > 15) + if (secondsSinceLastRun > this.coreConfig.profileSaveIntervalSeconds) { this.saveServer.save(); return true; diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 5b45aa8d..67a788ac 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -5,7 +5,8 @@ export interface ICoreConfig extends IBaseConfig kind: "aki-core" akiVersion: string projectName: string - compatibleTarkovVersion: string, - serverName: string; + compatibleTarkovVersion: string + serverName: string + profileSaveIntervalSeconds: number commit: string } \ No newline at end of file