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

Knife kill sound plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdulsami34
Member
Join Date: Oct 2017
Old 02-06-2019 , 19:48   Knife kill sound plugin
Reply With Quote #1

Hello,
Anyone have a plugin which plays sound when someone get knifed.
I found a code somewhere here. but it plays sound with every weapon

Code:
#include <emitsoundany>

public void OnPluginStart()
{ 
    HookEvent("player_death", Event_PlayerDeath); 
} 

public void OnMapStart()
{
    AddFileToDownloadsTable("sound/wgm/sknifed.mp3");
    PrecacheSoundAny("wgm/sknifed.mp3");
}

public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
    int attacker = GetClientOfUserId(event.GetInt("attacker"));
    if (IsValidClient(attacker))
    { 
        char weapon[64];
        event.GetString("weapon", weapon, sizeof(weapon));
        if (StrEqual(weapon, "knife") || StrEqual(weapon, "bayonet"))
        {
            EmitSoundToClientAny(attacker, "wgm/sknifed.mp3");
        }
    }
}

bool IsValidClient(int client)
{ 
    if (!(0 < client <= MaxClients)) return false;
    if (!IsClientInGame(client)) return false;
    return true;
}
Any help would be appreciated.
If yes anyone could help me with this plugin, I want to know if it could play more than 1 sound.

Thanks!
abdulsami34 is offline
McSnaggit
Junior Member
Join Date: Feb 2019
Old 02-12-2019 , 10:16   Re: Knife kill sound plugin
Reply With Quote #2

I'm just starting with writing my own plugin so I'm not sure if this is of any help. Shouldn't you put brackets around the StrEqual? Like this:

PHP Code:
if ((StrEqual(weapon"knife")) || (StrEqual(weapon"bayonet")))
{
    
EmitSoundToClientAny(attacker"wgm/sknifed.mp3");

Good luck!
McSnaggit 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:57.


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