Sounds and effects

Please post any questions about developing your plugin here. Please use the search function before posting!
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Sounds and effects

Postby Hedgehog » Sat Jun 07, 2014 7:59 pm

I'm trying to play sound from CS:S to player, but my server crashes on emit_sound command.

Syntax: Select all

from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid

from engines.sound import EngineSound
from engines.sound import Channels
from engines.sound import VOL_NORM
from engines.sound import Attenuations
from engines.sound import SoundFlags
from engines.sound import PitchTypes
from filters.recipients import RecipientFilter

from listeners import LevelInitListenerManager
from listeners import ServerActivateListenerManager

sound_path = 'doors/default_locked.wav'


def load():
EngineSound.precache_sound(sound_path, False, False)
ServerActivateListenerManager.register_listener(_server_activate)


def _server_activate(edicts, edict_count, client_max):
EngineSound.precache_sound(sound_path, False, False)


@Event
def player_say(event):
userid = event.get_int('userid')
index = index_from_userid(userid)
text = event.get_string('text')
player = PlayerEntity(index)

if text == 'run':
filter = RecipientFilter(index)

EngineSound.emit_sound(filter, 1, Channels.AUTO, sound_path, VOL_NORM, Attenuations.NORMAL, SoundFlags.NOFLAGS, PitchTypes.NORMAL, player.m_vecOrigin)

Also, I'm not sure what I need to provide in second arg (entity_index) of emit_sound.
Or can I call client-side play command somehow (like cexec in Mani/ES)?


Can someone provide me an example of using effects in SP? Especially I'm intrested in TempEntities.

CS:S, Windows, May 14 build
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Jun 07, 2014 11:35 pm

I'll have to test out sounds myself. I am fairly certain that the iEntIndex is the index of the entity to emit the sound from. I'm not sure how the vecOrigin affects that. It could possibly be crashing for you if the index 1 is not filled on your server when you call emit_sound, so it tries to emit the sound from an invalid index. I could be wrong on that, but it is my first guess. Try removing the player.m_vecOrigin and changing the 1 to index (or player.index). Also, the flags and pitch are default to the values you are passing in, so you can remove them, as well. All arguments up to attenuation are required, the rest are optional.

As for TempEntities, this addon uses it:
http://www.sourcepython.com/showthread.php?502

Though, we have since added directly to the effects package:[python]from effects import TempEntities[/python]
That should work for both CS:GO and the Valve OrangeBox-engine games.
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Mon Jun 09, 2014 5:58 pm

satoon101 wrote:I'll have to test out sounds myself. I am fairly certain that the iEntIndex is the index of the entity to emit the sound from. I'm not sure how the vecOrigin affects that. It could possibly be crashing for you if the index 1 is not filled on your server when you call emit_sound, so it tries to emit the sound from an invalid index. I could be wrong on that, but it is my first guess. Try removing the player.m_vecOrigin and changing the 1 to index (or player.index). Also, the flags and pitch are default to the values you are passing in, so you can remove them, as well. All arguments up to attenuation are required, the rest are optional.

Changed to
[PYTHON]EngineSound.emit_sound(rfilter, player.index, Channels.AUTO, sound_path, VOL_NORM, Attenuations.NORMAL)[/PYTHON]
still crashing :(
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Jun 11, 2014 1:03 am

Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Wed Jun 11, 2014 3:45 pm

Thank you) Works ok now.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 78 guests