Raised This Month: $ Target: $400
 0% 

TF2 suicide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lyric
Veteran Member
Join Date: Sep 2012
Old 04-02-2013 , 18:09   TF2 suicide
Reply With Quote #1

is there anything now that i can use to make it play sound clip when someone does suicide in tf2? either by suicide taunts or the kill/explode keybind? thanks:c rab:
__________________
lyric is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-02-2013 , 19:45   Re: TF2 suicide
Reply With Quote #2

Code:
public OnPluginStart()
{
    AddCommandListener(Suicide, "kill");
    AddCommandListener(Suicide, "explode");
}

public Action:Suicide(client, const String:command[], args)
{
          //Do something
}
Here's an example of hooking Suicide, etc.
Drixevel is offline
lyric
Veteran Member
Join Date: Sep 2012
Old 04-03-2013 , 17:21   Re: TF2 suicide
Reply With Quote #3

Quote:
Originally Posted by r3dw3r3w0lf View Post
Code:
public OnMapStart()
{
    AddFileToDownloadsTable("sound/custom/suicide.mp3");
	PrecacheSound("custom/suicide.mp3");
}

public OnPluginStart()
{
    AddCommandListener(Suicide, "kill");
    AddCommandListener(Suicide, "explode");
}

public Action:Suicide(client, const String:command[], args)
{
          //Do something
}
Here's an example of hooking Suicide, etc.
Maybe that will make it add the sound file to download tables?
__________________
lyric is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 04-04-2013 , 02:17   Re: TF2 suicide
Reply With Quote #4

Yep. EmitSoundToClient(client, "custom/suicide.mp3"); in the Suicide callback to play the sound.

Keep in mind, though, that method (hooking commands) doesn't check if the command actually worked, e.g. they're actually alive when using it or aren't spamming it too much. You can use event hooks instead, for more accuracy, and a wider range; this script, for example, also works on Kamikaze (as you requested) as well as fall damage deaths, self-damage, etc.

PHP Code:
#include <tf2_stocks>
public OnPluginStart()
{
    
HookEvent("player_death"Event_DeathEventHookMode_Post);
}

public 
OnMapStart()
{
    
AddFileToDownloadsTable("sound/custom/suicide.mp3");
    
PrecacheSound("custom/suicide.mp3"true);
}

public 
Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
GetEventInt(event"death_flags") & TF_DEATHFLAG_DEADRINGER) return;
    new 
victim GetClientOfUserId(GetEventInt(event"userid")), attacker GetClientOfUserId(GetEventInt(event"attacker"));
    if (!
attacker || victim == attacker)
    {
        
EmitSoundToClient(victim"custom/suicide.mp3");
    }

__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 04-04-2013 at 02:18.
MasterOfTheXP is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-04-2013 , 13:19   Re: TF2 suicide
Reply With Quote #5

Quote:
Originally Posted by MasterOfTheXP View Post
Yep. EmitSoundToClient(client, "custom/suicide.mp3"); in the Suicide callback to play the sound.

Keep in mind, though, that method (hooking commands) doesn't check if the command actually worked, e.g. they're actually alive when using it or aren't spamming it too much. You can use event hooks instead, for more accuracy, and a wider range; this script, for example, also works on Kamikaze (as you requested) as well as fall damage deaths, self-damage, etc.

PHP Code:
#include <tf2_stocks>
public OnPluginStart()
{
    
HookEvent("player_death"Event_DeathEventHookMode_Post);
}

public 
OnMapStart()
{
    
AddFileToDownloadsTable("sound/custom/suicide.mp3");
    
PrecacheSound("custom/suicide.mp3"true);
}

public 
Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
GetEventInt(event"death_flags") & TF_DEATHFLAG_DEADRINGER) return;
    new 
victim GetClientOfUserId(GetEventInt(event"userid")), attacker GetClientOfUserId(GetEventInt(event"attacker"));
    if (!
attacker || victim == attacker)
    {
        
EmitSoundToClient(victim"custom/suicide.mp3");
    }

Psst, don't look now but customkill and TF_CUSTOM_SUICIDE are calling to you.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
lyric
Veteran Member
Join Date: Sep 2012
Old 04-04-2013 , 15:11   Re: TF2 suicide
Reply With Quote #6

works perfectly Master thanks
__________________
lyric is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-04-2013 , 16:19   Re: TF2 suicide
Reply With Quote #7

I couldn't write this earlier, because I was on a strict 3pm EDT deadline (for an hour long meeting), but this should work for suicides:

PHP Code:
#include <sdktools>
#include <tf2_stocks>

#define SOUND "custom/suicide.mp3"

public OnPluginStart()
{
    
HookEvent("player_death"Event_Player_Death);
}

public 
OnMapStart()
{
    
PrecacheSound(SOUNDtrue);

    
decl String:soundString[PLATFORM_MAX_PATH];
    
Format(soundStringsizeof(soundString), "sound/%s"SOUND);
    
AddFileToDownloadsTable(soundString);
}

public 
Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
GetEventInt(event"customkill") == TF_CUSTOM_SUICIDE)
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if (
client && client <= MaxClients && IsClientInGame(client))
        {
            
EmitSoundToClient(clientSOUND);
        }
    }

__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-04-2013 at 16:22.
Powerlord is offline
lyric
Veteran Member
Join Date: Sep 2012
Old 04-04-2013 , 20:15   Re: TF2 suicide
Reply With Quote #8

@Powerlord

is there something different about your version that I should know? I tried Masters version and it seems to play the sound when I suicide taunt with the soldiers pick ax and when I die by sticky/failrocket jump. i dont' know what else would be needed?
__________________
lyric is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-04-2013 , 20:17   Re: TF2 suicide
Reply With Quote #9

Quote:
Originally Posted by lyric View Post
@Powerlord

is there something different about your version that I should know? I tried Masters version and it seems to play the sound when I suicide taunt with the soldiers pick ax and when I die by sticky/failrocket jump. i dont' know what else would be needed?
Mine only picks up ones marked as suicides by the game engine. I can't tell you for sure which ones it does and doesn't count, though.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 03:18.


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