• Lowering audio levels for SWEP
    3 replies, posted
I have this custom weapon, it's a chainsaw. Basically, the audio for it is way too loud in my server. I've taken the audio files that come with it and re-rendered them with lower audio levels, and then put them back into the folder they're supposed to go in (in my server), yet the audio is still as loud as it was earlier. I have deleted the files from my computer as well when doing so, so it re-downloaded the files to my pc from the server. Ingame the audio is, as I mentioned, as loud as it was earlier. Yet, when I go to the folder where they downloaded to, and play the files, they're as low as I made them. I was wondering if there's another way to lower audio levels that I don't know about? I'd really appreciate the help. Thanks in advance.
How are you playing the sound. Show your code.
[QUOTE=Robotboy655;42690479]How are you playing the sound. Show your code.[/QUOTE] Since the audio parts are in a couple of places, I cut out a piece from the coding to give you an idea of how the audio plays. This is from the "shared.lua" file. This weapon is used in Trouble in Terrorist Town, by the way. The audio files mentioned (for example chainsaw_attack.wav) are the ones I've lowered the audio levels on. SWEP.LastShootTime = 0 SWEP.IsMelee = true function SWEP:Initialize() self:SetWeaponHoldType("physgun") self:SetDeploySpeed(0.5) self.LastShootTime = 0 chainsawidle_Sound = Sound("weapons/arch_chainsaw/chainsaw_idle.wav") idlesound = CreateSound(self.Weapon, chainsawidle_Sound ) chainsawattack_Sound = Sound("weapons/arch_chainsaw/chainsaw_attack.wav") attacksound = CreateSound(self.Weapon, chainsawattack_Sound ) if CLIENT then emitter = ParticleEmitter(self:GetPos()) end end function SWEP:Deploy() self.Weapon:EmitSound( "weapons/arch_chainsaw/chainsaw_start_0"..math.random( 1, 2 )..".wav" ) self.Weapon:SendWeaponAnim( ACT_VM_DRAW ) timer.Create( "IdleSoundStart", 3, 1, function() idlesound:Play() -- starts the sound end ) end function SWEP:Reload() return false end function SWEP:Precache() util.PrecacheSound("physics/wood/wood_plank_impact_hard1.wav") util.PrecacheSound("physics/wood/wood_plank_impact_hard2.wav") util.PrecacheSound("physics/wood/wood_plank_impact_hard3.wav") util.PrecacheSound("physics/wood/wood_plank_impact_hard4.wav") util.PrecacheSound("physics/wood/wood_plank_impact_hard5.wav") util.PrecacheSound("physics/flesh/flesh_impact_bullet1.wav") util.PrecacheSound("physics/flesh/flesh_impact_bullet2.wav") util.PrecacheSound("physics/flesh/flesh_impact_bullet3.wav") util.PrecacheSound("physics/flesh/flesh_impact_bullet4.wav") util.PrecacheSound("physics/flesh/flesh_impact_bullet5.wav") util.PrecacheSound("weapons/knife/knife_slash1.wav") util.PrecacheSound("weapons/knife/knife_slash2.wav") end local function StabCallback(attacker, trace, dmginfo) if trace.Hit and trace.HitPos:Distance(trace.StartPos) <= 62 then attacksound:ChangePitch( 50 ) attacker:GetActiveWeapon():SendWeaponAnim(ACT_VM_HITCENTER) attacker:ViewPunch( Angle( math.random(-1,1), math.random(-1,1), 0 ) ) if trace.MatType == MAT_FLESH or trace.MatType == MAT_BLOODYFLESH or trace.MatType == MAT_ANTLION or trace.MatType == MAT_ALIENFLESH then local effectdata = EffectData() effectdata:SetOrigin(trace.HitPos) effectdata:SetMagnitude(math.random(1, 3)) effectdata:SetEntity(ent) util.Effect("bloodstream", effectdata) util.Decal("Blood", trace.HitPos + trace.HitNormal * 8, trace.HitPos - trace.HitNormal * 8) else local Effect = EffectData() Effect:SetOrigin(trace.HitPos) Effect:SetEntity(ent) Effect:SetMagnitude(0.2) Effect:SetScale(0.2) Effect:SetRadius(5) Effect:SetColor(Color(0,0,255,255)) util.Effect("sparks", Effect) attacker:EmitSound( "npc/manhack/grind"..math.random( 1, 5 )..".wav" ) util.Decal("ManhackCut", trace.HitPos + trace.HitNormal * 8, trace.HitPos - trace.HitNormal * 8) end if trace.Entity:IsValid() then return {damage = true, effects = false} end else attacksound:ChangePitch( 100 ) attacker:GetActiveWeapon():SendWeaponAnim(ACT_VM_HITCENTER) if SERVER then --attacker:EmitSound("weapons/iceaxe/iceaxe_swing1.wav", 80, math.random(65, 70)) end end return {effects = false, damage = false} end local function SlashCallback(attacker, trace, dmginfo) if trace.Hit and trace.HitPos:Distance(trace.StartPos) <= 62 then attacker:GetActiveWeapon():SendWeaponAnim(ACT_VM_MISSCENTER) if trace.MatType == MAT_FLESH or trace.MatType == MAT_BLOODYFLESH or trace.MatType == MAT_ANTLION or trace.MatType == MAT_ALIENFLESH then local effectdata = EffectData() effectdata:SetOrigin(trace.HitPos) effectdata:SetMagnitude(math.random(1, 3)) effectdata:SetEntity(ent) util.Effect("bloodstream", effectdata) util.Decal("Blood", trace.HitPos + trace.HitNormal * 8, trace.HitPos - trace.HitNormal * 8) else local Effect = EffectData() Effect:SetOrigin(trace.HitPos) Effect:SetEntity(ent) Effect:SetMagnitude(0.2) Effect:SetScale(0.2) Effect:SetRadius(5) Effect:SetColor(Color(0,0,255,255)) util.Effect("sparks", Effect) attacker:EmitSound( "npc/manhack/grind_flesh"..math.random( 1, 3 )..".wav", 200, 50 ) util.Decal("ManhackCut", trace.HitPos + trace.HitNormal * 8, trace.HitPos - trace.HitNormal * 8) end if trace.Entity:IsValid() then return {damage = true, effects = false} end else attacker:GetActiveWeapon():SendWeaponAnim(ACT_VM_MISSCENTER) if SERVER then --attacker:EmitSound("weapons/iceaxe/iceaxe_swing1.wav", 80, math.random(65, 70)) end end return {effects = false, damage = false} end function SWEP:CanPrimaryAttack() if self.Owner:Team() == TEAM_UNDEAD then self.Owner:PrintMessage(HUD_PRINTCENTER, "Great Job!") self.Owner:Kill() return false end if self.Owner:GetNetworkedBool("IsHolding") then return false end return self:CanSecondaryAttack() end function SWEP:CanSecondaryAttack() if self.Owner:Team() == TEAM_UNDEAD then self.Owner:PrintMessage(HUD_PRINTCENTER, "Great Job!") self.Owner:Kill() return false end if self.Owner:GetNetworkedBool("IsHolding") then return false end return self:GetNextSecondaryFire() <= CurTime() end function SWEP:PrimaryAttack() if self:CanSecondaryAttack() then self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self.Owner:SetAnimation(PLAYER_ATTACK1) self.Owner:ViewPunch( Angle( math.random(-0.5,0.5), math.random(-0.5,0.5), 0 ) ) if CLIENT then return end local bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector(0, 0, 0) bullet.Tracer = 0 bullet.Force = 2 bullet.Damage = self.Primary.Damage bullet.HullSize = 1.75 bullet.Callback = StabCallback self.Owner:FireBullets(bullet) end end function SWEP:SecondaryAttack() if self:CanSecondaryAttack() then self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay) self:SetNextPrimaryFire(CurTime() + self.Secondary.Delay) self:SetWeaponHoldType("melee2") self.Owner:SetAnimation(PLAYER_ATTACK1) self.Owner:EmitSound("weapons/arch_chainsaw/chainsaw_die_01.wav", 50, 100) self.Owner:ViewPunch( Angle( -10, 0, 0 ) ) timer.Create( "setmeleetype", 0.5, 1, function() self:SetWeaponHoldType("physgun") end) timer.Create( "Down", 0.1, 1, function() self.Owner:ViewPunch( Angle( 10, 0, 0 ) ) end) if CLIENT then return end local bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector(0, 0, 0) bullet.Tracer = 0 bullet.Force = 2 bullet.Damage = self.Secondary.Damage bullet.HullSize = 1.75 bullet.Callback = SlashCallback self.Owner:FireBullets(bullet) end end function SWEP:Holster() timer.Destroy( "IdleSound" ) idlesound:Stop() -- stops the sound attacksound:Stop() self.Owner:EmitSound("weapons/arch_chainsaw/chainsaw_die_01.wav") self.Owner:StopSound("weapons/arch_chainsaw/chainsaw_start_01") self.Owner:StopSound("weapons/arch_chainsaw/chainsaw_start_02") return true end if CLIENT then function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha) draw.SimpleText(self.PrintName, "HUDFontSmallAA", x + wide * 0.5, y + tall * 0.5, COLOR_RED, TEXT_ALIGN_CENTER) draw.SimpleText(self.PrintName, "HUDFontSmallAA", XNameBlur2 + x + wide * 0.5, YNameBlur + y + tall * 0.5, color_blur1, TEXT_ALIGN_CENTER) draw.SimpleText(self.PrintName, "HUDFontSmallAA", XNameBlur + x + wide * 0.5, YNameBlur + y + tall * 0.5, color_blu1, TEXT_ALIGN_CENTER) end end
[code] tags, please! You change the volume like this: attacksound:ChangeVolume(0.5) If I remember correctly, the range is 0-1, not 0-100. I might be wrong.
Sorry, you need to Log In to post a reply to this thread.