playing sounds to the player only??

Discuss programming in the QuakeC language.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

playing sounds to the player only??

Post 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;
  }
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: playing sounds to the player only??

Post 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.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: playing sounds to the player only??

Post 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..
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: playing sounds to the player only??

Post 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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: playing sounds to the player only??

Post 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...
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: playing sounds to the player only??

Post 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.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: playing sounds to the player only??

Post 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 :)
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: playing sounds to the player only??

Post 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
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: playing sounds to the player only??

Post by Nahuel »

hi, I am nahuel, I love quake and qc.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: playing sounds to the player only??

Post 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.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: playing sounds to the player only??

Post 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. ;)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: playing sounds to the player only??

Post by leileilol »

Cool Edit 95 can also do it, it's what id used.
i should not be here
RenegadeC
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada
Contact:

Re: playing sounds to the player only??

Post 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 ;)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: playing sounds to the player only??

Post 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.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: playing sounds to the player only??

Post 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 ;)
Post Reply