Raised This Month: $51 Target: $400
 12% 

Play my sound of death


Post New Thread Reply   
 
Thread Tools Display Modes
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
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-18-2024 , 01:24   Re: Play my sound of death
Reply With Quote #2

https://sm.alliedmods.net/new-api/ha.../PrecacheSound

Also, look other plugins source code. For examples.
__________________
Do not Private Message @me
Bacardi is offline
Drimacus
Member
Join Date: Jun 2011
Old 02-18-2024 , 02:20   Re: Play my sound of death
Reply With Quote #3

There is a sound pre-sharpening.
PHP Code:
public OnMapStart()
{
    
decl String:file[MAX_PATH_LENGTH];
    
// Precache
    
for (new 1<= 5i++)
    {
        
Format(filesizeof(file), "death%d.mp3"i);
        
PrecacheSound(filetrue);
    }


Last edited by Drimacus; 02-18-2024 at 02:21.
Drimacus is offline
Drimacus
Member
Join Date: Jun 2011
Old 02-18-2024 , 05:49   Re: Play my sound of death
Reply With Quote #4

That's how it works.
PHP Code:
public Action:DeathSound(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
    if (
StrContains(sample"death"false) != -1)
    {
        
decl String:file[MAX_PATH_LENGTH];
        
Format(filesizeof(file), "death%d.wav"GetRandomInt(15));
        
EmitSoundToAll(file);

        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

Can you tell me how to get a specific player in "public ActioneathSound" to play a sound for him?
PHP Code:
new client GetClientOfUserId(GetEventInt(event"userid")); 
doesn't work because of missing event.
Drimacus is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-18-2024 , 06:19   Re: Play my sound of death
Reply With Quote #5

Usually there is "userid" in player_death.
Would help if you tell us, what is a game?

There are many many hl2 games and have own differences.
__________________
Do not Private Message @me
Bacardi is offline
Drimacus
Member
Join Date: Jun 2011
Old 02-18-2024 , 09:02   Re: Play my sound of death
Reply With Quote #6

Game Counter-Strike: Source.
Drimacus is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-18-2024 , 10:20   Re: Play my sound of death
Reply With Quote #7

Ok.
Not sure why you not get it work, I have not seen your whole plugin.

I can't help much for now, I do other things.

Anyway, have you try similiar plugins ?
https://www.sourcemod.net/plugins.ph...Sound&search=1
__________________
Do not Private Message @me
Bacardi is offline
Drimacus
Member
Join Date: Jun 2011
Old 02-19-2024 , 02:15   Re: Play my sound of death
Reply With Quote #8

Solved.
PHP Code:
public OnPluginStart()
{
    
AddNormalSoundHook(DeathSound);
}

public 
Action:DeathSound(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
    if (
StrContains(sample"kevlar"false) != -1)
    {
        
FormatEx(samplesizeof(sample), "hitkill/hit%d.wav"GetRandomInt(1GetConVarInt(cvarHitSoundsCount)));
        return 
Plugin_Changed;
    }
    if (
StrContains(sample"death"false) != -1)
    {
        
FormatEx(samplesizeof(sample), "hitkill/death%d.wav"GetRandomInt(1GetConVarInt(cvarDeathSoundsCount)));
        return 
Plugin_Changed;
    }
    if (
StrContains(sample"headshot"false) != -1)
    {
        
FormatEx(samplesizeof(sample), "hitkill/headshot%d.wav"GetRandomInt(1GetConVarInt(cvarHeadshotSoundsCount)));
        return 
Plugin_Changed;
    }

    return 
Plugin_Continue;

Drimacus is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode