Page 1 of 1
HL2DM: Winner sound
Posted: Sun Feb 28, 2021 6:18 am
by daren adler

Hello game scripters

I would like to have a script/sound for a winner on my server. The sound i will be using would be (x/chat/badboys/badboys_001.mp3). Thank You and have a great weekend.
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 10:48 am
by cssbestrpg
Hi, try this script its untested since i don't own this game.
Syntax: Select all
from events import Event
from engines.sound import Sound
from stringtables.downloads import Downloadables
WINNER_SOUND = Sound('x/chat/badboys/badboys_001.mp3')
def load():
dl = Downloadables()
dl.add('sound/x/chat/badboys/badboys_001.mp3')
@Event('game_end')
def game_end(args):
if args['winner'] > 1:
WINNER_SOUND.play()
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 5:54 pm
by daren adler
OK, i will give it a try, thank you.

I checked it and it loads and no errors, but it dont work, i get no sound, thank you for trying.
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 7:37 pm
by cssbestrpg
Does the game have rounds? i am not familiar to game, i need more details of it when the sound should be played?
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 8:06 pm
by daren adler
No rounds, it goes through the maps every 20 min with a map end sound, i need a sound when a player gets 172 score and ends the game before time runs out.
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 8:13 pm
by cssbestrpg
Try this it plays sound different way than previous version
Syntax: Select all
from events import Event
from players.helpers import edict_from_userid
from filters.players import PlayerIter
from engines.server import engine_server
from stringtables.downloads import Downloadables
def load():
dl = Downloadables()
dl.add('sound/x/chat/badboys/badboys_001.mp3')
@Event('game_end')
def game_end(args):
if args['winner']:
for i in getUseridList():
playgamesound(i, 'sound/x/chat/badboys/badboys_001.mp3')
def getUseridList():
for i in PlayerIter.iterator():
yield i.userid
def playgamesound(userid, _sound):
client_command(userid, 'play %s' % _sound)
def client_command(userid, __cmd__):
engine_server.client_command(edict_from_userid(userid), __cmd__)
Edit:
- Added missing def client_command
Re: HL2DM: Winner sound
Posted: Sun Feb 28, 2021 8:25 pm
by daren adler
Ok will do, thanks again

update, nope no sound on winnner, again thanks for trying,,there were no errors, but again there is no sound.