As of SourceMod 1.6.1, this extension is obsolete. Use SDKTools instead.
2013-11-19: Fixed a memory leak, added AMBuild packaging system. CS:GO, Blade Symphony, Insurgency, and DOTA2 versions have been rebuilt against the new SDKs, although note that the latter 3 may need separate recompiling as they were built against SourceMod 1.5 despite being games that require SourceMod 1.6.
2013-10-10 (u3): Added new stock: EmitAmbientGameSound to readgamesounds.inc
2013-10-09: Make sure to grab the updated readgamesounds.inc from this post.[/SIZE] It fixes a bug in the EmitGameSoundToAll stock. You
will need to recompile it against the new version.
Read Game Sounds is an extension that provides 1 native and 3 stocks that plugins can use.
The native is
Code:
native bool:GetGameSoundParams(const String:gameSound[], &channel, &soundLevel, &Float:volume, &pitch, String:sample[], maxlength, entity=SOUND_FROM_PLAYER);
This native takes the name of a sound listed in one the game_sound text files for a game and puts the channel, sound level, volume, pitch, and one of its sample names in the variables provided. It also returns true or false based on whether it was successful or not.
For TF2, you could call this with something like "Announcer.SD_Rocket_PreLaunch" as the game sound to retrieve one of the Announcer's Special Delivery map start lines... randomly, because it has a rndwave section.
This native does not precache the sound it returns.
The 3 stocks are:
Code:
stock bool:EmitGameSound(const clients[],
numClients,
const String:gameSound[],
entity = SOUND_FROM_PLAYER,
flags = SND_NOFLAGS,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
stock bool:EmitGameSoundToClient(client,
const String:gameSound[],
entity = SOUND_FROM_PLAYER,
flags = SND_NOFLAGS,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
stock bool:EmitGameSoundToAll(const String:gameSound[],
entity = SOUND_FROM_PLAYER,
flags = SND_NOFLAGS,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
These are similar to the existing EmitSound, EmitSoundToClient, and EmitSoundToAll calls, but they take a gameSound and retrieve the parameters mentioned in the native above.
Note that these function DO precache the sample and are recommended instead of calling GetGameSoundParams directly.
I've compiled this extension for every game under the sun and tested it a bit in TF2. The compile size is about the same for every game
except CS:GO on Linux... not sure why, but it's nearly 10 times the size of the others.
For those of you who are developers, this extension just wraps the Source SDK's ISoundEmitterSystemBase's GetSoundIndex and GetSoundParametersEx functions.