Advertisement
EmperorRubidium

clothing import

Aug 17th, 2022
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { DependencyContainer } from "tsyringe";
  2.  
  3. import { IMod } from "@spt-aki/models/external/mod";
  4. import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
  5. import { InitialModLoader } from "@spt-aki/loaders/InitialModLoader";
  6. import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
  7. import { DatabaseImporter } from "@spt-aki/utils/DatabaseImporter";
  8.  
  9. class GF2_Character implements IMod
  10. {
  11.     public preAkiLoad(container: DependencyContainer): void
  12.     {
  13.         return
  14.     }
  15.  
  16.     public postAkiLoad(container: DependencyContainer): void
  17.     {
  18.         //Logger
  19.         const logger = container.resolve<ILogger>("WinstonLogger");
  20.        
  21.         logger.info("Loading: kmyuhkyuk-GF2_Character");
  22.  
  23.         //Server database
  24.         const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
  25.  
  26.         const tables = databaseServer.getTables();
  27.  
  28.         const databaseImporter = container.resolve<DatabaseImporter>("DatabaseImporter");
  29.  
  30.         //New database
  31.         const initialModLoader = container.resolve<PostDBModLoader>("PostDBModLoader");
  32.  
  33.         const db = databaseImporter.loadRecursive(`${initialModLoader.getModPath("kmyuhkyuk-GF2_Character")}db/`);
  34.  
  35.         //Add customization
  36.         for (const skin in db.templates.customization) {
  37.             tables.templates.customization[skin] = db.templates.customization[skin];
  38.         }
  39.  
  40.         //Add character
  41.         for (const ca in db.templates.character) {
  42.             tables.templates.character.push(db.templates.character[ca]);
  43.         }
  44.  
  45.         for (const su in db.templates.profiles) {
  46.             tables.templates.profiles[su] = db.templates.profiles[su];
  47.         }
  48.  
  49.         //Add locales to game
  50.         for (const lang in db.locales)
  51.             for (const item in db.locales[lang].templates)
  52.                 tables.locales.global[lang].templates[item] = db.locales[lang].templates[item];
  53.  
  54.         //Add trader
  55.         for (const trader in db.traders) {
  56.             //Add suits
  57.             for (const st in db.traders[trader].suits)
  58.                 tables.traders[trader].suits.push(db.traders[trader].suits[st]);
  59.         }  
  60.     }
  61. }
  62.  
  63. module.exports = { mod: new GF2_Character() }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement