[How-To] Weapon Modifying

Customizing Weapon Settings

Following this tutorial, you can change the reload speed, firing rate, and magazine size for the weapon_rifle_springfield. Magazine size: 50, Reload speed: 0.5x (twice as slow), and firing rate: 3.5 (3.5 times faster).

First, create fxmanifest.lua with the following content:

fx_version "cerulean"
game "rdr3"

rdr3_warning "I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships."

file 'weaponinfo_test.meta'
data_file 'WEAPONINFO_FILE_PATCH' 'weaponinfo_test.meta'

file 'weaponcomponent_test.meta'
data_file 'WEAPONCOMPONENTSINFO_FILE' 'weaponcomponent_test.meta'

Also, create two files:

weaponinfo_test.meta:


<?xml version="1.0" encoding="UTF-8"?>
<sss> 
<CWeaponInfo>
    <!-- Set value here -->
    <Name>weapon_rifle_springfield</Name>

    <!-- Weapon Magazine Size-->
     <ClipInfos itemType="dyasubaa_0xde99e9ed">
      <Item>
       <Type>Magazine</Type>
       <Size value="50" /> <!-- Set value here -->
       <BulletsPerAnimLoop value="1" />
      </Item>
     </ClipInfos>
     
     <!-- Weapon Reload -->
     <WeaponReload type="CWeaponReload">
      <ReloadTime value="-1" />
      <VehicleReloadTime value="-1" />
      <AnimReloadRate value="0.5" />  <!-- Set value here. Default: 1.0  -->
      <SectionedReloadInfo />
      <SectionedReloadInfoDual />
     </WeaponReload>

    <!-- Bullet speed flying. Matrix effect can be achieved with lower values :D -->
    <Speed value="2000" />

    <!-- Weaopon flags. It was manually configured by attempting and trying  to achieve desired result. Checkout list of flags below.-->
    <WeaponFlags>TwoHanded, AllowEarlyExitFromFireAnimAfterBulletFired, CanHipFire, CarriedInHand, Gun, AnimReload, CanFreeAim</WeaponFlags>

    <!-- <WeaponFlags>Gun CanFreeAim AnimReload UsableOnFoot 0x72B9E864 Vehicle ForceEjectShellAfterFiring 0x75138DBF 0x82564383 Turret</WeaponFlags>
    <WeaponFlags>CarriedInHand, Gun, CanLockonOnFoot, CanLockonInVehicle, CanFreeAim, TwoHanded, AnimReload, UsableInCover, UsableInVehicle, UseSectionedReload, UsableOnFoot, CanPerformArrest, DontBlendFireOutro, NoWheelStats, ktvicrua_0x0497cfae, pfhtvbfa_0x72b9e864, mbpfauja_0x0f00e598, OnlyFireOneShot, CanBeFiredLikeGun, OnlyAllowFiring, Vehicle, NonViolent, AllowCloseQuarterKills, AllowMeleeIntroAnim, ManualDetonation, SuppressGunshotEvent, AllowDriverLockOnToAmbientPeds, NoAutoRunWhenFiring, UseLeftHandIkWhenAiming, ForcesActionMode, CreatesAPotentialExplosionEventWhenFired, DisableStealth, IgnoreHelmets, TorsoIKForWeaponBlock, Unarmed, nqpnchea_0x82564383, qplkduda_0xdb7546e0, izwultja_0x087a39d7, smywzqua_0xb7db72ac, ffjiviaa_0x07f0cbca, zzqbnmcc_0xbdbbc7fe, ApplyVehicleDamageToEngine, BlockAmbientIdles, DisableFPSAimForScope, AttachFPSLeftHandIKToRight, AllowMeleeBlock, SwapToUnarmedWhenOutOfThrownAmmo, PlayOutOfAmmoAnim, DamageCausesDisputes, SkipVehiclePetrolTankDamage, gisenogc_0x1fce1778, DisableCrouch, ExclusivelyHolstered, bqlkqoha_0x895400e1, CanBeOffhandCarried, jlkqscbb_0xb241c6ea, wpircgea_0x70a9b652, xjfjmwea_0x352d6203, dvrdqnda_0xe7833781, fxopleia_0xd250dfdb, DropWhenLassoed, qfgglhja_0x3a829c54, xeqcqcaa_0x2610198c, rwutmjda_0x4411da0c, CannotInstantHolster, goaxxmja_0x282cf096, wthsbaua_0x60efb98c, allphuga_0x27895875, jbuvmeua_0x5fff57f6, ymigrtqb_0xb5506e4e, cnradqeb_0xd399b030, AllowILO, MeleeSmashable, ujdyudib_0xc6ee6dee, bcoctrsb_0x42bce923, xuepsdaa_0x255dcb79, ogtjhfca_0xaf408974, Shotgun, jfgpampa_0x5cac88b8, hdlluqra_0xc2b9b746, uxzzirka_0x8bc0aa13, Torch, MeleeThrown, ueicfoqa_0xe64f69a1, CanTwirl, siqrqfna_0x140ac63f, lpqxseaa_0xa93afc4b, MetalDetector, arsrskja_0x9aa4f395, lpespypa_0x4a515b55, dnxheula_0xa02bcf5b, UnequipDuringRagdoll, uqxjyvfa_0xfc80dbfc, vwyelbca_0x81ece712</WeaponFlags>
    -->
</CWeaponInfo>

</sss>

weaponcomponent_test.meta:

<?xml version="1.0" encoding="utf-8"?>
<CWeaponComponentInfoBlob>
  <Infos>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_GRIP</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="1.000000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_GRIP_IRONWOOD</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="1.000000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_GRIP_ENGRAVED</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="1.000000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_SIGHT_NARROW</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="1.000000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_SIGHT_WIDE</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="0.950000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="1.000000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP1</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP2</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP3</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP4</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP5</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
    <Item type="CWeaponComponentInfo">
      <Name>COMPONENT_RIFLE_SPRINGFIELD_WRAP6</Name>
      <UnlockHash />
      <AttachBone />
      <AccuracyModifier value="1.000000" />
      <CameraFovModifier value="1.000000" />
      <DamageModifier value="1.000000" />
      <DegradationModifier value="0.900000" />
      <FireRateModifier value="3.500000" />  <!-- Set value here. Default: 1.0  -->
      <VfxOpacityModifier value="1.000000" />
      <bShownOnWheel value="true" />
      <CreateObject value="true" />
    </Item>
  </Infos>
</CWeaponComponentInfoBlob>

Customize the magazine size and reload speed in the first file, and the firing speed in the second file. Run your server and script and enter the game, check in the console (F8) that the files are successfully loaded:

And this is what our result looks like - a fully automatic weapon with 50 rounds in the magazine and reduced reload speed.

Video Link

Additionally, you can replace the weapon model, and the result will look like this, but that’s not part of this tutorial.

7 Likes

Files: GitHub - draobrehtom/redm-custom-weapon
Weapon Flags: rdr-weapon-flags/weapon_flags.txt at main · draobrehtom/rdr-weapon-flags · GitHub

1 Like

Is there any way to use this to produce a custom weapon? Or would it always need to replace a preexisting gun?

Basically duplicate a current weapon, then replace the model so you can still have the original weapon and a new one.

Also, been testing this out. Is there a way to reduce the rate of fire for other weapons, without using custom attachments? I added the mauser but it always has an extremely high rate of fire. I did not add any custom parts as in the customization for the springfield.

This is not possible at the moment, as RedM does not support catamlog_mp.ymt, and this file is the starting point for defining new weapons.

Indeed, firerate does not work properly. I think the issue is the lack of some weapon flag. You could try setting different weapon flags and their combinations and see if you can replicate the standard behaviour with default fire rate.

I have seen it possible for others to duplicate a weapon’s statistics and animations, then stream another over top. I am unsure how they do it though. This is likely a large step forward though to getting there.

If you figure out the fire rate issues, please let me know. I will be looking through to determine why all weapons go full-auto as well.

1 Like

I have seen it possible for others to duplicate a weapon’s statistics and animations, then stream another over top. I am unsure how they do it though. This is likely a large step forward though to getting there.

They did everything using Lua script by attaching YDR prop to weapon + other script tweaks. For example weapon name is changed by using:

AddTextEntry('weapon_repeater_evans', 'test12345')

So far the only way to add-on custom weapon in RedM is to follow same technic with Lua scripting, such as:

  1. Define a moment when you want to use custom weapon (usually it is inventory item usage).
  2. Give base weapon to player and at the same time attach YDR prop on it (we are faking add-on weapon by placing custom prop on default weapon).
  3. Change weapon name in weapon wheel with the help of AddTextEntry native.
  4. Change weapon stats in weapon wheel (to be researched).
  5. Change weapon icon in weapon wheel (to be researched).

Regarding weapons stats, maybe something related to UI Apps can be applied and some other natives to change weapon physical characteristics. Take a look on next examples:

Examples

RedM-jo_libs/jo_libs/modules/ui/client.lua at 7cccf6b597a683568d5f2b4255175b2ec09bc3bf · Jump-On-Studios/RedM-jo_libs · GitHub

wild/wild-satchel/client/cl_weaponDegradation.lua at 9235aaa39696691ff26977ff1d2c18fe67971ef5 · aaron1a12/wild · GitHub

wild/wild-core/client/cl_weaponWheel.lua at 9235aaa39696691ff26977ff1d2c18fe67971ef5 · aaron1a12/wild · GitHub


Regarding weapon icon replacement in weapon wheel, the only method I can think of is to accurately determine the weapon wheel position on the screen, which varies with different display screens, and then draw a texture on top of desired weapon icon (RequestStreamedTextureDict, DrawSprite).

Example

GitHub - abdulkadiraktas/qadr-safe: edited for Redem by qadr_*

1 Like

Here proper config for changing Mauser’s reload speed and magazine size :slight_smile:

<?xml version="1.0" encoding="UTF-8"?>
<Infos> 
  <CWeaponInfo>
    <Name>WEAPON_PISTOL_MAUSER</Name>
    
    <ClipInfos itemType="dyasubaa_0xde99e9ed">
        <Item>
            <Size value="15" />
        </Item>
    </ClipInfos>
    
    <WeaponReload type="CWeaponReload">
        <AnimReloadRate value="0.1" />
    </WeaponReload>

  </CWeaponInfo>
</Infos>

Looks good! The customization works well, adding sights in the other config will allow for fire rate adjustment, though the reload size and speed remain the same. Gonna keep tweaking it on my end.

Is there a way to reduce the size of ClipSize or set it to 0? I tried the tag used in FiveM, but unfortunately it didn’t work.

I didn’t check it. You can try this resource GitHub - draobrehtom/redm-custom-mauser, in config change Size value from 15 to 1 or 0

Weapon Decoration

Source: @snapopotamus Weapon file data mounting does not work in RedM. · Issue #2718 · citizenfx/fivem · GitHub

Download weapon-decoration.zip (779 Bytes)

1 Like

Nice! Glad it’s already getting some use!

Hopefully more can come from it with more eyes on it.

Per @draobrehtom:

regarding pbrweaponsurfaces.ymt I failed to stream it in game. The only result I get is when it manually placed into RedM folder (editing existing surfaces and adding new one - all works)

Certainly a limitation, but custom colors are possible!

1 Like

Alright probably the last update from me for a while, will likely take a break from this for a sec.

I believe the next step in this process is to figure out custom wrap tinting.

Here is what I have discovered so far:

  • The wrap tint is controlled via weaponcomponents.meta.
  • It is the same Item type, CWeaponComponentDecorationInfo
  • It has a type of Tint
  • The data type is different, it is CWeaponDecorationDataInt
  • It has a value associated with it that presumably controls the tint rgb values (among other things).
  • It is as of yet unclear where this value comes from.

Literally have zero clue as to the file that might be storing these tint values, at the moment. Will come back to it at some point, though.

image

2 Likes

This is fantastic to see, excellent work!

We’re always getting closer to custom streamed weapons and custom colours. I can’t wait for this stuff to be well understood and for folks to start making custom items for the community!

Guys, you know how to add maxammo to the weapon?, so instead of having 100 bullets, put like 200 or more

Please share the information on how you streamed the weapon model

Check out any single-player weapon mod on Nexus Mods, extract the .ydr and .ytd files in the stream folder, and you’re good to go.

LMFAO, I already did that, with the same gun model! :grin: but thank you for helping anyway.
By the way, did you figure out a way to get the change the weapon icon in the weapon wheel? like in the other mod on nexus, Tommygun Tweaks.

Haha, that’s awesome! :smile: As for the weapon wheel icons, you can update them by streaming multiwheel_weapons.ytd