MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / EmitSoundEntry

Function EmitSoundEntry

extensions/sdktools/vsound.cpp:1268–1423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1266}
1267
1268static cell_t EmitSoundEntry(IPluginContext *pContext, const cell_t *params)
1269{
1270#if SOURCE_ENGINE < SE_PORTAL2
1271 return pContext->ThrowNativeError("EmitSoundEntry is not available in this game.");
1272#else
1273 cell_t *addr, *cl_array;
1274 CellRecipientFilter crf;
1275 unsigned int numClients;
1276 int client;
1277 IGamePlayer *pPlayer = NULL;
1278
1279 pContext->LocalToPhysAddr(params[1], &cl_array);
1280 numClients = params[2];
1281
1282 /* Client validation */
1283 for (unsigned int i = 0; i < numClients; i++)
1284 {
1285 client = cl_array[i];
1286 pPlayer = playerhelpers->GetGamePlayer(client);
1287
1288 if (!pPlayer)
1289 {
1290 return pContext->ThrowNativeError("Client index %d is invalid", client);
1291 }
1292 else if (!pPlayer->IsInGame()) {
1293 return pContext->ThrowNativeError("Client %d is not in game", client);
1294 }
1295 }
1296
1297 crf.Initialize(cl_array, numClients);
1298
1299 char *soundEntry;
1300 pContext->LocalToString(params[3], &soundEntry);
1301
1302 char *sample;
1303 pContext->LocalToString(params[4], &sample);
1304
1305 // By default, we want the hash to equal maxint
1306 unsigned int soundEntryHash = -1;
1307
1308 // We only generate a hash if the sample is not the same as the sound entry and the sound entry is not empty.
1309 if (strcmp(soundEntry, sample) != 0 && strcmp(soundEntry, "") != 0)
1310 soundEntryHash = GenerateSoundEntryHash(soundEntry);
1311
1312 int entity = SoundReferenceToIndex(params[5]);
1313 int channel = params[6];
1314 int level = params[7];
1315 int seed = params[8];
1316 int flags = params[9];
1317 float vol = sp_ctof(params[10]);
1318 int pitch = params[11];
1319 int speakerentity = params[12];
1320
1321 Vector *pOrigin = NULL, origin;
1322 Vector *pDir = NULL, dir;
1323
1324 pContext->LocalToPhysAddr(params[13], &addr);
1325 if (addr != pContext->GetNullRef(SP_NULL_VECTOR))

Callers

nothing calls this directly

Calls 7

GenerateSoundEntryHashFunction · 0.85
SoundReferenceToIndexFunction · 0.85
GetGamePlayerMethod · 0.80
IsInGameMethod · 0.80
IsDedicatedServerMethod · 0.80
InitializeMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected