EmitSound

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

EmitSound

Postby velocity » Thu Oct 20, 2016 4:15 pm

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?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: EmitSound

Postby satoon101 » Thu Oct 20, 2016 4:31 pm

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.
Image
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: EmitSound

Postby velocity » Thu Oct 20, 2016 5:01 pm

Thank you, I'll test it! 25 was just to give an example. I'm only gonna emitsound for a very small area
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: EmitSound

Postby D3CEPTION » Fri Oct 21, 2016 3:48 am

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
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: EmitSound

Postby L'In20Cible » Sat Oct 22, 2016 2:27 am


Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 31 guests