While doing some work on Jailbreak I’ve just noticed that my post on using SendAudio to send sounds to be played on clients is out of date.
In the orangebox sdk there is a new event named teamplay_broadcast_audio which is already set up to allow you to play announcement like sounds on the client (i.e. sounds that are heard in the players head, rather than placed in the level somewhere).
You can quite easily rip the function from the roundbased gamerules and place it in your own to make use of it:
1 2 3 4 5 6 7 8 9 10 11 | void CJBGameRules::BroadcastSound( int iTeam, const char *sound ) { //send it to everyone IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_broadcast_audio" ); if ( event ) { event->SetInt( "team", iTeam ); event->SetString( "sound", sound ); gameeventmanager->FireEvent( event ); } } |
Then just call it with the team you want and the sound name, like so:
1 | BroadcastSound(TEAM_REBELS, "Jailbreak.ExecutionAverted"); |
This doesn’t have much over the previous way of playing sounds as it ultimately works the same way on the client, but it is slightly more concise to call, and of course involves less work to set it up in the first place, which is always a bonus.
May 26th, 2009 at 11:22 am
I like the other way better lol
May 31st, 2009 at 12:20 pm
[...] Playing sounds is great, but occasionally you may want to stop a sound that is currently being played. For example there is an execution countdown in Jailbreak that can be averted mid way through, and it was easiest to have this as a single sound that can be stopped as needed. [...]