• Trouble getting sWep to play custom sound.
    12 replies, posted
Howdy, sorry to bother you. But this is bothering me. Here's the code and the error below. [CODE]Failed to load sound "weapons\mccree\nooner.wav", file probably missing from disk/repository [/CODE] [CODE] AddCSLuaFile() if ( SERVER ) then resource.AddWorkshop( "123277559" ) end SWEP.PrintName = "McCree's Mistake" SWEP.Author = "Crafty_" SWEP.Contact = "http://steamcommunity.com/id/Crafty_/" SWEP.Purpose = "Praise be to Gandalf" SWEP.Instructions = "Right-Click, Left-Click, R" SWEP.Category = "memes" SWEP.Spawnable= true SWEP.AdminSpawnable= true SWEP.AdminOnly = true --if CLIENT then --killicon.Add( "ar1_ak", "entities/ar1killicon", Color( 255, 80, 0, 255 ) ) --SWEP.WepSelectIcon = surface.GetTextureID( "hud/ar1hudicon.vtf" ) --end SWEP.ViewModelFOV = 75 SWEP.ViewModel = "models/weapons/c_357.mdl" SWEP.WorldModel = "models/weapons/w_357.mdl" SWEP.ViewModelFlip = false SWEP.AutoSwitchTo = true SWEP.AutoSwitchFrom = false SWEP.ShowViewModel = true SWEP.ShowWorldModel = true SWEP.ViewModelBoneMods = {} SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.UseHands = true SWEP.HoldType = "357" SWEP.FiresUnderwater = true SWEP.DrawCrosshair = true SWEP.DrawAmmo = true SWEP.ReloadSound = "weapons/357/357_reload4.wav" SWEP.Base = "weapon_base" SWEP.Primary.Sound = Sound("weapons/357_fire2.wav") SWEP.Primary.Damage = 1000 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 6 SWEP.Primary.Ammo = "357" SWEP.Primary.DefaultClip = 6 SWEP.Primary.Spread = 10 SWEP.Primary.NumberofShots = 100 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = .6 SWEP.Primary.Delay = 0.145 SWEP.Primary.Force = 1000 SWEP.Primary.Empty = Sound("weapons/357/357_spin1.wav") SWEP.Secondary.Sound = Sound("npc/strider/fire.wav") SWEP.Secondary.Damage = 17 SWEP.Secondary.TakeAmmo = 10 SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Spread = 0.1 SWEP.Secondary.NumberofShots = 10 SWEP.Secondary.Automatic = true SWEP.Secondary.Recoil = 5 SWEP.Secondary.Delay = 1 SWEP.Secondary.Force = 170 SWEP.Secondary.Ammo = "none" SWEP.Secondary.Empty = Sound("weapons\nooner.wav") SWEP.CSMuzzleFlashes = true SWEP.IronSightsPos = Vector(0, 0, 0) SWEP.IronSightsAng = Vector(0, 0, 0) --function SWEP:Initialize() --util.PrecacheSound(self.Primary.Sound) --util.PrecacheSound(self.ReloadSound) --self:SetWeaponHoldType( self.HoldType ) --end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then self:EmitSound(Sound(self.Primary.Empty)) return end local bullet = {} bullet.Num = self.Primary.NumberofShots bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = 1 bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo bullet.TracerName = "Tracer" local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self:ShootEffects() self.Owner:FireBullets( bullet ) self:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() self:EmitSound( "weapons/mccree/nooner.wav", 75, 100, 1, CHAN_AUTO ) end function SWEP:Reload() self:EmitSound(Sound(self.ReloadSound)) self.Weapon:DefaultReload( ACT_VM_RELOAD ); end --ocal a = "weapons/mccree/nooner.wav" function SWEP:Initialize() util.PrecacheSound(self.Primary.Sound) util.PrecacheSound(self.ReloadSound) self:SetWeaponHoldType( self.HoldType ) if CLIENT then // Create a new table for every weapon instance self.VElements = table.FullCopy( self.VElements ) self.WElements = table.FullCopy( self.WElements ) self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods ) self:CreateModels(self.VElements) // create viewmodels self:CreateModels(self.WElements) // create worldmodels // init view model bone build function if IsValid(self.Owner) then local vm = self.Owner:GetViewModel() if IsValid(vm) then self:ResetBonePositions(vm) // Init viewmodel visibility if (self.ShowViewModel == nil or self.ShowViewModel) then vm:SetColor(Color(255,255,255,255)) else // we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called vm:SetColor(Color(255,255,255,1)) // ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in // however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing vm:SetMaterial("Debug/hsv") end end end end end function SWEP:Holster() if CLIENT and IsValid(self.Owner) then local vm = self.Owner:GetViewModel() if IsValid(vm) then self:ResetBonePositions(vm) end end return true end function SWEP:OnRemove() self:Holster() end if CLIENT then SWEP.vRenderOrder = nil function SWEP:ViewModelDrawn() local vm = self.Owner:GetViewModel() if !IsValid(vm) then return end if (!self.VElements) then return end self:UpdateBonePositions(vm) if (!self.vRenderOrder) then // we build a render order because sprites need to be drawn after models self.vRenderOrder = {} for k, v in pairs( self.VElements ) do if (v.type == "Model") then table.insert(self.vRenderOrder, 1, k) elseif (v.type == "Sprite" or v.type == "Quad") then table.insert(self.vRenderOrder, k) end end end for k, name in ipairs( self.vRenderOrder ) do local v = self.VElements[name] if (!v) then self.vRenderOrder = nil break end if (v.hide) then continue end local model = v.modelEnt local sprite = v.spriteMaterial if (!v.bone) then continue end local pos, ang = self:GetBoneOrientation( self.VElements, v, vm ) if (!pos) then continue end if (v.type == "Model" and IsValid(model)) then model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z ) ang:RotateAroundAxis(ang:Up(), v.angle.y) ang:RotateAroundAxis(ang:Right(), v.angle.p) ang:RotateAroundAxis(ang:Forward(), v.angle.r) model:SetAngles(ang) //model:SetModelScale(v.size) local matrix = Matrix() matrix:Scale(v.size) model:EnableMatrix( "RenderMultiply", matrix ) if (v.material == "") then model:SetMaterial("") elseif (model:GetMaterial() != v.material) then model:SetMaterial( v.material ) end if (v.skin and v.skin != model:GetSkin()) then model:SetSkin(v.skin) end if (v.bodygroup) then for k, v in pairs( v.bodygroup ) do if (model:GetBodygroup(k) != v) then model:SetBodygroup(k, v) end end end if (v.surpresslightning) then render.SuppressEngineLighting(true) end render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255) render.SetBlend(v.color.a/255) model:DrawModel() render.SetBlend(1) render.SetColorModulation(1, 1, 1) if (v.surpresslightning) then render.SuppressEngineLighting(false) end elseif (v.type == "Sprite" and sprite) then local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z render.SetMaterial(sprite) render.DrawSprite(drawpos, v.size.x, v.size.y, v.color) elseif (v.type == "Quad" and v.draw_func) then local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z ang:RotateAroundAxis(ang:Up(), v.angle.y) ang:RotateAroundAxis(ang:Right(), v.angle.p) ang:RotateAroundAxis(ang:Forward(), v.angle.r)
The sound is missing from your client.
How do I fix that? :V
Download it. If it's on a server, add it to the FastDL.
Well I have the sound in it's sound file with a string going to it, but it still says it's missing. So how would I work around that?
Make sure the sound type and file is completely correct. Otherwise, the sound could be a bitrate that GMod can't support.
I had the file name "example.wav" by accident so would that have mean the proper string would have been "example.wav.wav" ?
[QUOTE=Crafty_;50968115]I had the file name "example.wav" by accident so would that have mean the proper string would have been "example.wav.wav" ?[/QUOTE] If that's the file name. Make sure you have file types enabled in windows explorer to see the full name.
Alright, I got the entire addon completed (including custom sound) but for whatever reason it did not like the name of some of file names. I accidently named it something on the whitelist, so I had to go change the names of everything with that name, aaaaand it broke the custom sound. Here's the error: [CODE]Failed to load sound "weapons\nyan\hoinoon.wav", file probably missing from disk/repository [/CODE] And here's the now busted code (again): [CODE]AddCSLuaFile() if ( SERVER ) then resource.AddWorkshop( "123277559" ) end SWEP.PrintName = "McCree's Mistake" SWEP.Author = "Crafty_" SWEP.Contact = "http://steamcommunity.com/id/Crafty_/" SWEP.Purpose = "Praise be to Gandalf" SWEP.Instructions = "Right-Click, Left-Click, R" SWEP.Category = "Crafty_'s O.W. SWeps" SWEP.Spawnable= true SWEP.AdminSpawnable= true SWEP.AdminOnly = false if CLIENT then killicon.Add( "sswep_highnoon", "hud/noonhud", Color( 255, 80, 0, 255 ) ) SWEP.WepSelectIcon = surface.GetTextureID( "hud/noonhud.vtf" ) end SWEP.ViewModelFOV = 75 SWEP.ViewModel = "models/weapons/c_357.mdl" SWEP.WorldModel = "models/weapons/w_357.mdl" SWEP.ViewModelFlip = false SWEP.AutoSwitchTo = true SWEP.AutoSwitchFrom = false SWEP.ShowViewModel = true SWEP.ShowWorldModel = true SWEP.ViewModelBoneMods = {} SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.UseHands = true SWEP.HoldType = "revolver" SWEP.FiresUnderwater = true SWEP.DrawCrosshair = true SWEP.DrawAmmo = true SWEP.ReloadSound = "weapons/357/357_reload4.wav" SWEP.Base = "weapon_base" SWEP.Primary.Sound = Sound("weapons/357_fire2.wav") SWEP.Primary.Damage = 1000 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 6 SWEP.Primary.Ammo = "357" SWEP.Primary.DefaultClip = 6 SWEP.Primary.Spread = 10 SWEP.Primary.NumberofShots = 100 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = .6 SWEP.Primary.Delay = 0.145 SWEP.Primary.Force = 1000 SWEP.Primary.Empty = Sound("weapons/357/357_spin1.wav") SWEP.Secondary.Sound = Sound("npc/strider/fire.wav") SWEP.Secondary.Damage = 17 SWEP.Secondary.TakeAmmo = 10 SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Spread = 0.1 SWEP.Secondary.NumberofShots = 10 SWEP.Secondary.Automatic = true SWEP.Secondary.Recoil = 5 SWEP.Secondary.Delay = 1 SWEP.Secondary.Force = 170 SWEP.Secondary.Ammo = "none" SWEP.Secondary.Empty = Sound("weapons/nyan/hoinoon.wav") SWEP.CSMuzzleFlashes = true SWEP.IronSightsPos = Vector(0, 0, 0) SWEP.IronSightsAng = Vector(0, 0, 0) function SWEP:Deploy() self:SendWeaponAnim( ACT_VM_DRAW ) self:SetNextPrimaryFire( CurTime() + self:SequenceDuration() ) if ( CLIENT ) then return true end --self:Idle() self.BeatSound = CreateSound( self.Owner, Sound( "weapons/nyan/hoinoon.wav" ) ) if ( self.BeatSound ) then self.BeatSound:Play() end return true end --function SWEP:Initialize() --util.PrecacheSound(self.Primary.Sound) --util.PrecacheSound(self.ReloadSound) --self:SetWeaponHoldType( self.HoldType ) --end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then self:EmitSound(Sound(self.Primary.Empty)) return end local bullet = {} bullet.Num = self.Primary.NumberofShots bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = 1 bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo bullet.TracerName = "Tracer" local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self:ShootEffects() self.Owner:FireBullets( bullet ) self:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() self:EmitSound( "weapons/nyan/hoinoon.wav" ) end function SWEP:Reload() self:EmitSound(Sound(self.ReloadSound)) self.Weapon:DefaultReload( ACT_VM_RELOAD ); end[/CODE] The EXACT location of the sound file: sounds -> weapons -> nyan -> hoinoon (hoinoon is a .wav but it is not named hoinoon.wav) Please help me because it took forever to get the custom sound to work and now it's broke again thanks to me naming poorly.
If you're using the Nyan gun resources, you should credit Robotboy655 as well. Try running this in the server console and post the result. [code]lua_run print(file.Exists("sound/weapons/nyan/hoinoon.wav","GAME"))[/code] And in your client console with sv_cheats enabled. [code]lua_run_cl print(file.Exists("sound/weapons/nyan/hoinoon.wav","GAME"))[/code]
[CODE]] lua_run print(file.Exists("sound/weapons/nyan/hoinoon","GAME")) > print(file.Exists("sound/weapons/nyan/hoinoon","GAME"))... false [/CODE] What you told me to do [CODE]] lua_run print(file.Exists("addons/highnnonswep/sounds/weapons/nyan/hoinoon.wav","GAME")) > print(file.Exists("addons/highnnonswep/sounds/weapons/nyan/hoinoon.wav","GAME"))... true [/CODE] What I also did. So should this be the actual file location in the code? : highnnonswep/sounds/weapons/nyan/hoinoon.wav EDIT: Is the file supposed to be named sound or sounds? [editline]29th August 2016[/editline] Finally fixed the problem, thank you so much for your help!
It's supposed to be in sound. sounds is not a directory.
I wish people would stop editing my work and completely removing my authorship and ignoring the things I asked you not to do. [img]http://i.imgur.com/QvkYxRZ.png[/img]
Sorry, you need to Log In to post a reply to this thread.