Custom Sounds

Please post any questions about developing your plugin here. Please use the search function before posting!
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Custom Sounds

Postby Predz » Tue Oct 27, 2015 3:09 pm

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

Postby satoon101 » Tue Oct 27, 2015 3:17 pm

What game are you testing this on?
Image
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Tue Oct 27, 2015 3:18 pm

CSGO (but 5 char limitation xD)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Oct 27, 2015 3:21 pm

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.
Image
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Tue Oct 27, 2015 3:26 pm

Thanks :) I forgot entirely about this problem. Will see if I can get it working using the fake precache. :)
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Tue Oct 27, 2015 3:38 pm

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()

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 58 guests