Ent:EmitSound()/Ent:StopSound() problem, any workaround?

Well, as I’m stuck with CreateSound not being a 3d sound, and ENT:StopSound() not working as described on the wiki, I was hoping for someone to know a way around.

I currently have a cannon, which shoots off another entity, which is ofcourse, a cannonball.

What I wanted to have was people being able to hear the ball fly, now the problem is with CreateSound is that you need to be within range of the place of where it gets launched from to be able to actually hear the ball fly off, but if you’re waiting at place of impact, the sneaky fella will just bomb you like it just came out of nowhere.
That isn’t something for what I was aiming for and want the sound to be heard from the entity when it’s fired, anytime, anyplace, within reach.

EmitSound seems to be able to do the job, but sadly: http://wiki.garrysmod.com/?title=Entity.StopSound, this doesn’t seem to be working anymore to stop the 12 second loop.

I could think of just making the loop not looped and just repeat EmitSound every 12 seconds, but what if the sound just started playing again 1 second before it exploded.
Yes, a lame effect where the sound still stays buggering you for 11 seconds.

Garry, could you fix this?
Fellow facepunchers, do you know a way around?

Either way will make me happy and willing to learn more.

Thanks.

Try using CSoundPatch:SetSoundLevel() once before (or is it after?) you play the sound.

I think there’s a list on the wiki that explains what each sound level is. All I can remember is that 0 makes it audible everywhere and that 160 or something makes it audible from a long distance.

It will restart the sound once you set the sound level, so use it once.

Thanks, but this is not really what I was looking for.

The cannonball is supposed to have a looped sound ATTACHED to it, which should even be heard when you’re standing on place of impact, while the cannon is on the other side of the map.

CreateSound() doesn’t work for this, as you can only hear it fly off.
EmitSound() works, but once the ball explodes, the sound keeps on playing at place of impact, if StopSound() was working properly (referring to garry to fix it) I wouldn’t have this problem.

Incredibly large bump as this hasn’t been solved yet, and really want to get this over with now.

I’m really not sure this works, but try to EmitSound this sound “common/null.wav”. It’s apparently used for stopping sounds, but I’m not sure how it works exactly.

Don’t know how to use the null.wav either.

Oh come on, it’s been half a year now.

Another huuuge bump.

It has been more than half a year now, can this PLEASE be fixed as I have been stalled for HALF a year now.

BUMP.

Seriously come on.

Maybe you should learn reading topics before trying to help anyone.

This is exactly a function I don’t need at all.
Why?

If you looked into OP, it clearly says I want a player to hear it when the sound object comes closer to them, even though it is initiated from very far away.

Guess what CreateSound does when a player is too far away?


From the wiki:

**  Additional Info **

 
[ul]
[li] Does not play long sounds correctly.[/li][li] **If a player gets to far away from where the sound is emitted the sound will disappear. **[/li][/ul]


Rated dumb.

Oh right. I should have told you that a while ago. You simply play it like any sound file, using EmitSound. It is used to stop looping sounds, but since it’s used only with soundscripts, I’m not sure it works on sounds you are playing directly from a file.

If it doesn’t work, you could try using CreateSound clientside, and give the created sound the maximum possible sound level, so that it always plays at full volume, wherever you are. Then in your entity’s clientside Think hook, calculate the volume yourself. It’s hacky, but it would be certainly interesting, if you feel like doing some more math, you could even try to manipulate the pitch to give your sound a Doppler effect.

Agh, I’m extremely bad at such kind of math, but I guess I’ll give it a try.

I’m using a direct soundfile so I hope it works.

Nope, still at 0.

Why doesn’t garry fix this instead of releasing all those new things.

EDIT: Sweet jesus, I’ve just realised this has taken as long as at least 10 months now. -.-

Bump…

BUMP, Can someone start making a cake, this thread is almost 1 year old and still alive and kicking.
BUMP.

Another Bump, this thread is almost 1 year old \o/

Another bump, passed the 1 year and 1 month mark.

Derp, bump.

I think the CSoundPatch issues might’ve been fixed already.
I remember having the same problems in the past, but I just tried it again and the CSoundPatch played fine, even when I was out of range and then came close to it.

Just tried it, negative, doesn’t work the way I want it to. unless you have an alternative way of using it, but I doubt it.
The sound plays fine when you’re close to it, then go far away and back, but when it starts playing while you are out of range, and go to it, just doesn’t want to play.