Page 1 of 2

playing sounds to the player only??

Posted: Tue Aug 21, 2012 12:52 pm
by drm_wayne
hey,

I recently try to add Hitmarker sounds to my quakemod, they also working but everybody kan hear the sounds..
Is there a way to play a sound to the current player only? I hear some thing about "stuffcmd playsound yoursound.wav",
but is there a better way? it should work in fitzquake/proquake, no darkplaces and other stuff plz.

I added it into combat.qc

Code: Select all

// do the damage
  targ.health = targ.health - take;

  sound (activator, CHAN_AUTO, "weapons/hitmarker.wav", 1, ATTN_NORM); //Hitmarker sound, maybe wrong

  if (targ.health <= 0)
  {
    Killed (targ, attacker);
    return;
  }

Re: playing sounds to the player only??

Posted: Tue Aug 21, 2012 1:09 pm
by Spike
not possible without extensions.

you could do it with writebytes, but that's so insanely hacky that I'm not even going to explain it.

Re: playing sounds to the player only??

Posted: Tue Aug 21, 2012 7:36 pm
by drm_wayne
That sad, so i need to stay with "bullet hits body" sounds on the player..
btw: do you know how i can make a weaponsound play looped and then stopped by another sound when you stop fireing?
i think the "invisibility whispering" is using a similar method, but i am not home atm to look in my sources...
atm i only have a normal sound playing for the weapon and it sounds not really good..

Re: playing sounds to the player only??

Posted: Tue Aug 21, 2012 10:49 pm
by frag.machine
drm_wayne wrote:That sad, so i need to stay with "bullet hits body" sounds on the player..
btw: do you know how i can make a weaponsound play looped and then stopped by another sound when you stop fireing?
i think the "invisibility whispering" is using a similar method, but i am not home atm to look in my sources...
atm i only have a normal sound playing for the weapon and it sounds not really good..

For looping sounds in Quake you just need to open the .wav file in SoundForge (or any other good sound editor of your preference) and add a cue tag at the point where the loop is supposed to start. Stopping the looping sound is a bit more tricky: you need to play another sound (even "misc/null.wav" works) thru the exactly the same entity and voice channel.

Re: playing sounds to the player only??

Posted: Wed Aug 22, 2012 9:28 am
by drm_wayne
i wont do it that way, because when you get shoot or killed the sound still plays...
I kinda suck at soundthings...

Re: playing sounds to the player only??

Posted: Wed Aug 22, 2012 6:49 pm
by Spike
you can use svc_startsound.
the problem there is that you don't know the sound index of the sound you wish to play.


you can use stuffcmds.
the problem there is that the sound is centered on where you were when the sound started playing. strafe to one side and it sounds really stupid. there are some engines that attempt to fix that directly, and some that have a playsound2 console command instead.


you can use csqc.
woo. dp+fte only.


you can use localsound.
buggy pile of poo that only works in single player as its not networked. only works in telejano.


you can use the regular sound builtin.
give it a really high attenuation, and it will be barely audiable for players further away, yet will follow the player upon which it was started.
attenuation is typically limited to a max value of about 4.

you can use ext_dimension_send.
woo. ftesv only, but won't crash other engines.
example follows. note the attenuation value in this example is 4, as a fallback for other servers that don't recognise dimensions.
//set up multicasts to send to only one player
dimension_send = 512;
self.dimension_see = 512;
//call the sound builtin (which multicasts in fte/qw)
sound(self, CHAN_FOO, "foo.wav", 1, 4);
//reset to defaults, so nothing else breaks
dimension_see = 255;
self.dimension_see = 255;


so yeah, sucks.

Re: playing sounds to the player only??

Posted: Wed Aug 22, 2012 6:54 pm
by drm_wayne
heh, thanks..

the unusual way stuffcmd "play hitmarker.wav" works great at least for the hitmaker sounds :D
But i need to take a "deeper" look at the soundstuff, some things are still a misterium for me :lol:
I also tricked my MG sound now, it was supposed to be a played loop, but now we edited the soundfiles
and the self.attack finished of the firefunction and now it sounds like it should sound :)

Re: playing sounds to the player only??

Posted: Mon Oct 01, 2012 3:10 pm
by Seven
frag.machine wrote: For looping sounds in Quake you just need to open the .wav file in SoundForge (or any other good sound editor of your preference) and add a cue tag at the point where the loop is supposed to start. Stopping the looping sound is a bit more tricky: you need to play another sound (even "misc/null.wav" works) thru the exactly the same entity and voice channel.
Hello,

can somebody tell me how to add a loop into a .wav file with another program than sound forge ?
This is an extremely expensive program and a free version is not available.
I do not understand this part:
add a cue tag
google also did not help me :(

Thank you for your help and effort.
Seven

Re: playing sounds to the player only??

Posted: Mon Oct 01, 2012 3:14 pm
by Nahuel

Re: playing sounds to the player only??

Posted: Mon Oct 01, 2012 3:41 pm
by Seven
Hello Nahuel,

Audacity is what I used until now. But it does not seem to be able to add "cue tags"...

But nevermind, I found a software (with shareware option) that can do it: Goldwave

Here is a step by step explanation for dummies like myself, how to do it :)
https://developer.valvesoftware.com/wik ... ng_a_Sound

valvesoftware helped us, hehe...

EDITED:
Nahuel, if you found a way to do it with Audacity, please describe which menue-option do you use for it ?
Thank you.

Re: playing sounds to the player only??

Posted: Mon Oct 01, 2012 9:09 pm
by frag.machine
Seven wrote:Hello Nahuel,

Audacity is what I used until now. But it does not seem to be able to add "cue tags"...

But nevermind, I found a software (with shareware option) that can do it: Goldwave

Here is a step by step explanation for dummies like myself, how to do it :)
https://developer.valvesoftware.com/wik ... ng_a_Sound

valvesoftware helped us, hehe...

EDITED:
Nahuel, if you found a way to do it with Audacity, please describe which menue-option do you use for it ?
Thank you.

Yeah, sorry, my bad. Goldwave works, too, I could mentioned. Luckily you found out by yourself. ;)

Re: playing sounds to the player only??

Posted: Mon Oct 01, 2012 9:46 pm
by leileilol
Cool Edit 95 can also do it, it's what id used.

Re: playing sounds to the player only??

Posted: Tue Oct 02, 2012 12:39 am
by RenegadeC
leileilol wrote:Cool Edit 95 can also do it, it's what id used.
Me too, Cool Edit 95 is where it's at ;)

Re: playing sounds to the player only??

Posted: Tue Jul 15, 2014 6:31 pm
by Baker
A while late, but I have a theory on how to successfully do this in most engines in a looping way.

In engines that support music in id1/music, use svc_cdtrack

Code: Select all

WriteByte (MSG_ONE, SVC_CDTRACK);
			WriteByte (MSG_ONE, 2);
			WriteByte (MSG_ONE, 2);
Have the .mp3 or .ogg be what you want the player to hear.

Re: playing sounds to the player only??

Posted: Tue Jul 15, 2014 8:46 pm
by r00k
I would think a stuffcmd is plenty reliable...and fast.

I did change my player pain sounds to car horns once. its not like a complete hack, as further away you really cant hear them ;)