Raised This Month: $12 Target: $400
 3% 

Playing Sound to All Clients


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-19-2007 , 05:22   Playing Sound to All Clients
Reply With Quote #1

Hey guys, been wondering how can I play a sound to all clients ( clearly, as if they have played it themselves using the play command ) without going through this bs?

Code:
    new playersconnected;
    playersconnected = GetMaxClients();
    for (new i = 1; i <= playersconnected; i++)
    {
        if(IsClientInGame(i))
        {    
            ClientCommand(i,"play km/goodbye.wav");
        }
    }
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 09-19-2007 , 06:58   Re: Playing Sound to All Clients
Reply With Quote #2

EmitSoundToAll maybe?

PHP Code:
/**
 * Wrapper to emit sound to all clients.
 *
 * @param entity        Entity to emit from.
 * @param channel        Channel to emit with.
 * @param sample        Sound name.
 * @param level            Sound level.
 * @param flags            Sound flags.
 * @param volume        Sound volume.
 * @param pitch            Sound pitch.
 * @param speakerentity    Unknown.
 * @param origin        Sound origin.
 * @param dir            Sound direction.
 * @param updatePos        Unknown (updates positions?)
 * @param soundtime        Alternate time to play sound for.
 * @noreturn
 * @error                Invalid client index.
 */
stock EmitSoundToAll(const String:sample[],
                 
entity SOUND_FROM_PLAYER,
                 
channel SNDCHAN_AUTO,
                 
level SNDLEVEL_NORMAL,
                 
flags SND_NOFLAGS,
                 
Float:volume SNDVOL_NORMAL,
                 
pitch SNDPITCH_NORMAL,
                 
speakerentity = -1,
                 const 
Float:origin[3] = NULL_VECTOR,
                 const 
Float:dir[3] = NULL_VECTOR,
                 
bool:updatePos true,
                 
Float:soundtime 0.0
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-19-2007 , 09:14   Re: Playing Sound to All Clients
Reply With Quote #3

Code:
 * @error                Invalid client index.
How can this function throw a invalid client index error? There isn't a client parameter.
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-19-2007 , 18:23   Re: Playing Sound to All Clients
Reply With Quote #4

yeah the problem i've experienced with EmitSoundToAll is that the sound plays very low, like it's barely audible.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
BAILOPAN
Join Date: Jan 2004
Old 09-20-2007 , 01:06   Re: Playing Sound to All Clients
Reply With Quote #5

There are a bunch of sound emittance functions in sdktools and most of them let you tweak the volume. I'm not too great with client side coding (and sound falls into that area) but I'm pretty sure the difference between them is spatial ambiance, for example emitting to a player is different from emitting to an entity.

Thus the ClientCommand + playgamesound method might be better.
__________________
egg
BAILOPAN is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-21-2007 , 18:23   Re: Playing Sound to All Clients
Reply With Quote #6

Quote:
Originally Posted by SamuraiBarbi View Post
yeah the problem i've experienced with EmitSoundToAll is that the sound plays very low, like it's barely audible.
I have had the same problems but EmitSoundToClient() is pretty reliable. JUst iterate over all the active players and use EmitSoundToClient() on each.

The problem with using the client command "play" is that there seems to be only one possible at a time and it also will override some "in-game" sounds.
dalto is offline
sumguy14
Senior Member
Join Date: Apr 2006
Old 09-21-2007 , 20:54   Re: Playing Sound to All Clients
Reply With Quote #7

You can use playgamesound to emit multiple sounds at once.
__________________
Don't think of them as bugs think of them as unexpected features
sumguy14 is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-21-2007 , 22:41   Re: Playing Sound to All Clients
Reply With Quote #8

Thx for the tips guys, i will certainly rewrite the code i've done that's using "play". I have noticed the problem with playing multiple sounds using "play" and I'm glad you guys have suggested those workarounds.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode