Page 1 of 1

Custom Sounds

Posted: Tue Oct 27, 2015 3:09 pm
by Predz
Currently am trying to get custom sounds working for a server I am working on. Am using the Sound class available and have tried playing the sound on my end after the download happens.

The download works perfectly and anyone who joins downloads the file without error. However when trying to play the sound I get some sort of "mixer" error.

Code: Select all

[Sound] S_StartSound(): Failed to load sound 'source-python\wcs\levelup.mp3'. Can't create mixer.


Using the code below:

Syntax: Select all

from events import Event

from engines.sound import Sound

from filters.recipients import RecipientFilter

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

levelup = Sound(None, 0, 'source-python/wcs/levelup.mp3', download=True)

@Event('player_jump')
def player_jump(event):
player = PlayerEntity(index_from_userid(event.get_int('userid')))
levelup.index = player.index
levelup.play(RecipientFilter())

Posted: Tue Oct 27, 2015 3:17 pm
by satoon101
What game are you testing this on?

Posted: Tue Oct 27, 2015 3:18 pm
by Predz
CSGO (but 5 char limitation xD)

Posted: Tue Oct 27, 2015 3:21 pm
by satoon101
I imagine this might be part of your issue:
https://wiki.alliedmods.net/CSGO_Quirks#Playing_Custom_Sounds

We currently don't have any workarounds built into our API.

Posted: Tue Oct 27, 2015 3:26 pm
by Predz
Thanks :) I forgot entirely about this problem. Will see if I can get it working using the fake precache. :)

Posted: Tue Oct 27, 2015 3:38 pm
by Predz
Got it working :smile:

Syntax: Select all

from events import Event

from engines.sound import Sound

from filters.recipients import RecipientFilter

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

from stringtables import string_tables
from stringtables.downloads import Downloadables

soundprecache = string_tables.soundprecache

downloadables = Downloadables()
downloadables.add('sound/source-python/wcs/levelup.mp3')

soundprecache.add_string('*/source-python/wcs/levelup.mp3', '*/source-python/wcs/levelup.mp3')

@Event('player_jump')
def player_jump(event):
player = PlayerEntity(index_from_userid(event.get_int('userid')))
Sound(RecipientFilter(), player.index, '*/source-python/wcs/levelup.mp3').play()