Hello!
Please help me play my sounds of death. I can block the standard death sounds (they are not heard and the message public Action
eathSound appears in the chat).
Public Event_PlayerDeath does not work. I know that the delusional way, but there are no other options.
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#pragma semicolon 1
#define MAX_PATH_LENGTH 128
...
public OnPluginStart()
{
AddNormalSoundHook(DeathSound);
HookEvent("player_death", Event_PlayerDeath);
}
...
public Action:DeathSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
if(StrContains(sample, "death", false) != -1)
{
PrintToChatAll("\x04public Action:DeathSound");
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:path[MAX_PATH_LENGTH];
PrintToChatAll("\x04public Event_PlayerDeath");
Format(path, sizeof(path), "death%d.mp3", GetRandomInt(1, 5));
EmitSoundToAll(path);
}