Page 1 of 1

EmitSound

Posted: Thu Oct 20, 2016 4:15 pm
by velocity
How would I emitsound in sourcepython?

Syntax: Select all

es.emitsound("player", userid, "player/falldamage.wav", 1, 25)


I'm trying to mimic the player falldamage sound, but I'm not sure how to emitsound in sourcepython, so it's only a specific radius people hear the sound?

Re: EmitSound

Posted: Thu Oct 20, 2016 4:31 pm
by satoon101
The maximum attenuation is only 3.98, so I'm not sure using 25 would work at all.
https://github.com/alliedmodders/hl2sdk ... ags.h#L110

If you want to play it across the whole server, use Attenuation.NONE (which is default for the Sound class). In the same way, the default for volume is VOL_NORM (which is 1):
https://github.com/Source-Python-Dev-Te ... #L112-L118

Syntax: Select all

from engines.sound import Attenuation, Sound
from events import Event
from players.helpers import index_from_userid


my_sound = Sound('player/falldamage.wav', attenuation=Attenuation.GUNFIRE)


@Event('player_say')
def player_say(game_event):
my_sound.index = index_from_userid(game_event['userid'])
my_sound.play()

By not passing any user indexes in the play() method, all players hear the sound.

*Edit: though, in the future, we might consider adding Entity.emit to emit sounds from an entity/player, as well as Player.play to play a sound directly to a user.

Re: EmitSound

Posted: Thu Oct 20, 2016 5:01 pm
by velocity
Thank you, I'll test it! 25 was just to give an example. I'm only gonna emitsound for a very small area

Re: EmitSound

Posted: Fri Oct 21, 2016 3:48 am
by D3CEPTION
satoon101 wrote:*Edit: though, in the future, we might consider adding Entity.emit to emit sounds from an entity/player, as well as Player.play to play a sound directly to a user.

+1

Re: EmitSound

Posted: Sat Oct 22, 2016 2:27 am
by L'In20Cible