• Sound only plays for local player?
    8 replies, posted
Hey, I have simplified my script but it basically does this with other things in the middle. This is in my Shared.lua however it only plays the primary attack sound. Does this Scan sound need to be server side or something? What am I missing? Thanks! local ShootSound = Sound( "npc/scanner/combat_scan3.wav" ) local FoundSound = Sound( "npc/scanner/combat_scan5.wav" ) function SWEP:PrimaryAttack() self.Weapon:EmitSound( ShootSound ) end function SWEP:Scan() self.Weapon:EmitSound( FoundSound ) end
Where do you call your Scan function?
Sorry, edited. I only did this as a mockup to explain my problem. Not the actual script.
the actual script would help.
local ShootSound = Sound( "npc/scanner/combat_scan3.wav" ) local FoundSound = Sound( "npc/scanner/combat_scan5.wav" ) function SWEP:PrimaryAttack() if !SERVER then return end self.Weapon:EmitSound( ShootSound ) self:Scan() end function SWEP:Scan() if !SERVER then return end self.Weapon:EmitSound( FoundSound ) end This should help you man! ^_^
But he said in his original post that PrimaryAttack works already. This means his code must be running on the SERVER.
Oops my bad. I thought he was talking about secondaryattack for some very odd reason[. Anyhow, it's probably because he's trying to emit 2 sounds at once. EmitSound sometimes has issues playing two sounds at once from what I can re-call. Also, make sure that you're still using "if SERVER then" since you're using shared.lua Your server will still spit an error, if you leave EmitSound on the SHARED part of things. Again, make sure you use "if SERVER then" for server-side code, and "if CLIENT then" for client-side code.
I tried running two sounds in sequence on the same entity. I found it didn't work so I just did self.Weapon:EmitSound("somesound") self.Owner:EmitSound("someothersound") This might not work in your case but it's a lazy ass solution that saves me some work.
Thanks man. I did not realize that both did not work together. I "re-jigged" my loop so the sounds only play on certain conditions.
Sorry, you need to Log In to post a reply to this thread.