To play announcement messages to players I've made use of the SendAudio 
HUD message, although there are a few tweaks needed to enable it:

In hud.cpp find

#ifdef CSTRIKE_DLL
DECLARE_MESSAGE(gHUD, SendAudio);
#endif

and comment out the #ifdef and #endif, do the same for

#ifdef CSTRIKE_DLL
    HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif

In hl2_usermessages.cpp register a new message:

usermessages->Register( "SendAudio", -1 );

Once that's done you should be able to call it with something like this:

CRecipientFilter filter;
filter.AddAllPlayers();
filter.MakeReliable();

//send announcement to play
UserMessageBegin( filter, "SendAudio" );
WRITE_STRING( "Your.Sound"  );
MessageEnd();

Then you just need to make sure you have your sound setup in 
scripts\game_sounds.txt

You can also use CBroadcastRecipientFilter to send to all players or 
filter.AddRecipientsByTeam() to add a specific team.

This was on the Orange Box SDK, but I'm fairly sure that EP1 SDK is 
similar. No idea if it's suitable for what you want to use it for, might 
be better to look at doing it on the client as it's a regular occurence, 
and should be predictable anyway.

- Rich

Jorge Rodriguez wrote:
> On Mon, Feb 16, 2009 at 12:00 PM, Yorg Kuijs <[email protected]> wrote:
>
>   
>> 1. Does anybody know if it's possible to have a sound be emitted that
>> only the player it was meant for can hear? As far as I know all sounds
>> are emitted into the world. I might be making a hitbleep system similar
>> to quake, wet, et:qw and dystopia, roughly I think it would look like
>> this in the ontakedamage class:
>> pAttacker->PlayAttackerHearableSoundOnly( "soundname" );
>> or
>> pInflictor->PlayInflictorHearableSoundOnly( "soundname" );
>>
>> well the function is bogus ofcourse since it doesn't exist. So does
>> anybody know?
>>
>>     
>
> You can emit the sound on the client, or you can call the sound with a
> single recipient filter instead of a pas filter.
>
>   


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to