I need swep help

I’m making a small swep pack (no, non of the sweps so 10 thousand damage, fire lasers, or props) and I have a few questions:

  1. What is the exact code I would use to randomize firing sounds?
  2. How do I change the pumping/shell insertion sounds?
    heres an example of a shotgun im working on (using Mad Cows Base)

// Variables that are used on both client and server

SWEP.Base 				= "weapon_mad_base_shotgun"

SWEP.ViewModelFlip		= true
SWEP.Category			= "*****"
SWEP.ViewModel			= "models/weapons/v_shot_m3super95.mdl"
SWEP.WorldModel			= "models/weapons/w_shot_m3super95.mdl"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= false

SWEP.Primary.Sound 		= Sound("weapons/spas/m3-1.wav")
SWEP.Primary.Recoil		= 4
SWEP.Primary.Damage		= 18
SWEP.Primary.NumShots		= 14
SWEP.Primary.Cone			= 0.025
SWEP.Primary.Delay 		= 0.85

SWEP.Primary.ClipSize		= 9					// Size of a clip
SWEP.Primary.DefaultClip	= 8					// Default number of bullets in a clip
SWEP.Primary.Automatic		= false				// Automatic/Semi Auto
SWEP.Primary.Ammo			= "Buckshot"

SWEP.Secondary.ClipSize		= -1					// Size of a clip
SWEP.Secondary.DefaultClip	= -1					// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false				// Automatic/Semi Auto
SWEP.Secondary.Ammo		= "none"

SWEP.ShellDelay			= 0.53

SWEP.IronSightsPos = Vector (2.6847, -5.6888, 1.6512)
SWEP.IronSightsAng = Vector (0.37, 0.1817, 0)
SWEP.RunArmOffset = Vector (-4.6638, -3.7178, -0.6803)
SWEP.RunArmAngle = Vector (-12.9323, -45.8191, 11.8832)

SWEP.ShotgunReloading		= false
SWEP.ShotgunFinish		= 0.5
SWEP.ShotgunBeginReload		= 0.3

/*---------------------------------------------------------
   Name: SWEP:Precache()
   Desc: Use this function to precache stuff.
---------------------------------------------------------*/
function SWEP:Precache()

    	util.PrecacheSound("weapons/spas/m3_insertshell.wav")
end

do you want a different pitch or a different sound ?

for the shotgun look at the code in the css pump shotgun in your CSS folder in your addons.

No, What you need to do is use a Script…


"Weapon_G36k.Single"
{
	"channel"		"CHAN_WEAPON"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"0.48"
	"pitch"		"PITCH_NORM"
	"rndwave"
	{
		"wave" "weapons/G36c/aug-1.wav"
		"wave" "weapons/G36c/aug-2.wav"
		"wave" "weapons/G36c/aug-3.wav"
		"wave" "weapons/G36c/aug-4.wav"
	}
}

"G36c.MagIn"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/MagIn.wav"
}

"G36c.Magout"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/Magout.wav"
}

"G36c.BoltBack"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/BoltBack.wav"
}

"G36c.BoltForward"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/BoltForward.wav"
}


"G36c.Draw"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/Draw.wav"
}

"G36c.MagFiddle"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/MagFiddle.wav"
}


"G36c.Safety"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"			"PITCH_NORM"

	"wave"			"weapons/G36c/Safety.wav"
}

But usurally it would be a text file at Scripts/sounds/Game_sounds_weapons.txt

If the script the gun skin came with is made to overwrite the original Css Sounds then you have to edit the model as well.

The only difference is how do I make a script for shotgun sounds?
Heres a list of the .wav’s
weapons/spas/
-m3-1.wav
-m3_draw.wav
-m3_insertshell.wav
-m3_pump.wav

Would something like this work for you?



SOUNDLIST = {}
SOUNDLIST[1] = {
NAME = SOUND1
SOUNDFILE = randomsound1.wav
}
SOUNDLIST[2] = {
NAME = SOUND2
SOUNDFILE = randomsound2.wav
}
.
.
.

function RandomSound()
   local soundToUse = math.random(table.getn(SOUNDLIST))
   return SOUNDLIST[soundToUse].SOUNDFILE
end


That would obviously be for the random sounds. Then when you need to use a sound just call that function to get the location of the sound and play it.