plugins/include/sdktools_sound.inc
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 17 09:28:46 2008 +0000 (2008-04-17)
changeset 2013 5cf82fea0177
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Gah, finalized the revised ILibrarySys::GetFileExtension() code
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     5
 * =============================================================================
ds@1952
     6
 *
ds@1952
     7
 * This file is part of the SourceMod/SourcePawn SDK.
ds@1952
     8
 *
ds@1952
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    11
 * Free Software Foundation.
ds@1952
    12
 * 
ds@1952
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    16
 * details.
ds@1952
    17
 *
ds@1952
    18
 * You should have received a copy of the GNU General Public License along with
ds@1952
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    20
 *
ds@1952
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    28
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    29
 *
ds@1952
    30
 * Version: $Id$
ds@1952
    31
 */
ds@1952
    32
ds@1952
    33
#if defined _sdktools_sound_included
ds@1952
    34
  #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _sdktools_sound_included
ds@1952
    37
ds@1952
    38
/**
ds@1952
    39
 * Sound should be from the target client.
ds@1952
    40
 */
ds@1952
    41
#define SOUND_FROM_PLAYER		-2
ds@1952
    42
ds@1952
    43
/**
ds@1952
    44
 * Sound should be from the listen server player.
ds@1952
    45
 */
ds@1952
    46
#define SOUND_FROM_LOCAL_PLAYER	-1
ds@1952
    47
ds@1952
    48
/**
ds@1952
    49
 * Sound is from the world.
ds@1952
    50
 */
ds@1952
    51
#define SOUND_FROM_WORLD		0
ds@1952
    52
ds@1952
    53
/**
ds@1952
    54
 * Sound channels.
ds@1952
    55
 */
ds@1952
    56
enum
ds@1952
    57
{
ds@1952
    58
	SNDCHAN_REPLACE = -1,		/**< Unknown */
ds@1952
    59
	SNDCHAN_AUTO = 0,			/**< Auto */
ds@1952
    60
	SNDCHAN_WEAPON = 1,			/**< Weapons */
ds@1952
    61
	SNDCHAN_VOICE = 2,			/**< Voices */
ds@1952
    62
	SNDCHAN_ITEM = 3,			/**< Items */
ds@1952
    63
	SNDCHAN_BODY = 4,			/**< Player? */
ds@1952
    64
	SNDCHAN_STREAM = 5,			/**< "Stream channel from the static or dynamic area" */
ds@1952
    65
	SNDCHAN_STATIC = 6,			/**< "Stream channel from the static area" */
ds@1952
    66
	SNDCHAN_VOICE_BASE = 7,		/**< "Channel for network voice data" */
ds@1952
    67
	SNDCHAN_USER_BASE = 135		/**< Anything >= this is allocated to game code */
ds@1952
    68
};
ds@1952
    69
ds@1952
    70
/**
ds@1952
    71
 * Sound flags for the sound emitter system.
ds@1952
    72
 */
ds@1952
    73
enum
ds@1952
    74
{
ds@1952
    75
	SND_NOFLAGS= 0,			/**< Nothing */
ds@1952
    76
	SND_CHANGEVOL = 1,		/**< Change sound volume */
ds@1952
    77
	SND_CHANGEPITCH = 2,	/**< Change sound pitch */
ds@1952
    78
	SND_STOP = 3,			/**< Stop the sound */
ds@1952
    79
	SND_SPAWNING = 4,		/**< Used in some cases for ambients */
ds@1952
    80
	SND_DELAY = 5,			/**< Sound has an initial delay */
ds@1952
    81
	SND_STOPLOOPING = 6,	/**< Stop looping all sounds on the entity */
ds@1952
    82
	SND_SPEAKER = 7,		/**< Being played by a mic through a speaker */
ds@1952
    83
	SND_SHOULDPAUSE = 8,	/**< Pause if game is paused */
ds@1952
    84
};
ds@1952
    85
ds@1952
    86
/**
ds@1952
    87
 * Various predefined sound levels in dB.
ds@1952
    88
 */
ds@1952
    89
enum
ds@1952
    90
{
ds@1952
    91
	SNDLEVEL_NONE = 0,			/**< None */
ds@1952
    92
	SNDLEVEL_RUSTLE = 20,		/**< Rustling leaves */
ds@1952
    93
	SNDLEVEL_WHISPER = 25,		/**< Whispering */
ds@1952
    94
	SNDLEVEL_LIBRARY = 30,		/**< In a library */
ds@1952
    95
	SNDLEVEL_FRIDGE = 45,		/**< Refridgerator */
ds@1952
    96
	SNDLEVEL_HOME = 50,			/**< Average home (3.9 attn) */
ds@1952
    97
	SNDLEVEL_CONVO = 60,		/**< Normal conversation (2.0 attn) */
ds@1952
    98
	SNDLEVEL_DRYER = 60,		/**< Clothes dryer */
ds@1952
    99
	SNDLEVEL_DISHWASHER = 65,	/**< Dishwasher/washing machine (1.5 attn) */
ds@1952
   100
	SNDLEVEL_CAR = 70,			/**< Car or vacuum cleaner (1.0 attn) */
ds@1952
   101
	SNDLEVEL_NORMAL = 75,		/**< Normal sound level */
ds@1952
   102
	SNDLEVEL_TRAFFIC = 75,		/**< Busy traffic (0.8 attn) */
ds@1952
   103
	SNDLEVEL_MINIBIKE = 80,		/**< Mini-bike, alarm clock (0.7 attn) */
ds@1952
   104
	SNDLEVEL_SCREAMING = 90,	/**< Screaming child (0.5 attn) */
ds@1952
   105
	SNDLEVEL_TRAIN = 100,		/**< Subway train, pneumatic drill (0.4 attn) */
ds@1952
   106
	SNDLEVEL_HELICOPTER = 105,	/**< Helicopter */
ds@1952
   107
	SNDLEVEL_SNOWMOBILE = 110,	/**< Snow mobile */
ds@1952
   108
	SNDLEVEL_AIRCRAFT = 120,	/**< Auto horn, aircraft */
ds@1952
   109
	SNDLEVEL_RAIDSIREN = 130,	/**< Air raid siren */
ds@1952
   110
	SNDLEVEL_GUNFIRE = 140,		/**< Gunshot, jet engine (0.27 attn) */
ds@1952
   111
	SNDLEVEL_ROCKET = 180,		/**< Rocket launching (0.2 attn) */
ds@1952
   112
};
ds@1952
   113
ds@1952
   114
#define SNDVOL_NORMAL		1.0		/**< Normal volume */
ds@1952
   115
#define SNDPITCH_NORMAL		100		/**< Normal pitch */
ds@1952
   116
#define SNDPITCH_LOW		95		/**< A low pitch */
ds@1952
   117
#define SNDPITCH_HIGH		120		/**< A high pitch */
ds@1952
   118
#define SNDATTN_NONE		0.0		/**< No attenuation */
ds@1952
   119
#define SNDATTN_NORMAL		0.8		/**< Normal attenuation */
ds@1952
   120
#define SNDATTN_STATIC		1.25	/**< Static attenuation? */
ds@1952
   121
#define SNDATTN_RICOCHET	1.5		/**< Ricochet effect */
ds@1952
   122
#define SNDATTN_IDLE		2.0		/**< Idle attenuation? */
ds@1952
   123
 
ds@1952
   124
/**
ds@1952
   125
 * Prefetches a sound.
ds@1952
   126
 *
ds@1952
   127
 * @param name		Sound file name relative to the "sounds" folder.
ds@1952
   128
 * @noreturn
ds@1952
   129
 */
ds@1952
   130
native PrefetchSound(const String:nane[]);
ds@1952
   131
ds@1952
   132
/**
ds@1952
   133
 * This function is not known to work, and may crash.  You should 
ds@1952
   134
 * not use it.  It is provided for backwards compatibility only.
ds@1952
   135
 *
ds@1952
   136
 * @param name		Sound file name relative to the "sounds" folder.
ds@1952
   137
 * @return			Duration in seconds.
ds@1952
   138
 */
ds@1952
   139
#pragma deprecated Does not work, may crash.
ds@1952
   140
native Float:GetSoundDuration(const String:name[]);
ds@1952
   141
ds@1952
   142
/**
ds@1952
   143
 * Emits an ambient sound.
ds@1952
   144
 *
ds@1952
   145
 * @param name		Sound file name relative to the "sounds" folder.
ds@1952
   146
 * @param pos		Origin of sound.
ds@1952
   147
 * @param entity	Entity index to associate sound with.
ds@1952
   148
 * @param level		Sound level (from 0 to 255).
ds@1952
   149
 * @param flags		Sound flags.
ds@1952
   150
 * @param vol		Volume (from 0.0 to 1.0).
ds@1952
   151
 * @param pitch		Pitch (from 0 to 255).
ds@1952
   152
 * @param delay		Play delay.
ds@1952
   153
 * @noreturn
ds@1952
   154
 */
ds@1952
   155
native EmitAmbientSound(const String:name[],
ds@1952
   156
						const Float:pos[3],
ds@1952
   157
						entity = SOUND_FROM_WORLD,
ds@1952
   158
						level = SNDLEVEL_NORMAL,
ds@1952
   159
						flags = SND_NOFLAGS,
ds@1952
   160
						Float:vol = SNDVOL_NORMAL,
ds@1952
   161
						pitch = SNDPITCH_NORMAL,
ds@1952
   162
						Float:delay = 0.0);
ds@1952
   163
ds@1952
   164
/**
ds@1952
   165
 * Fades a client's volume level toward silence or a given percentage.
ds@1952
   166
 *
ds@1952
   167
 * @param client	Client index.
ds@1952
   168
 * @param percent	Fade percentage.
ds@1952
   169
 * @param outtime	Fade out time, in seconds.
ds@1952
   170
 * @param holdtime	Hold time, in seconds.
ds@1952
   171
 * @param intime	Fade in time, in seconds.
ds@1952
   172
 * @noreturn
ds@1952
   173
 * @error			Invalid client index or client not in game.
ds@1952
   174
 */
ds@1952
   175
native FadeClientVolume(client, Float:percent, Float:outtime, Float:holdtime, Float:intime);
ds@1952
   176
ds@1952
   177
/**
ds@1952
   178
 * Stops a sound.
ds@1952
   179
 *
ds@1952
   180
 * @param entity	Entity index.
ds@1952
   181
 * @param channel	Channel number.
ds@1952
   182
 * @param name		Sound file name relative to the "sounds" folder.
ds@1952
   183
 * @noreturn
ds@1952
   184
 */
ds@1952
   185
native StopSound(entity, channel, const String:name[]);
ds@1952
   186
ds@1952
   187
/**
ds@1952
   188
 * Emits a sound to a list of clients.
ds@1952
   189
 *
ds@1952
   190
 * @param clients		Array of client indexes.
ds@1952
   191
 * @param numClients	Number of clients in the array.
ds@1952
   192
 * @param sample		Sound file name relative to the "sounds" folder.
ds@1952
   193
 * @param entity		Entity to emit from.
ds@1952
   194
 * @param channel		Channel to emit with.
ds@1952
   195
 * @param level			Sound level.
ds@1952
   196
 * @param flags			Sound flags.
ds@1952
   197
 * @param volume		Sound volume.
ds@1952
   198
 * @param pitch			Sound pitch.
ds@1952
   199
 * @param speakerentity	Unknown.
ds@1952
   200
 * @param origin		Sound origin.
ds@1952
   201
 * @param dir			Sound direction.
ds@1952
   202
 * @param updatePos		Unknown (updates positions?)
ds@1952
   203
 * @param soundtime		Alternate time to play sound for.
ds@1952
   204
 * @param ...			Optional list of Float[3] arrays to specify additional origins.
ds@1952
   205
 * @noreturn
ds@1952
   206
 * @error				Invalid client index.
ds@1952
   207
 */
ds@1952
   208
native EmitSound(const clients[],
ds@1952
   209
				 numClients,
ds@1952
   210
				 const String:sample[],
ds@1952
   211
				 entity = SOUND_FROM_PLAYER,
ds@1952
   212
				 channel = SNDCHAN_AUTO,
ds@1952
   213
				 level = SNDLEVEL_NORMAL,
ds@1952
   214
				 flags = SND_NOFLAGS,
ds@1952
   215
				 Float:volume = SNDVOL_NORMAL,
ds@1952
   216
				 pitch = SNDPITCH_NORMAL,
ds@1952
   217
				 speakerentity = -1,
ds@1952
   218
				 const Float:origin[3] = NULL_VECTOR,
ds@1952
   219
				 const Float:dir[3] = NULL_VECTOR,
ds@1952
   220
				 bool:updatePos = true,
ds@1952
   221
				 Float:soundtime = 0.0,
ds@1952
   222
				 any:...);
ds@1952
   223
ds@1952
   224
/**
ds@1952
   225
 * Emits a sentence to a list of clients.
ds@1952
   226
 *
ds@1952
   227
 * @param clients		Array of client indexes.
ds@1952
   228
 * @param numClients	Number of clients in the array.
ds@1952
   229
 * @param sentence		Sentence index (from PrecacheSenteFile).
ds@1952
   230
 * @param entity		Entity to emit from.
ds@1952
   231
 * @param channel		Channel to emit with.
ds@1952
   232
 * @param level			Sound level.
ds@1952
   233
 * @param flags			Sound flags.
ds@1952
   234
 * @param volume		Sound volume.
ds@1952
   235
 * @param pitch			Sound pitch.
ds@1952
   236
 * @param speakerentity	Unknown.
ds@1952
   237
 * @param origin		Sound origin.
ds@1952
   238
 * @param dir			Sound direction.
ds@1952
   239
 * @param updatePos		Unknown (updates positions?)
ds@1952
   240
 * @param soundtime		Alternate time to play sound for.
ds@1952
   241
 * @param ...			Optional list of Float[3] arrays to specify additional origins.
ds@1952
   242
 * @noreturn
ds@1952
   243
 * @error				Invalid client index.
ds@1952
   244
 */
ds@1952
   245
native EmitSentence(const clients[],
ds@1952
   246
				 numClients,
ds@1952
   247
				 sentence,
ds@1952
   248
				 entity,
ds@1952
   249
				 channel = SNDCHAN_AUTO,
ds@1952
   250
				 level = SNDLEVEL_NORMAL,
ds@1952
   251
				 flags = SND_NOFLAGS,
ds@1952
   252
				 Float:volume = SNDVOL_NORMAL,
ds@1952
   253
				 pitch = SNDPITCH_NORMAL,
ds@1952
   254
				 speakerentity = -1,
ds@1952
   255
				 const Float:origin[3] = NULL_VECTOR,
ds@1952
   256
				 const Float:dir[3] = NULL_VECTOR,
ds@1952
   257
				 bool:updatePos = true,
ds@1952
   258
				 Float:soundtime = 0.0,
ds@1952
   259
				 any:...);
ds@1952
   260
ds@1952
   261
/**
ds@1952
   262
 * Called when an ambient sound is about to be emitted to one or more clients.
ds@1952
   263
 *
ds@1952
   264
 * NOTICE: all parameters can be overwritten to modify the default behavior.
ds@1952
   265
 *
ds@1952
   266
 * @param sample	Sound file name relative to the "sounds" folder.
ds@1952
   267
 * @param entity	Entity index associated to the sound.
ds@1952
   268
 * @param volume	Volume (from 0.0 to 1.0).
ds@1952
   269
 * @param level		Sound level (from 0 to 255).
ds@1952
   270
 * @param pitch		Pitch (from 0 to 255).
ds@1952
   271
 * @param pos		Origin of sound.
ds@1952
   272
 * @param flags		Sound flags.
ds@1952
   273
 * @param delay		Play delay.
ds@1952
   274
 * @return		Plugin_Continue to allow the sound to be played, Plugin_Stop to block it, 
ds@1952
   275
 *			  Plugin_Changed when any parameter has been modified.
ds@1952
   276
 */
ds@1952
   277
functag AmbientSHook Action:public(String:sample[PLATFORM_MAX_PATH], &entity, &Float:volume, &level, &pitch, Float:pos[3], &flags, &Float:delay);
ds@1952
   278
ds@1952
   279
/**
ds@1952
   280
 * Called when a sound is going to be emitted to one or more clients.
ds@1952
   281
 * NOTICE: all params can be overwritten to modify the default behaviour.
ds@1952
   282
 *
ds@1952
   283
 * @param clients		Array of client indexes.
ds@1952
   284
 * @param numClients		Number of clients in the array (modify this value if you add/remove elements from the client array).
ds@1952
   285
 * @param sample		Sound file name relative to the "sounds" folder.
ds@1952
   286
 * @param entity		Entity emitting the sound.
ds@1952
   287
 * @param channel		Channel emitting the sound.
ds@1952
   288
 * @param volume		Sound volume.
ds@1952
   289
 * @param level			Sound level.
ds@1952
   290
 * @param pitch			Sound pitch.
ds@1952
   291
 * @param flags			Sound flags.
ds@1952
   292
 * @return			Plugin_Continue to allow the sound to be played, Plugin_Stop to block it, 
ds@1952
   293
 *				  Plugin_Changed when any parameter has been modified.
ds@1952
   294
 */
ds@1952
   295
functag NormalSHook Action:public(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags);
ds@1952
   296
ds@1952
   297
/**
ds@1952
   298
 * Hooks all played ambient sounds.
ds@1952
   299
 *
ds@1952
   300
 * @param hook		Function to use as a hook.
ds@1952
   301
 * @noreturn
ds@1952
   302
 * @error		Invalid function hook.
ds@1952
   303
 */
ds@1952
   304
native AddAmbientSoundHook(AmbientSHook:hook);
ds@1952
   305
ds@1952
   306
/**
ds@1952
   307
 * Hooks all played normal sounds.
ds@1952
   308
 *
ds@1952
   309
 * @param hook		Function to use as a hook.
ds@1952
   310
 * @noreturn
ds@1952
   311
 * @error		Invalid function hook.
ds@1952
   312
 */
ds@1952
   313
native AddNormalSoundHook(NormalSHook:hook);
ds@1952
   314
ds@1952
   315
/**
ds@1952
   316
 * Unhooks all played ambient sounds.
ds@1952
   317
 *
ds@1952
   318
 * @param hook		Function used for the hook.
ds@1952
   319
 * @noreturn
ds@1952
   320
 * @error		Invalid function hook.
ds@1952
   321
 */
ds@1952
   322
native RemoveAmbientSoundHook(AmbientSHook:hook);
ds@1952
   323
ds@1952
   324
/**
ds@1952
   325
 * Unhooks all played normal sounds.
ds@1952
   326
 *
ds@1952
   327
 * @param hook		Function used for the hook.
ds@1952
   328
 * @noreturn
ds@1952
   329
 * @error		Invalid function hook.
ds@1952
   330
 */
ds@1952
   331
native RemoveNormalSoundHook(NormalSHook:hook);
ds@1952
   332
				 
ds@1952
   333
/**
ds@1952
   334
 * Wrapper to emit sound to one client.
ds@1952
   335
 *
ds@1952
   336
 * @param client		Client index.
ds@1952
   337
 * @param sample		Sound file name relative to the "sounds" folder.
ds@1952
   338
 * @param entity		Entity to emit from.
ds@1952
   339
 * @param channel		Channel to emit with.
ds@1952
   340
 * @param level			Sound level.
ds@1952
   341
 * @param flags			Sound flags.
ds@1952
   342
 * @param volume		Sound volume.
ds@1952
   343
 * @param pitch			Sound pitch.
ds@1952
   344
 * @param speakerentity	Unknown.
ds@1952
   345
 * @param origin		Sound origin.
ds@1952
   346
 * @param dir			Sound direction.
ds@1952
   347
 * @param updatePos		Unknown (updates positions?)
ds@1952
   348
 * @param soundtime		Alternate time to play sound for.
ds@1952
   349
 * @noreturn
ds@1952
   350
 * @error				Invalid client index.
ds@1952
   351
 */
ds@1952
   352
stock EmitSoundToClient(client,
ds@1952
   353
				 const String:sample[],
ds@1952
   354
				 entity = SOUND_FROM_PLAYER,
ds@1952
   355
				 channel = SNDCHAN_AUTO,
ds@1952
   356
				 level = SNDLEVEL_NORMAL,
ds@1952
   357
				 flags = SND_NOFLAGS,
ds@1952
   358
				 Float:volume = SNDVOL_NORMAL,
ds@1952
   359
				 pitch = SNDPITCH_NORMAL,
ds@1952
   360
				 speakerentity = -1,
ds@1952
   361
				 const Float:origin[3] = NULL_VECTOR,
ds@1952
   362
				 const Float:dir[3] = NULL_VECTOR,
ds@1952
   363
				 bool:updatePos = true,
ds@1952
   364
				 Float:soundtime = 0.0)
ds@1952
   365
{
ds@1952
   366
	new clients[1];
ds@1952
   367
	clients[0] = client;
ds@1952
   368
	/* Save some work for SDKTools and remove SOUND_FROM_PLAYER references */
ds@1952
   369
	entity = (entity == SOUND_FROM_PLAYER) ? client : entity;
ds@1952
   370
	EmitSound(clients, 1, sample, entity, channel, 
ds@1952
   371
		level, flags, volume, pitch, speakerentity,
ds@1952
   372
		origin, dir, updatePos, soundtime);
ds@1952
   373
}
ds@1952
   374
ds@1952
   375
/**
ds@1952
   376
 * Wrapper to emit sound to all clients.
ds@1952
   377
 *
ds@1952
   378
 * @param sample		Sound file name relative to the "sounds" folder.
ds@1952
   379
 * @param entity		Entity to emit from.
ds@1952
   380
 * @param channel		Channel to emit with.
ds@1952
   381
 * @param level			Sound level.
ds@1952
   382
 * @param flags			Sound flags.
ds@1952
   383
 * @param volume		Sound volume.
ds@1952
   384
 * @param pitch			Sound pitch.
ds@1952
   385
 * @param speakerentity	Unknown.
ds@1952
   386
 * @param origin		Sound origin.
ds@1952
   387
 * @param dir			Sound direction.
ds@1952
   388
 * @param updatePos		Unknown (updates positions?)
ds@1952
   389
 * @param soundtime		Alternate time to play sound for.
ds@1952
   390
 * @noreturn
ds@1952
   391
 * @error				Invalid client index.
ds@1952
   392
 */
ds@1952
   393
stock EmitSoundToAll(const String:sample[],
ds@1952
   394
				 entity = SOUND_FROM_PLAYER,
ds@1952
   395
				 channel = SNDCHAN_AUTO,
ds@1952
   396
				 level = SNDLEVEL_NORMAL,
ds@1952
   397
				 flags = SND_NOFLAGS,
ds@1952
   398
				 Float:volume = SNDVOL_NORMAL,
ds@1952
   399
				 pitch = SNDPITCH_NORMAL,
ds@1952
   400
				 speakerentity = -1,
ds@1952
   401
				 const Float:origin[3] = NULL_VECTOR,
ds@1952
   402
				 const Float:dir[3] = NULL_VECTOR,
ds@1952
   403
				 bool:updatePos = true,
ds@1952
   404
				 Float:soundtime = 0.0)
ds@1952
   405
{
ds@1952
   406
	new maxClients = GetMaxClients();
ds@1952
   407
	new clients[maxClients];
ds@1952
   408
	new total = 0;
ds@1952
   409
	
ds@1952
   410
	for (new i=1; i<=maxClients; i++)
ds@1952
   411
	{
ds@1952
   412
		if (IsClientInGame(i))
ds@1952
   413
		{
ds@1952
   414
			clients[total++] = i;
ds@1952
   415
		}
ds@1952
   416
	}
ds@1952
   417
	
ds@1952
   418
	if (!total)
ds@1952
   419
	{
ds@1952
   420
		return;
ds@1952
   421
	}
ds@1952
   422
	
ds@1952
   423
	EmitSound(clients, total, sample, entity, channel, 
ds@1952
   424
		level, flags, volume, pitch, speakerentity,
ds@1952
   425
		origin, dir, updatePos, soundtime);
ds@1952
   426
}
ds@1952
   427
ds@1952
   428
/**
ds@1952
   429
 * Converts an attenuation value to a sound level.  
ds@1952
   430
 * This function is from the HL2SDK.
ds@1952
   431
 *
ds@1952
   432
 * @param attn		Attenuation value.
ds@1952
   433
 * @return			Integer sound level.
ds@1952
   434
 */
ds@1952
   435
stock ATTN_TO_SNDLEVEL(Float:attn)
ds@1952
   436
{
ds@1952
   437
	if (attn > 0.0)
ds@1952
   438
	{
ds@1952
   439
		return RoundFloat(50.0 + (20.0 / attn));
ds@1952
   440
	}
ds@1952
   441
	return 0;
ds@1952
   442
}