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

[L4D2]Headshot Sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-23-2014 , 08:27   [L4D2]Headshot Sound
Reply With Quote #1

Looking for a simple plugin to play a sound everytime a headshot is made
MasterMind420 is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-23-2014 , 09:02   Re: [L4D2]Headshot Sound
Reply With Quote #2

What sound? To everyone or to the person who headshots?
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-23-2014 , 16:01   Re: [L4D2]Headshot Sound
Reply With Quote #3

Quote:
Originally Posted by DJ Data View Post
What sound? To everyone or to the person who headshots?
just the person who gets the headshot, want players to know they got one, without spamming the chat
MasterMind420 is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-23-2014 , 18:30   Re: [L4D2]Headshot Sound
Reply With Quote #4

Alright, ill see what i can do
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-23-2014 , 19:34   Re: [L4D2]Headshot Sound
Reply With Quote #5

Quote:
Originally Posted by DJ Data View Post
Alright, ill see what i can do
thanks appreciate it, I attempted to rip apart event sounds plugin and headshots in a row to figure it out, couldnt imagine it would take much code to do, but alas my coding skills suck so....thanks again.
MasterMind420 is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 09-24-2014 , 16:48   Re: [L4D2]Headshot Sound
Reply With Quote #6

Quote:
Originally Posted by MasterMind420 View Post
thanks appreciate it, I attempted to rip apart event sounds plugin and headshots in a row to figure it out, couldnt imagine it would take much code to do, but alas my coding skills suck so....thanks again.
Well, if you guys don't mind, I just wrote a plugin for MasterMind's request.

Untested, but this should work.

I don't really know if this sound is appropriate for representing a Headshot, but you can easily change within the code.

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

#define SOUND_HEADSHOT        "UI/LittleReward.wav"

public Plugin:myinfo = { 
    
name        "[L4D2] Headshot sounds"
    
author        "DeathChaos25"
    
description    "Players will hear a sound when they perform a Headshot"
    
version        "1.0"
    
url        "https://forums.alliedmods.net/showthread.php?t=248751" 
}

public 
OnPluginStart()
{
    
HookEvent("player_death"PlayerDeath_Event
    
HookEvent("infected_death"InfectedDeath_Event
    
HookEvent("hunter_headshot"HunterHeadshot_Event
}

public 
OnMapStart()
{
    
PrecacheSound(SOUND_HEADSHOT
}
public 
PlayerDeath_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"attacker")) 
    new 
bool:IsHeadshot GetEventBool(event"headshot"
    if (
IsSurvivor(client) && IsHeadshot == true) {
        
PlaySound(clientSOUND_HEADSHOT)
    }
}

public 
InfectedDeath_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"attacker")) 
    new 
bool:IsHeadshot GetEventBool(event"headshot"
    
    if (
IsSurvivor(client) && IsHeadshot == true) {
        
PlaySound(clientSOUND_HEADSHOT)
    }
}

public 
HunterHeadshot_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid")) 
    
    if (
IsSurvivor(client)) {
        
PlaySound(clientSOUND_HEADSHOT)
    }
}

stock bool:IsSurvivor(client)
{
    if (
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        return 
true;
    }
    return 
false;
}

/* Taken from Gear Transfer, credits to SilverShot for that*/
stock PlaySound(client, const String:s_Sound[32]) {
    
EmitSoundToClient(clients_SoundSOUND_FROM_PLAYERSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGSSNDVOL_NORMALSNDPITCH_NORMAL, -1NULL_VECTORNULL_VECTORtrue0.0

And if it were to be done, spamming the chat shouldn't be too much of a problem as you can print stuff to the chat only for Specific clients, no need for global chat warnings.
Attached Files
File Type: sp Get Plugin or Get Source (L4D2_HeadShotSounds.sp - 1063 views - 1.9 KB)
__________________

Last edited by DeathChaos25; 09-24-2014 at 16:50.
DeathChaos25 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-24-2014 , 18:40   Re: [L4D2]Headshot Sound
Reply With Quote #7

DeathChaos25 your plugin works great, thankyou very much, appreciate it...another request i made awhile ago was for a plugin to force players to thirdperson under certain circumstances, I can discuss this in more detail if your interested in helping out
MasterMind420 is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 09-24-2014 , 20:02   Re: [L4D2]Headshot Sound
Reply With Quote #8

Quote:
Originally Posted by MasterMind420 View Post
DeathChaos25 your plugin works great, thankyou very much, appreciate it...another request i made awhile ago was for a plugin to force players to thirdperson under certain circumstances, I can discuss this in more detail if your interested in helping out
Well, I don't really know If I'd be able to help you out, as I'm only just starting out.

If you look at any of my plugins, they all contain very simple and easy to understand code, nothing too fancy or too complicated.

Plus, I'm also currently putting my efforts into a big plugin/personal project that I've been working on for quite a while, over a whole month now at least, something I want to get finished.

Feel free to post your ideas though, if they're simple enough, and it can be done relatively quickly (this plugin took me roughly around 3 to 5 minutes at most), I might be able to do something.
__________________
DeathChaos25 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-30-2014 , 15:20   Re: [L4D2]Headshot Sound
Reply With Quote #9

Im looking for someone to create a plugin that forces a client to thirdperson and auto switch to melee weapon when zombies are within a certain distance from a survivor, obviously with configurable distance, and whether or not a client wants it active specifically. I personally prefer melee in thirdperson...I can create a keybind to switch to thirdperson and melee weapon but having it active within a certain distance would be easier...
MasterMind420 is offline
kochiurun119
BANNED
Join Date: Sep 2014
Location: GB
Old 09-30-2014 , 22:05   Re: [L4D2]Headshot Sound
Reply With Quote #10

https://forums.alliedmods.net/showthread.php?p=1239957 this is plugin but player join server will see a black screen and not joining. Who can fix bug? Plz
kochiurun119 is offline
Send a message via ICQ to kochiurun119 Send a message via AIM to kochiurun119 Send a message via Yahoo to kochiurun119 Send a message via Skype™ to kochiurun119
Reply


Thread Tools
Display Modes

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 16:15.


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