SWEP reload sounds don't work

I’ve realized i have made multiple threads regarding other things, but i am the biggest noob concerning lua so bear with me. i am trying to learn it…
anyway, i fixed up some black ops sweps for gmod13 hoverver, the sound don’t work.
here is the code:


if (CLIENT) then
	SWEP.BounceWeaponIcon   = true	
	SWEP.WepSelectIcon		= surface.GetTextureID("vgui/entities/fokku_bo_ak47")
	killicon.Add("fokku_bo_ak47","vgui/entities/fokku_bo_ak47_kc",Color(255,255,255))	
end

SWEP.Category				= "Black Ops"
SWEP.Author				= "Fokkusu"
SWEP.Contact				= "STEAM: dragon5876"
SWEP.Purpose				= "Jihadding"
SWEP.Instructions				= "BANGZIEZ"
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment			= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.DrawCrosshair			= false	

SWEP.ViewModelFOV			= 65
SWEP.ViewModelFlip			= true
SWEP.ViewModel				= "models/weapons/v_cbo_ak47.mdl"
SWEP.WorldModel				= "models/weapons/w_rif_ak47.mdl"
SWEP.Base 				= "gdcw_base_assault"
SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true

SWEP.Primary.Sound			= Sound("Weapon_boak.Single")
SWEP.Primary.Round			= ("gdcwa_7.62x39_tracer")
SWEP.Primary.RPM				= 600						// This is in Rounds Per Minute
SWEP.Primary.ClipSize			= 30						// Size of a clip
SWEP.Primary.DefaultClip			= 60
SWEP.Primary.KickUp			= 0.5					// Maximum up recoil (rise)
SWEP.Primary.KickDown			= 0.4					// Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal			= 0.4					// Maximum up recoil (stock)
SWEP.Primary.Automatic			= true						// Automatic/Semi Auto
SWEP.Primary.Ammo			= "ar2"

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			= ""
SWEP.Secondary.IronFOV			= 55						// How much you 'zoom' in. Less is more! 	

SWEP.data 				= {}						// The starting firemode
SWEP.data.ironsights			= 1


SWEP.IronSightsPos = Vector (3.263, -4.1547, 0.8342)
SWEP.IronSightsAng = Vector (0.3294, -0.1301, 0)
SWEP.SightsPos = Vector (3.263, -4.1547, 0.8342)
SWEP.SightsAng = Vector (0.3294, -0.1301, 0)
SWEP.RunSightsPos = Vector (-2.3095, -3.0514, 2.3965)
SWEP.RunSightsAng = Vector (-19.8471, -33.9181, 10)

can someone help me with this.

Well there’s nothing there about reloading. Could you show us the reload method in your weapon base (gdcw_base_assault)?

in the base it should say something about reload sound eg swep.reloadsound copy that in to your gun and put the reload sound in there

there is nothing about reload sound except


SWEP.Primary.Sound 			= Sound("")				// Sound of the gun

and


function SWEP:Reload()

	self.Weapon:DefaultReload(ACT_VM_RELOAD) 
	if !self.Owner:IsNPC() then
	self.Idle = CurTime() + self.Owner:GetViewModel():SequenceDuration() end

	if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and !self.Owner:IsNPC() then
	-- When the current clip < full clip and the rest of your ammo > 0, then

		self.Owner:SetFOV( 0, 0.3 )
		-- Zoom = 0

		self:SetIronsights(false)
		-- Set the ironsight to false

		if CLIENT then return end
		self.Owner:DrawViewModel(true)
end
	
end

and thats about it. what now?

[editline]19th August 2013[/editline]

there isn’t such a code like that i can find. any more help? :confused:

Another problem has risen and is giving so many errors. plus iron sights of some weapons don’t work.
[ERROR] gamemodes/sandbox/entities/weapons/gmod_camera.lua:81: attempt to call method ‘SetWeaponHoldType’ (a nil value)

  1. unknown - gamemodes/sandbox/entities/weapons/gmod_camera.lua:81

why is this ‘SetWaeponHoldType’ command giving errors? need major help!

Use your original code.

Under everything put:



local wepname = "weapon name here"
local time1 = 1
local sound1 = "your/1st/sound/file.here"
local time2 = 2
local sound2 = "your/2nd/sound/file.here"
local time3 = 3
local sound3 = "your/3rd/sound/file.here"
local time4 = 4
local sound4 = "your/4th/sound/file.here"
local time5 = 5
local sound5 = "your/5th/sound/file.here"
function SWEP:Reload()
	self.Weapon:DefaultReload(ACT_VM_RELOAD)

	if (self.Weapon:Clip1() < self.Primary.ClipSize) and (self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
		self:SetIronsights(false)
		self:ReloadAnimation()
        if time1 > 0 then
           timer.Create(wepname.. "1", time1, 1, function() self.Weapon:EmitSound(sound1) end)
        end
        if time2 > 0 then
        timer.Create(wepname.. "2", time2, 1, function() self.Weapon:EmitSound(sound2) end)
        end
        if time3 > 0 then
           timer.Create(wepname.. "3", time3, 1, function() self.Weapon:EmitSound(sound3) end)
        end
        if time4 > 0 then
           timer.Create(wepname.. "4", time4, 1, function() self.Weapon:EmitSound(sound4) end)
        end
        if time5 > 0 then
           timer.Create(wepname.. "5", time5, 1, function() self.Weapon:EmitSound(sound5) end)
        end
	end
end



Replace all of the time and sound variables, with time being the time to emit the respective sound, and sound being the sound for the respective reload time.
If you need more reload sounds, copy



        if time1 > 0 then
           timer.Create(wepname.. "1", time1, 1, function() self.Weapon:EmitSound(sound1) end)
        end


and replace all of the 1’s with the sound number you need to add. Also copy time1 and sound1 and replace the 1 with the number you need to add. You may need to play with the reload sound timing in game.

Or you could just use sound.Add()

It’s a replacement for the old .txt sound scripts.

That is assuming your model has sound events.

Sound events? what do you mean?

It’s an animation event that is defined in the QC file before compiling the model. It is usually designated by the number 5004. It will play a sound assigned to the name at the defined frame of an animation. Here is an example of the event in the QC file


{ event 5004 frame number "Insert.Name" }

But since you are not compiling a model you don’t have to worry about that code. I take it since you are fixing them up for g13 they were originally made for 12. They should have came with a folder called scripts and inside should be txt files with something like this in them.


"Weapon_G3SG1.Clipout"
{
	"channel"		"CHAN_ITEM"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"1.0"
	"pitch"		"PITCH_NORM"

	"wave"			"weapons/g3sg1/g3sg1_clipout.wav" 
}

This has been replaced with sound.Add Here is an example of a sound.Add


sound.Add(
{
    name = "Weapon_G3SG1.Clipout",
    channel = CHAN_STATIC,
    volume = 1.0,
    soundlevel = 80,
    sound = "weapons/g3sg1/g3sg1_clipout.wav"
})

This will go into a lua file that will in-turn go into the autorun folder of your addon. You will repeat this code for every sound script in that file. This will make it so you don’t have to make a bunch of timers because the sounds will play when the animation calls for it.

This is a good idea but that code would lead to problems. Any timer that’s created by a SENT/SWEP needs to include a unique identifier like the object’s ent index, otherwise a ton of identically-named timers could be running at the same time and you’d never be able to properly update, check, or kill any of them.

And just a general coding tip, that snippet can be a lot more efficient. For instance, instead of ten separate variables with different values, you could store the information in a single table with the sound name as each key and the duration as each value. You can then use pairs in a for loop to automatically create a timer with each sound and duration in the table. Adding a sound would just require adding a key/value pair to the table.

Thanks guys for helping out. but i will try to use this code in two weeks as i am busy.
see you guys then.

Another question, how do i update sounds?
because replacing the sound files don’t work. (the sounds have been named exactly as the previous)
however they still play the old sounds. even if they don’t exist. how do fix this?
(not part of the above problem. a different question)