Here is the CPP i wrote for a silenced MP5 that i made a while ago. you can look at the coding and make comparisons. It is written for version 1.46....so it is pretty old, but hopefully it will help you get an understanding and fix your problems...
BUNTRO :beat:
//Heckler & Koch MP5 redone by BUNTRO (BUN)
//Sounds and pictures!
//Basic info on the weapon
//Manufacturer: Heckler and Koch (Germany)
//Length (collapsed stock): 19.29 inches
//Length (stock extended): 25.98 inches
//Weight: 7.44 pounds (w/30rd mag)
//Bore diameter: 9mm
//Maximum Effective Range: 328.1 feet
//Rate of Fire: 800 rounds per minute
//http://www.moreammo.com/HK.html
// some basic defines
#define TEast 0
#define TWest 1
#define TGuerrila 2
#define TCivilian 3
#define TSideUnknown 4
#define TEnemy 5
#define TFriendly 6
#define TLogic 7
#define true 1
#define false 0
// type scope
#define private 0
#define protected 1
#define public 2
#define WeaponNoSlot 0// dummy weapons
#define WeaponSlotPrimary 1// primary weapons
#define WeaponSlotSecondary 16// secondary weapons
#define WeaponSlotItem 256// items
#define WeaponSlotBinocular 4096// binocular
#define WeaponHardMounted 65536
class CfgPatches
{
class BUNHKMP5
{
units[] = {};
weapons[] = {BUNHKMP5};
requiredVersion = 1.30;
};
};
class CfgAmmo
{
class Default {};
class BulletSingle: Default{};
class BUN9MMS: BulletSingle
{
hit= 8;
indirectHit= 1;
indirectHitRange= 0.40000;
minRange=0.5;
minRangeProbab=0.800000;
midRange=50;
midRangeProbab=0.350000;
maxRange=109;
maxRangeProbab=0.080000;
visibleFire= 16;
audibleFire= 16;
visibleFireTime= 10;
};
};
class CfgWeapons
{
class Default {};
class MGun: Default {};
class Riffle: Mgun {};
class BUNHKMP5: Riffle
{
scopeWeapon=2;
scopeMagazine=0;
model="\BUNHKMP5\BUNHKMP5.p3d";
modelOptics="\BUNHKMP5\BUNHKMP5S.p3d";
picture="\BUNHKMP5\BUN10.paa";
displayName="MP5 NAVY";
drySound[]={"\BUNHKMP5\BUNHKMP5D.wav",1.000000,1};
reloadMagazineSound[]={"\BUNHKMP5\BUNHKMP5R.wav",0.010316,1};
magazines[]={"BUNHKMP5mag"};
flash="gunfire";
flashSize=5;
initSpeed=938;
opticsFlare= true;
modes[]= {"Single","Burst","Full"};
class Single
{
ammo="BUN9MMS";
multiplier=1;
burst=1;
displayName="SINGLE FIRE";
dispersion=0.0002000;
sound[]={"\BUNHKMP5\BUNHKMP5S.wav",1.000000,1};
soundContinuous= 0;
ffCount=1;
reloadTime=0.100000;
recoil="BUNHKMP5RE";
autofire=0;
aiRateOfFire=5.0000;
aiRateOfFireDistance = 200;
UseAction=0;
useActionTitle="";
};
class Burst
{
ammo="BUN9MMS";
multiplier=1;
burst=3;
displayName= "BURST FIRE";
dispersion= 0.0004000;
sound[]={"\BUNHKMP5\BUNHKMP5B.wav",1.000000,1};
soundContinuous=0;
reloadtime=0.10000;
ffCount=3;
recoil= "BUNHKMP5RE";
autoFire=0;
aiRateofFire= 5.0000;
aiRateOfFireDistance= 200;
useAction= 0;
useActionTitle= "";
};
class Full
{
ammo="BUN9MMS";
multiplier= 1;
burst= 1;
displayName= "FULL AUTO";
dispersion=0.0008000;
sound[]={"\BUNHKMP5\BUNHKMP5B.wav",1.000000,1};
soundContinuous= 0;
reloadTime= 0.100000;
ffCount= 3;
recoil= "BUNHKMP5RE";
autoFire= 1;
aiRateOfFire= 5.00000;
aiRateOfFireDistance= 200;
useAction = 0;
useActionTitle= "";
};
};
class BUNHKMP5mag: BUNHKMP5
{
scopeWeapon=0;
scopeMagazine=2;
displayNamgeMagazine="9mm";
shortNameMagazine="9mm";
picture="\BUNHKMP5\BUN11.paa";
};
};
class CfgRecoils
{
BUNHKMP5RE[]= {0.04, 0.015,0.030, 0.040,0,0};
};
class CfgNonAIVehicles
{
class ProxyWeapon {};
class ProxyBUNHKMP5: ProxyWeapon {};
};