Re: CSGO What's the plugin for hs bell sound?
Quote:
Originally Posted by Comlog
(Post 2804817)
How can i make it play the sound for the attacker only in every hs, not only after kill
|
change hs_sound_enable to 2
not tested
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0.2"
ConVar Sound;
ConVar Soundvolume;
int bSound = 0;
float bSoundvolume = 0.00;
Handle SoundPath = INVALID_HANDLE;
public Plugin myinfo =
{
name = "[ANY] Headshot Sound",
author = "Gold KingZ",
description = "Headshot Kill Sound",
version = PLUGIN_VERSION,
url = "https://github.com/oqyh"
}
public void OnPluginStart()
{
CreateConVar("hs_sound_version", PLUGIN_VERSION, "[ANY] Headshot Sound Plugin Version", FCVAR_NOTIFY|FCVAR_DONTRECORD);
Sound = CreateConVar( "hs_sound_enable", "1", "Enable HeadShot Sound? || 2= Yes After Every Headshot || 1= Yes After Kill || 0= No", _, true, 0.0, true, 2.0);
Soundvolume = CreateConVar( "hs_sound_volume", "0.30", "Volume of the Sound From 0.00 To 1.00 || 1.00 is the hightest", _, true, 0.00, true, 1.00);
SoundPath = CreateConVar( "hs_sound_file", "training/bell_normal.wav","if hs_sound_enable 1 or 2 Where is Sound Location Without Sound/ beginning" );
HookEvent("player_death", Event_PlayerDeath_Pre, EventHookMode_Pre);
HookEvent("player_hurt", Event_PlayerHurt_Pre, EventHookMode_Pre);
HookConVarChange(Sound, OnSettingsChanged);
HookConVarChange(Soundvolume, OnSettingsChanged);
AutoExecConfig(true, "Headshot_Sound");
}
public void OnConfigsExecuted()
{
bSound = GetConVarInt(Sound);
bSoundvolume = GetConVarFloat(Soundvolume);
if(GetConVarInt(Sound) == 1 || GetConVarInt(Sound) == 2)
{
char iFileSound[PLATFORM_MAX_PATH];
GetConVarString(SoundPath, iFileSound, sizeof(iFileSound));
if(!StrEqual(iFileSound, ""))
{
char download[PLATFORM_MAX_PATH];
Format(download, sizeof(download), "sound/%s", iFileSound);
AddFileToDownloadsTable(download);
PrecacheSound(iFileSound);
}
}
}
public int OnSettingsChanged(Handle convar, const char[] oldValue, const char[] newValue)
{
if(convar == Sound)
{
bSound = Sound.IntValue;
}
if(convar == Soundvolume)
{
bSoundvolume = Soundvolume.FloatValue;
}
return 0;
}
public Action Event_PlayerDeath_Pre(Event event, const char[] name, bool dontBroadcast)
{
if(bSound != 1)return Plugin_Continue;
int attacker = GetClientOfUserId(event.GetInt("attacker"));
bool headshot = GetEventBool(event, "headshot");
char iFileSound[PLATFORM_MAX_PATH];
GetConVarString(SoundPath, iFileSound, sizeof(iFileSound));
if(IsValidClient(attacker))
{
if(headshot)
{
EmitSoundToClient(attacker, iFileSound, _, _, _, _, bSoundvolume);
}
}
return Plugin_Continue;
}
public Action Event_PlayerHurt_Pre(Event event, const char[] name, bool dontBroadcast)
{
if(bSound != 2)return Plugin_Continue;
int attacker = GetClientOfUserId(event.GetInt("attacker"));
bool headshot = GetEventBool(event, "headshot");
char iFileSound[PLATFORM_MAX_PATH];
GetConVarString(SoundPath, iFileSound, sizeof(iFileSound));
if(IsValidClient(attacker))
{
if(headshot)
{
EmitSoundToClient(attacker, iFileSound, _, _, _, _, bSoundvolume);
}
}
return Plugin_Continue;
}
stock bool IsValidClient(int iClient)
{
return (1 <= iClient <= MaxClients && IsClientInGame(iClient)) ? true : false;
}
|