|
Senior Member
Join Date: Jan 2014
Location: Brazil
|
08-14-2018
, 20:16
Re: [CSGO-Req] weapon sounds changer
|
#18
|
Must be working:
Spoiler
PHP Code:
#include <sourcemod> #include <sdktools>
// Example with AK47 #define NEW_AK47SOUND "custom/weapons/new_ak47.mp3"
#pragma newdecls required
public void OnPluginStart() { AddTempEntHook("Shotgun Shot", OnWeaponFireSound); }
public void OnPluginEnd() { RemoveTempEntHook("Shotgun Shot", OnWeaponFireSound); }
public void OnMapStart() { FakePrecacheSound(NEW_AK47SOUND); }
public Action OnWeaponFireSound(const char[] teName, const int[] players, int numClients, float delay) { int client = TE_ReadNum("m_iPlayer") + 1;
if (client > 0 && client <= MaxClients && IsClientInGame(client)) { int weapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon"); if (!IsValidEdict(weapon)) { return Plugin_Continue; }
static char buffer[32] GetEdictClassname(weapon, buffer, sizeof(buffer)); if (StrEqual(buffer, "weapon_ak47", false)) { CS_EmitSoundToAll(NEW_AK47SOUND, client, SNDCHAN_WEAPON, SNDLEVEL_ROCKET, SNDVOL_NORMAL); CS_EmitSoundToAll(NEW_AK47SOUND, client, SNDCHAN_STATIC, SNDLEVEL_NORMAL, SNDVOL_NORMAL); return Plugin_Stop; } } return Plugin_Continue; }
// Fix for CS:GO. stock void FakePrecacheSound(const char[] soundpath) { char fullPath[PLATFORM_MAX_PATH]; Format(fullPath, sizeof(fullPath), "sound/%s", soundpath);
if (!FileExists(fullPath)) { return; }
AddFileToDownloadsTable(fullPath);
Format(fullPath, sizeof(fullPath), "*/%s", soundpath); AddToStringTable(FindStringTable("soundprecache"), fullPath); }
stock void CS_EmitSoundToAll(const char[] sound, int entity = SOUND_FROM_PLAYER, int channel = SNDCHAN_AUTO, int level = SNDLEVEL_NORMAL, float volume = SNDVOL_NORMAL) { static char soundPath[PLATFORM_MAX_PATH]; Format(soundPath, sizeof(soundPath), "*/%s", sound); EmitSoundToAll(soundPath, entity, channel, level, _, volume); }
BUT it is not possible to block the original sound for who are shooting due to the client's predict (that is, you will hear both sounds), just for the other players.
Last edited by brunoronning; 08-14-2018 at 20:18.
|
|
|
|