First, with SparkIV, export your WEAPONS.ivaud from resident.rpf (find it in
pc\audio\Sfx). Open the WEAPONS.ivaud with GTA IV-aud and import all sound files
to here (match the names):

M4_SHOT1_L
M4_SHOT1_R
M4_SHOT2_A
M4_SHOT2_B
M4_SHOT2_C
M4_SHOT2_D

Save once done and import back to resident.rpf, Save and close.

If you are using the Silencer attachment, import all the sound files from the
"Silenced version" folder to here (match the names):

M4_SHOT1_L
M4_SHOT1_R
M4_SHOT2_A
M4_SHOT2_B
M4_SHOT2_C
M4_SHOT2_D

Now install this WeaponInfo to M4 line:

Non-silenced version (use this if you are using non-silencer attachment)

	<weapon type="M4">
		<data slot="RIFLE" firetype="INSTANT_HIT" damagetype="BULLET" group="RIFLE_ASSAULT" targetrange="40.0" weaponrange="600" clipsize="30" ammomax="300" timebetweenshots="66">
			<damage base="40" networkplayermod="2.5" networkpedmod="1.25"/>
			<physics force="75.0"/>
			<reload time="2066" fasttime="1166" crouchtime="2066"/>

			<aiming accuracy="0.75">
				<offset x="0.14" y="1.0" z="0.55"/>
				<crouchedoffset x="0.08" y="1.0" z="0.12"/>
				<reticule standing="0.6" ducked="0.5" scale="0.3"/>
			</aiming>

			<pickup regentime="300000" ammoonstreet="45"/>

			<controller>
				<rumble duration="200" intensity="0.55"/>
			</controller>

			<flags>
				<flag>GUN</flag>
				<flag>CAN_AIM</flag>
				<flag>2HANDED</flag>
				<flag>ANIM_RELOAD</flag>
				<flag>CAN_FREE_AIM</flag>
				<flag>ANIM_CROUCH_FIRE</flag>
			</flags>
		</data>

		<assets model="w_m4">
			<anim group="gun@ak47">
				<rates firerate="2.58" blindfirerate="2.58"/>
			</anim>
			<effects>
				<muzzle fx="muz_machine"/>
				<shell fx="weap_ejected_rifle"/>
			</effects>
		</assets>
	</weapon>

Silenced version (use this if you are using silencer attachment)

	<weapon type="M4">
		<data slot="RIFLE" firetype="INSTANT_HIT" damagetype="BULLET" group="RIFLE_ASSAULT" targetrange="40.0" weaponrange="600" clipsize="30" ammomax="300" timebetweenshots="66">
			<damage base="40" networkplayermod="2.5" networkpedmod="1.25"/>
			<physics force="75.0"/>
			<reload time="2066" fasttime="1166" crouchtime="2066"/>

			<aiming accuracy="0.75">
				<offset x="0.14" y="1.0" z="0.55"/>
				<crouchedoffset x="0.08" y="1.0" z="0.12"/>
				<reticule standing="0.6" ducked="0.5" scale="0.3"/>
			</aiming>

			<pickup regentime="300000" ammoonstreet="45"/>

			<controller>
				<rumble duration="200" intensity="0.55"/>
			</controller>

			<flags>
				<flag>GUN</flag>
				<flag>CAN_AIM</flag>
				<flag>2HANDED</flag>
				<flag>ANIM_RELOAD</flag>
				<flag>CAN_FREE_AIM</flag>
				<flag>ANIM_CROUCH_FIRE</flag>
				<flag>SILENCED</flag>
			</flags>
		</data>

		<assets model="w_m4">
			<anim group="gun@ak47">
				<rates firerate="2.58" blindfirerate="2.58"/>
			</anim>
			<effects>
				<muzzle fx="muz_pistol_small"/>
				<shell fx="weap_ejected_rifle"/>
			</effects>
		</assets>
	</weapon>