Broadcast sound to single client

Locked
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Broadcast sound to single client

Post by nexus024 »

I have been trying to get this code to broadcast a sound to a single entity on the server but thus far I haven't had much luck. Can someone please tell me what I am missing? Thanks for any help!

Code: Select all

void BroadCastSoundClient(gentity_t *ent, char *path) {
    gentity_t   *te;
    vec3_t      origin;

    if(!strlen(path))
        return;
    origin[0] = origin[1] = origin[2] = 0;
    te = G_TempEntity(origin, EV_GLOBAL_SOUND);
    te->s.eventParm = G_SoundIndex(path);
    //only send to a single client
    te->r.svFlags |= SVF_SINGLECLIENT;
    te->r.singleClient = ent->s.number;
    te->s.otherEntityNum = ent->s.number;
}
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Broadcast sound to single client

Post by ^misantropia^ »

You are trying to send a sound event to a single client, right? What does the code above do? Nothing? Or broadcast the sound to all clients?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Re: Broadcast sound to single client

Post by nexus024 »

Yes, broadcast a sound to a single client. It will work on one map but then on the next it won't work.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Broadcast sound to single client

Post by ^misantropia^ »

Weird. I suppose some logging is in order. Does the server fire off the event? Does the client receive it?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Re: Broadcast sound to single client

Post by nexus024 »

Yes, it just worked 2-3 maps in a row so maybe it needs to just catch up once I enable my cvar. On another note, how can I make it so spectators watching the client don't get the sound copied to them too?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Broadcast sound to single client

Post by ^misantropia^ »

You'd probably have to intercept it client side. A spectator has for all practical purposes the same ps.clientNum as the player being followed so it gets a copy of everything the player receives.
Locked