View Single Post
Author Message
Drimacus
Member
Join Date: Jun 2011
Old 02-17-2024 , 16:33   Play my sound of death
Reply With Quote #1

Hello!
Please help me play my sounds of death. I can block the standard death sounds (they are not heard and the message public ActioneathSound 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], &numClientsString: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(pathsizeof(path), "death%d.mp3"GetRandomInt(15));
    
EmitSoundToAll(path);


Last edited by Drimacus; 02-17-2024 at 16:55.
Drimacus is offline