Maybe I'm doing something wrong, but I'm not able to get the location to work. Am I missing something?
import { DependencyContainer, Lifecycle, injectable } from "tsyringe";
import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import type { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import type { StaticRouterModService } from "@spt-aki/services/mod/staticRouter/StaticRouterModService";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
/*
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
const loader = container.resolve<PreAkiModLoader>("PreAkiModLoader");
const apiPath = loader.getModPath("API");
const api = require(apiPath);
*/
export class QuestZoneApi implements IPreAkiLoadMod, IPostDBLoadMod {
router: StaticRouterModService;
dbServer: DatabaseServer;
private modConfig = require("../config/config.json");
public preAkiLoad(container: DependencyContainer): void {
const logger = container.resolve<ILogger>("WinstonLogger");
this.router = container.resolve<StaticRouterModService>(
"StaticRouterModService"
);
this._registerStaticRoutes();
}
public postDBLoad(container: DependencyContainer): void {
this.dbServer = container.resolve<DatabaseServer>("DatabaseServer");
const tables = this.dbServer.getTables();
tables.globals["QuestZones"] = [];
}
private _registerStaticRoutes(): void {
// Get Zones Route
this.router.registerStaticRouter(
"GetZones",
[
{
url: "/quests/zones/getZones",
action: (url, info, sessionId, output) => {
const json = JSON.stringify(
this.dbServer.getTables().globals["QuestZones"]
);
if (this.modConfig.debugMode) console.log(json);
return json;
},
},
],
""
);
if (this.modConfig.debugMode) {
this.router.registerStaticRouter(
"AddDormSupply",
[
{
url: "/quests/zones/addDormSupply",
action: (url, info, sessionId, output)=> {
this.dbServer
.getTables()
.globals["QuestsZones"].push({
zoneId:"dormSupply",
zoneName: "Dorm Supply",
zoneType: "VisitPlace",
zoneLocation: "bigmap",
position:{
xPos: "174.2927",
yPos: "2.8297",
zPos: "173.2282",
},
rotation: {
x: "0",
y: "0",
z: "0",
},
scale: {
x: "2.3",
y: "0.9",
z: "2.7",
},
});
return null;
},
},
],
);
}
}
}
module.exports = { mod: new QuestZoneApi() };
Display More