S13NDR_M4N

  • Member since May 3rd 2024
  • Last Activity:
Files
1
Posts
2
Reactions Received
17
Points
304
Profile Hits
240
  • hi, i've abondoned that mod for the moment as i cant get the trader assorts to work. i think the method has changed in 3.8.3 from earlier versions and i think it may change again in 3.9.0 so i'm going to wait and see

  • thanks very much for that. still not sure what i did wrong but all good now. going to see if i can add a mag for the 7.62 mdr now, wish me luck :)

    • that would be possible - but require significant code modifications


      Let me know if you figure it out-


      I would love to learn how to add different attachments to different guns

    • got the mag done for the 7.62 mdr but unforunately it doesnt line up with the slot properly. not sure how to fix it yet but i'll keep working on it. all i did to clone it was use the existing umpmod code and cahnged some ids and decsriptions

      private MDR762Drum()

      {

      this.printColor( "[specialmags] MDR762Drum enabled.", LogTextColor.CYAN );

      //Generate the new weapons

      //generate data


      const gunsnbulletsID = "gunsnbullets";

      const MDR556mmdrumID = "59c1383d86f774290a37e0ca";

      const newLocaleName = "762 60-round magazine";


      //const newName = this.itemDB[weapon]._name;

      const newName = newLocaleName;

      const price = 25000;

      const newID = `${ MDR556mmdrumID }MDRmod`;


      const leavesMDR: NewItemFromCloneDetails = {

      itemTplToClone: MDR556mmdrumID,

      overrideProperties: {

      Cartridges: [

      {

      _id: this.hashUtil.generate(),

      _max_count: 60,

      _name: "cartridges",

      _parent: newID,

      _props: {

      filters: [

      {

      Filter: [ "5e023e53d435e3302577c4c", "5a6086ea4f39f99cd479502f", "5a608bf24f39f98ffc77720e", "58dd3ad986f77403051cba8f", "5efb0c1bd79ff02a1f5e68d9", "5e023e6e34d52a55c3304f71", "5e023e88277cce2b522ff2b1" ],

      },

      ],

      },

      _proto: "5748538b2459770af276a261",

      },

      ],

      },

      newId: newID,

      parentId: "5448bc234bdc2d3c308b4569",

      handbookParentId: "5b5f754a86f774094242f19b",

      fleaPriceRoubles: price,

      handbookPriceRoubles: price,

      locales: {

      en: {

      name: newLocaleName,


      shortName: newName,

      description: "7.62Drum mag for the mdr",

      },

      },

      };


      this.customItemService.createItemFromClone( leavesMDR );


      if ( this.config.MDR762Drum )

      {

      this.printColor( "[specialmags] \MDR762Drum enabled for mdr.", LogTextColor.YELLOW );


      //Add the mag to the mdr

      this.itemDB[ "5dcbd56fdbd3d91b3e5468d5" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );




      const item = this.itemDB[ newID ];


      if ( this.config.MDR762DrumAddToTraders )

      {

      this.printColor( "[specialmags] \MDR762Drum added to traders.", LogTextColor.YELLOW );


      // Create barter scheme object

      const barterSchemeToAdd: IBarterScheme = {

      count: this.handbookHelper.getTemplatePrice( newID ),

      _tpl: Money.ROUBLES,

      };


      // Create item object

      const itemToAdd: Item = {

      _id: item._id,

      _tpl: item._id,

      parentId: "hideout",

      slotId: "hideout",

      upd: {

      StackObjectsCount: 9999999,

      UnlimitedCount: true,

      },

      };



      const guassort = this.db.getTables().traders[ "gunsnbullets" ].assort;


      // add item to assort



      guassort.items.push( itemToAdd );

      guassort.barter_scheme[ item._id ] = [ [ barterSchemeToAdd ] ];

      guassort.loyal_level_items[ item._id ] = 3;

      }

      }


      judt got to work out how the barters should be set up

    • and also i had to update the config of course

    • can you show me what you did to update the JSON file- I still cant get mine to sync?


      Also - the 50 Round AK drum or FAL drum might be better models since theyre already 762

    • this is the entire mod.ts file as i use it



      import type { DependencyContainer } from "tsyringe";

      import type { ILogger } from "@spt-aki/models/spt/utils/ILogger";

      import type { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";

      import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";

      import type { DatabaseServer } from "@spt-aki/servers/DatabaseServer";


      import type { VFS } from "@spt-aki/utils/VFS";

      import { jsonc } from "jsonc";

      import * as path from "node:path";

      import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor";

      import type { Item } from "@spt-aki/models/eft/common/tables/IItem";


      //item creation

      import type { CustomItemService } from "@spt-aki/services/mod/CustomItemService";

      import type { NewItemFromCloneDetails } from "@spt-aki/models/spt/mod/NewItemDetails";

      import type { HashUtil } from "@spt-aki/utils/HashUtil";

      import type { JsonUtil } from "@spt-aki/utils/JsonUtil";

      import type { IBarterScheme } from "@spt-aki/models/eft/common/tables/ITrader";

      import type { HandbookHelper } from "@spt-aki/helpers/HandbookHelper";

      import { Money } from "@spt-aki/models/enums/Money";

      import type { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables";

      import type { ConfigServer } from "@spt-aki/servers/ConfigServer";

      import type { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig";

      import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";

      import type { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig";


      class specialmags implements IPostDBLoadMod, IPreAkiLoadMod

      {

      private logger: ILogger;

      private db: DatabaseServer;

      private itemDB: any;


      //Config

      private config: IConfig;

      private vfs: VFS;


      private hashUtil: HashUtil;

      private jsonUtil: JsonUtil;

      private handbookHelper: HandbookHelper;

      private customItemService: CustomItemService;

      private configServer: ConfigServer;

      private botConfig: IBotConfig;

      private traderConfig: ITraderConfig;


      public preAkiLoad( container: DependencyContainer :( void

      {

      this.vfs = container.resolve<VFS>( "VFS" );

      const configFile = path.resolve( __dirname, "../config/config.jsonc" );

      this.logger = container.resolve<ILogger>( "WinstonLogger" );

      this.configServer = container.resolve<ConfigServer>( "ConfigServer" );

      this.config = jsonc.parse( this.vfs.readFile( configFile ) );


      this.traderConfig = this.configServer.getConfig<ITraderConfig>( ConfigTypes.TRADER );


      this.printColor( "[specialmags] preAki Starting" );


      if ( this.config.enableFenceBlacklist )

      {

      this.fenceBlacklist();

      }

      }


      public postDBLoad( container: DependencyContainer :( void

      {

      // Get stuff from container

      this.db = container.resolve<DatabaseServer>( "DatabaseServer" );


      this.hashUtil = container.resolve<HashUtil>( "HashUtil" );

      this.jsonUtil = container.resolve<JsonUtil>( "JsonUtil" );

      this.handbookHelper = container.resolve<HandbookHelper>( "HandbookHelper" );

      this.customItemService = container.resolve<CustomItemService>( "CustomItemService" );

      this.botConfig = this.configServer.getConfig<IBotConfig>( ConfigTypes.BOT );


      // Get tables from database

      const tables = this.db.getTables();

      // Get item database from tables

      this.itemDB = tables.templates.items;


      this.printColor( "[specialmags] PostDB Starting" );


      const mods = [ "MDR762Drum", "UMPDrum" ];



      if ( this.config.UMPDrum )

      {

      this.UMPDrum();

      }

      if ( this.config.MDR762Drum )

      {

      this.MDR762Drum();

      }


      //point output




      private UMPDrum()

      {

      this.printColor( "[specialmags] UMPDrum enabled.", LogTextColor.CYAN );

      //Generate the new weapons

      //generate data


      const gunsnbulletsID = "gunsnbullets";

      const ninemmdrumID = "5a718f958dc32e00094b97e7";

      const newLocaleName = ".45 ACP 50-round magazine";


      //const newName = this.itemDB[weapon]._name;

      const newName = newLocaleName;

      const price = 25000;

      const newID = `${ ninemmdrumID }45mod`;


      const leaves45: NewItemFromCloneDetails = {

      itemTplToClone: ninemmdrumID,

      overrideProperties: {

      Cartridges: [

      {

      _id: this.hashUtil.generate(),

      _max_count: 50,

      _name: "cartridges",

      _parent: newID,

      _props: {

      filters: [

      {

      Filter: [ "5e81f423763d9f754677bf2e", "5efb0cabfb3e451d70735af5", "5efb0fc6aeb21837e749c801", "5efb0d4f4bc50b58e81710f3", "5ea2a8e200685063ec28c05a" ],

      },

      ],

      },

      _proto: "5748538b2459770af276a261",

      },

      ],

      },

      newId: newID,

      parentId: "5448bc234bdc2d3c308b4569",

      handbookParentId: "5b5f754a86f774094242f19b",

      fleaPriceRoubles: price,

      handbookPriceRoubles: price,

      locales: {

      en: {

      name: newLocaleName,


      shortName: newName,

      description: "Drum mag for the vector/ump 45",

      },

      },

      };


      this.customItemService.createItemFromClone( leaves45 );


      //Add the mag to the ump

      this.itemDB[ "5fc3e272f8b6a877a729eac5" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );


      if ( this.config.UMPDrumVector )

      {

      this.printColor( "[specialmags] \tUMPDrum enabled for vector.", LogTextColor.YELLOW );


      //Add the mag to the vector

      this.itemDB[ "5fb64bc92b1b027b1f50bcf2" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );

      }


      const item = this.itemDB[ newID ];


      if ( this.config.UMPDrumAddToTraders )

      {

      this.printColor( "[specialmags] \tUMPDrum added to traders.", LogTextColor.YELLOW );


      // Create barter scheme object

      const barterSchemeToAdd: IBarterScheme = {

      count: this.handbookHelper.getTemplatePrice( newID ),

      _tpl: Money.ROUBLES,

      };


      // Create item object

      const itemToAdd: Item = {

      _id: item._id,

      _tpl: item._id,

      parentId: "hideout",

      slotId: "hideout",

      upd: {

      StackObjectsCount: 9999999,

      UnlimitedCount: true,

      },

      };



      const guassort = this.db.getTables().traders[ "gunsnbullets" ].assort;


      // add item to assort



      guassort.items.push( itemToAdd );

      guassort.barter_scheme[ item._id ] = [ [ barterSchemeToAdd ] ];

      guassort.loyal_level_items[ item._id ] = 3;

      }

      }

      private MDR762Drum()

      {

      this.printColor( "[specialmags] MDR762Drum enabled.", LogTextColor.CYAN );

      //Generate the new weapons

      //generate data


      const gunsnbulletsID = "gunsnbullets";

      const MDR556mmdrumID = "59c1383d86f774290a37e0ca";

      const newLocaleName = "762 60-round magazine";


      //const newName = this.itemDB[weapon]._name;

      const newName = newLocaleName;

      const price = 25000;

      const newID = `${ MDR556mmdrumID }MDRmod`;


      const leavesMDR: NewItemFromCloneDetails = {

      itemTplToClone: MDR556mmdrumID,

      overrideProperties: {

      Cartridges: [

      {

      _id: this.hashUtil.generate(),

      _max_count: 60,

      _name: "cartridges",

      _parent: newID,

      _props: {

      filters: [

      {

      Filter: [ "5e023e53d435e3302577c4c", "5a6086ea4f39f99cd479502f", "5a608bf24f39f98ffc77720e", "58dd3ad986f77403051cba8f", "5efb0c1bd79ff02a1f5e68d9", "5e023e6e34d52a55c3304f71", "5e023e88277cce2b522ff2b1" ],

      },

      ],

      },

      _proto: "5748538b2459770af276a261",

      },

      ],

      },

      newId: newID,

      parentId: "5448bc234bdc2d3c308b4569",

      handbookParentId: "5b5f754a86f774094242f19b",

      fleaPriceRoubles: price,

      handbookPriceRoubles: price,

      locales: {

      en: {

      name: newLocaleName,


      shortName: newName,

      description: "7.62Drum mag for the mdr",

      },

      },

      };


      this.customItemService.createItemFromClone( leavesMDR );


      if ( this.config.MDR762Drum )

      {

      this.printColor( "[specialmags] \MDR762Drum enabled for mdr.", LogTextColor.YELLOW );


      //Add the mag to the mdr

      this.itemDB[ "5dcbd56fdbd3d91b3e5468d5" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );




      const item = this.itemDB[ newID ];


      if ( this.config.MDR762DrumAddToTraders )

      {

      this.printColor( "[specialmags] \MDR762Drum added to traders.", LogTextColor.YELLOW );


      // Create barter scheme object

      const barterSchemeToAdd: IBarterScheme = {

      count: this.handbookHelper.getTemplatePrice( newID ),

      _tpl: Money.ROUBLES,

      };


      // Create item object

      const itemToAdd: Item = {

      _id: item._id,

      _tpl: item._id,

      parentId: "hideout",

      slotId: "hideout",

      upd: {

      StackObjectsCount: 9999999,

      UnlimitedCount: true,

      },

      };



      const guassort = this.db.getTables().traders[ "gunsnbullets" ].assort;


      // add item to assort



      guassort.items.push( itemToAdd );

      guassort.barter_scheme[ item._id ] = [ [ barterSchemeToAdd ] ];

      guassort.loyal_level_items[ item._id ] = 3;

      }

      }




      private printColor( message: string, color: LogTextColor = LogTextColor.GREEN )

      {

      this.logger.logWithColor( message, color );

      }


      private debugJsonOutput( jsonObject: any, label = "" )

      {

      //if ( this.config.debug )

      //{

      if ( label.length > 0 )

      {

      this.logger.logWithColor( `[${ label }]`, LogTextColor.GREEN );

      }

      this.logger.logWithColor( JSON.stringify( jsonObject, null, 4 ), LogTextColor.MAGENTA );

      //}

      }

      private writeResult( prefix: string, data: any, extension = ".json" :( void

      {

      // get formatted text to save

      const text = this.jsonUtil.serialize( data, true );


      // get file name

      const fileName = `E:/SPT-AKI/SPT-3.8.0-2024-03-29-50f50808/user/mods/leaves-specialmags/${ prefix }${ extension }`;


      // save file

      this.vfs.writeFile( fileName, text );

      this.logger.info( `Written results to: ${ fileName }` );

      }

      }


      module.exports = { mod: new specialmags() };

  • hi, i'm trying to do the same as you and add the drum mag to vector but i seem to be doing something wrong as it doesnt show up in trader. would you mind sharing your mod.ts file so i can work out ehat i'm doig wrong?

    thanks

    • So in order to simply replace the model- CTRL+F and search for "59c1383d86f774290a37e0ca"


      This is the 60 rnd M4 drum mag model in the mod


      You can replace that with whichever mag you would prefer to use, I used the 9mm vector drum which is "5a718f958dc32e00094b97e7"


      In the provided config JSON you can enable the mag for both guns


      I could not get the ts file to work as written to support 2 different in game models for the different guns


      I also have no experience with Js so I do not know how to correct the code to do that new functionality


      Hope this helps

    • private UMPDrum()
      {
      this.printColor( "[TreasureBox] UMPDrum enabled.", LogTextColor.CYAN );
      //Generate the new weapons
      //generate data
      const peacekeeperID = "5935c25fb3acc3127c3d8cd9";
      const mechanicID = "5a7c2eca46aef81a7ca2145d";
      const ninemmdrumID = "5a718f958dc32e00094b97e7";
      const newLocaleName = "Universal .45 ACP 50-round magazine with Glock compatible tower";

      //const newName = this.itemDB[weapon]._name;
      const newName = newLocaleName;
      const price = 25000;
      const newID = `${ ninemmdrumID }45mod`;

      const leaves45: NewItemFromCloneDetails = {
      itemTplToClone: ninemmdrumID,
      overrideProperties: {
      Cartridges: [
      {
      _id: this.hashUtil.generate(),
      _max_count: 50,
      _name: "cartridges",
      _parent: newID,
      _props: {
      filters: [
      {
      Filter: [ "5e81f423763d9f754677bf2e", "5efb0cabfb3e451d70735af5", "5efb0fc6aeb21837e749c801", "5efb0d4f4bc50b58e81710f3", "5ea2a8e200685063ec28c05a" ],
      },
      ],
      },
      _proto: "5748538b2459770af276a261",
      },
      ],
      },
      newId: newID,
      parentId: "5448bc234bdc2d3c308b4569",
      handbookParentId: "5b5f754a86f774094242f19b",
      fleaPriceRoubles: price,
      handbookPriceRoubles: price,
      locales: {
      en: {
      name: newLocaleName,

      shortName: newName,
      description: "Drum mag for the UMP45 HELL YISS BRUTHA.",
      },
      },
      };

      this.customItemService.createItemFromClone( leaves45 );

      //Add the mag to the ump
      this.itemDB[ "5fc3e272f8b6a877a729eac5" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );

      if ( this.config.UMPDrumVector )
      {
      this.printColor( "[TreasureBox] \tUMPDrum enabled for vector.", LogTextColor.YELLOW );

      //Add the mag to the vector
      this.itemDB[ "5fb64bc92b1b027b1f50bcf2" ]._props.Slots[ 0 ]._props.filters[ 0 ].Filter.push( newID );
      }

      const item = this.itemDB[ newID ];

      if ( this.config.UMPDrumAddToTraders )
      {
      this.printColor( "[TreasureBox] \tUMPDrum added to traders.", LogTextColor.YELLOW );

      // Create barter scheme object
      const barterSchemeToAdd: IBarterScheme = {
      count: this.handbookHelper.getTemplatePrice( newID ),
      _tpl: Money.ROUBLES,
      };

      // Create item object
      const itemToAdd: Item = {
      _id: item._id,
      _tpl: item._id,
      parentId: "hideout",
      slotId: "hideout",
      upd: {
      StackObjectsCount: 9999999,
      UnlimitedCount: true,
      },
      };

      const pkassort = this.db.getTables().traders[ peacekeeperID ].assort;
      const meassort = this.db.getTables().traders[ mechanicID ].assort;

      // add item to assort
      pkassort.items.push( itemToAdd );
      pkassort.barter_scheme[ item._id ] = [ [ barterSchemeToAdd ] ];
      pkassort.loyal_level_items[ item._id ] = 3;

      meassort.items.push( itemToAdd );
      meassort.barter_scheme[ item._id ] = [ [ barterSchemeToAdd ] ];
      meassort.loyal_level_items[ item._id ] = 3;
      }
      }