Failed to load sound

Hi guys,

I am new with LUA (but not with coding in general) so I am trying to customize a SWEP from a tutorial (http://wiki.garrysmod.com/page/Chair_Throwing_Gun or http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0e63.html).
I would like to use custom sounds but I get always the same error (Failed to load sound “name.wav”, file probably missing from disk/repository).

I would like to know if there is a specific folder for custom audio files. I’ve created a sound folder inside garrysmod, addons and in a custom gamemode I made, but nothing works.
Now my SWEP is in “garrysmod\gamemodes\mod01\entities\weapons”.

There are a lot of threads regarding this kind of problem but there is no specific solution for the latest version.

Thanks for any help!

you need to have it under youraddonfoldername/sound

You can have it in your root folders too. Can you post your weapon code in


 tags please?

yeah, but that’s implied since the addon folders are really just merged with the root folder later on


SWEP.PrintName		= "Sine Wave Rifle"			
SWEP.Author			= "N"
SWEP.Instructions	= "Shot a sine wave"

SWEP.Spawnable = true
SWEP.AdminOnly = true

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo		    = "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo		    = "none"

SWEP.Weight			    = 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Slot		 	    = 1
SWEP.SlotPos			= 2
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= true

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
SWEP.WorldModel			= "models/weapons/w_pistol.mdl"

-- local ShootSound = Sound( "Metal.SawbladeStick" )
   local ShootSound = Sound( "sound/sine.wav" )

--[[
SWEP.Primary.Sound = "sound/sine.wav"

function SWEP:Initialize() -- Tells the script what to do when the player "Initializes" the SWEP.
	util.PrecacheSound(self.Primary.Sound) 
	util.PrecacheSound(self.Secondary.Sound) 
    self:SetWeaponHoldType( self.HoldType )
end
--]]

--[[
function SWEP:Precache()

util.PrecacheSound("sound/sine.wav")
end
]]--

--
-- Called when the left mouse button is pressed
--

function SWEP:PrimaryAttack()

	-- This weapon is 'automatic'. This function call below defines
	-- the rate of fire. Here we set it to shoot every 0.5 seconds.
	self.Weapon:SetNextPrimaryFire( CurTime() + 0.3 )	

	-- Call 'ThrowChair' on self with this model
	self:ThrowChair( "models/props_c17/oildrum001.mdl" )

	self:EmitSound( ShootSound )
--	self:EmitSound(Sound(self.Primary.Sound)) 
--  self:EmitSound(Sound("sound/sine.wav")) 

end
 
--
-- Called when the rightmouse button is pressed
--
function SWEP:SecondaryAttack()

	-- Note we don't call SetNextSecondaryFire here because it's not
	-- automatic and so we let them fire as fast as they can click.	

	-- Call 'ThrowChair' on self with this model
	self:ThrowChair( "models/props_c17/FurnitureChair001a.mdl" )

end

--
-- A custom function we added. When you call this the player will fire a chair!
--
function SWEP:ThrowChair( model_file )

	-- 
	-- Play the shoot sound we precached earlier!
	--
	self:EmitSound( ShootSound )

 
	--
	-- If we're the client ) then this is as much as we want to do.
	-- We play the sound above on the client due to prediction.
	-- ( if ( we didn't they would feel a ping delay during multiplayer )
	--
	if ( CLIENT ) then return end

	--
	-- Create a prop_physics entity
	--
	local ent = ents.Create( "prop_physics" )

	--
	-- Always make sure that created entities are actually created!
	--
	if (  !IsValid( ent ) ) then return end

	--
	-- Set the entity's model to the passed in model
	--
	ent:SetModel( model_file )
 
	--
	-- Set the position to the player's eye position plus 16 units forward.
	-- Set the angles to the player'e eye angles. Then spawn it.
	--
	ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 40 ) )
	ent:SetAngles( self.Owner:EyeAngles() )
	ent:Spawn()
 

	--
	-- Now get the physics object. Whenever we get a physics object
	-- we need to test to make sure its valid before using it.
	-- If it isn't ) then we'll remove the entity.
	--
	local phys = ent:GetPhysicsObject()
	if (  !IsValid( phys ) ) then ent:Remove() return end
 
 
	--
	-- Now we apply the force - so the chair actually throws instead 
	-- of just falling to the ground. You can play with this value here
	-- to adjust how fast we throw it.
	--
	local velocity = self.Owner:GetAimVector()
	velocity = velocity * 400000
	velocity = velocity + ( VectorRand() * 10 ) -- a random element
	phys:ApplyForceCenter( velocity )
 
	--
	-- Assuming we're playing in Sandbox mode we want to add this
	-- entity to the cleanup and undo lists. This is done like so.
	--
	cleanup.Add( self.Owner, "props", ent )
 
	undo.Create( "Thrown_Chair" )
		undo.AddEntity( ent )
		undo.SetPlayer( self.Owner )
	undo.Finish()
end

I’ve tried to put sounds in the addons folder, it doesn’t work.

You don’t need “sound/” that part is implied by every sound function.

Thanks, now it works. I’ve tried before this solution with no success but the file was in different folders.
I know it was a stupid matter, but I had to create this sound folder…

Thanks again!