Raised This Month: $32 Target: $400
 8% 

[L4D2] Thirdperson Shotgun sound bug fix


Post New Thread Reply   
 
Thread Tools Display Modes
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 06-08-2016 , 09:30   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #21

Ahh, I think I get the idea, MasterMind. Is it just like below?

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

static const String:SOUND_AUTOSHOTGUN[] = "weapons/auto_shotgun/gunfire/auto_shotgun_fire_1.wav";
static const 
String:SOUND_SPASSHOTGUN[] = "weapons/auto_shotgun_spas/gunfire/shotgun_fire_1.wav";
static const 
String:SOUND_PUMPSHOTGUN[] = "weapons/shotgun/gunfire/shotgun_fire_1.wav";
static const 
String:SOUND_CHROMESHOTGUN[] = "weapons/shotgun_chrome/gunfire/shotgun_fire_1.wav";

static 
bool:confirmChangedView[MAXPLAYERS+1] = false;

public 
Plugin:myinfo 
{
    
name "Shotgun Sounds Fix",
    
author "DeathChaos25",
    
description "Fixes Bug Where Shotguns Don't Produce Sound In Third Person View.",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=259986"
};

public 
OnPluginStart()
{
    
HookEvent("weapon_fire"OnWeaponFire);
    
    
CreateTimer(1.0CheckCurrentView_TIMER_REPEAT);
}

public 
Action:CheckCurrentView(Handle:timer)
{
    for (new 
cIndex 1cIndex <= MaxClientscIndex++)
    {
        if (
IsClientInGame(cIndex) && !IsFakeClient(cIndex))
        {
            if (
GetClientTeam(cIndex) == 2)
            {
                
QueryClientConVar(cIndex"c_thirdpersonshoulder"QueryClientConVarCallback);
            }
        }
    }
    
    return 
Plugin_Continue;
}

public 
QueryClientConVarCallback(QueryCookie:cookieclientConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
{
    if (
IsClientInGame(client))
    {
        if (
result != ConVarQuery_Okay)
        {
            
confirmChangedView[client] = false;
        }
        
        if (
StrEqual(cvarValue"false") || StrEqual(cvarValue"0"))
        {
            
confirmChangedView[client] = false;
        }
        
        
confirmChangedView[client] = true;
    }
}

public 
OnMapStart()
{
    
PrefetchSound(SOUND_AUTOSHOTGUN);
    
PrefetchSound(SOUND_SPASSHOTGUN);
    
PrefetchSound(SOUND_CHROMESHOTGUN);
    
PrefetchSound(SOUND_PUMPSHOTGUN);
    
    
PrecacheSound(SOUND_AUTOSHOTGUNtrue);
    
PrecacheSound(SOUND_SPASSHOTGUNtrue);
    
PrecacheSound(SOUND_CHROMESHOTGUNtrue);
    
PrecacheSound(SOUND_PUMPSHOTGUNtrue);
}

public 
Action:OnWeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
client <= || client MaxClients || !IsClientInGame(client) || GetClientTeam(client) != || !IsPlayerAlive(client) || !confirmChangedView[client]) 
    {
        return 
Plugin_Handled;
    }
    
    new 
String:weapon[64];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    for (new 
i=1i<=MaxClientsi++)
    {
        if(
IsClientInGame(i) && GetClientTeam(client) == && == client)
        {
            if (
StrEqual(weapon"autoshotgun"))
            {
                
EmitSoundToClient(iSOUND_AUTOSHOTGUNclientSNDCHAN_WEAPON);
            }
            else if (
StrEqual(weapon"shotgun_spas"))
            {
                
EmitSoundToClient(iSOUND_SPASSHOTGUNclientSNDCHAN_WEAPON);
            }
            else if (
StrEqual(weapon"pumpshotgun"))
            {
                
EmitSoundToClient(iSOUND_PUMPSHOTGUNclientSNDCHAN_WEAPON);
            }
            else if (
StrEqual(weapon"shotgun_chrome"))
            {
                
EmitSoundToClient(iSOUND_CHROMESHOTGUNclientSNDCHAN_WEAPON);
            }
        }
    }
    
    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (shotgun_sounds_fix.sp - 530 views - 3.1 KB)

Last edited by cravenge; 06-08-2016 at 09:35.
cravenge is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 06-08-2016 , 11:20   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #22

you don't understand... this convar can still be 1 (c_thirdpersonshoulder) even if they are in first person view.
which mean's echo bug again this is what i mean by thirdpersonshoulder is clientsided cmd only and it is a cmd not a convar
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 06-08-2016 , 11:28   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #23

Quote:
Originally Posted by Ludastar View Post
you don't understand... this convar can still be 1 (c_thirdpersonshoulder) even if they are in first person view.
which mean's echo bug again this is what i mean by thirdpersonshoulder is clientsided cmd only and it is a cmd not a convar
That will only happen if something else forces you out of thirdpersonshoulder prematurely, for instance going afk in thirdpersonshoulder, it forces you back to firstperson when you come back yet that convar remains 1. That is the only instance i've seen that happen and i have a fix for that if its needed. But still i see that being a rare occurance...You can still use that convar check effectively. basically that convar only changes when you use the thirdpersonshoulder cmd, which is really the closest and only thing we have to detecting if there in thirdpersonshoulder...anything forcing you out of thirdpersonshoulder other than using the command will cause that issue...

Last edited by MasterMind420; 06-08-2016 at 11:32.
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 06-08-2016 , 11:36   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #24

Quote:
Originally Posted by Ludastar View Post
which mean's echo bug again
PHP Code:
for (new i=1i<=MaxClientsi++) 
    { 
        if(
IsClientInGame(i) && GetClientTeam(client) == && == client
        { 
            if (
StrEqual(weapon"autoshotgun")) 
            { 
                
EmitSoundToClient(iSOUND_AUTOSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"shotgun_spas")) 
            { 
                
EmitSoundToClient(iSOUND_SPASSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"pumpshotgun")) 
            { 
                
EmitSoundToClient(iSOUND_PUMPSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"shotgun_chrome")) 
            { 
                
EmitSoundToClient(iSOUND_CHROMESHOTGUNclientSNDCHAN_WEAPON); 
            } 
        } 
    } 
This doesn't produce any echo because it only emits to the client itself.

Last edited by cravenge; 06-08-2016 at 11:37.
cravenge is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 06-08-2016 , 12:17   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #25

Quote:
Originally Posted by cravenge View Post
PHP Code:
for (new i=1i<=MaxClientsi++) 
    { 
        if(
IsClientInGame(i) && GetClientTeam(client) == && == client
        { 
            if (
StrEqual(weapon"autoshotgun")) 
            { 
                
EmitSoundToClient(iSOUND_AUTOSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"shotgun_spas")) 
            { 
                
EmitSoundToClient(iSOUND_SPASSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"pumpshotgun")) 
            { 
                
EmitSoundToClient(iSOUND_PUMPSHOTGUNclientSNDCHAN_WEAPON); 
            } 
            else if (
StrEqual(weapon"shotgun_chrome")) 
            { 
                
EmitSoundToClient(iSOUND_CHROMESHOTGUNclientSNDCHAN_WEAPON); 
            } 
        } 
    } 
This doesn't produce any echo because it only emits to the client itself.
which would make sense, but can other clients hear the sound too, if your in thirdpersonshoulder, or does the bug only effect the specific client shooting the shotgun? Thats why i assume he initially coded it to Emit to all clients. But I haven't tested that, the echo is definately gone...

Last edited by MasterMind420; 06-08-2016 at 12:20.
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 06-09-2016 , 00:01   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #26

I did a crash test with my friend. Actually, even without this plugin, he can hear the shotgun sounds emitted from me which means the no shotgun sounds bug comes from the player holding the shotgun him/herself.
cravenge is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 06-09-2016 , 00:03   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #27

nice, so then that means you've fixed it...great job
MasterMind420 is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 06-09-2016 , 01:26   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #28

Quote:
Originally Posted by cravenge View Post
I did a crash test with my friend. Actually, even without this plugin, he can hear the shotgun sounds emitted from me which means the no shotgun sounds bug comes from the player holding the shotgun him/herself.
I see you use a local hosted server cravenge, so you would never hear the echo, the echo only happens due to delay with ping, the higher ping the more of a delay the sound you be, meaning if your on 150ping this fix is kinda useless because of standard lerp = 100ms making total latency 250ms making the sounds out of sync.

This make the fix feel yuck, ill maybe try and calc the latency if it's below >100ms
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 08-09-2016 , 18:43   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #29

Crossing fingers people but on an initial test with Ludastar it's looking promising, report any bugs and when they happened(echo returns), its very important for me to find and fix where the convarquerycheck is reporting falsely. So far i've narrowed it down to 4 instances mapchange, death, afk and rescue closet.
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_thirdpersonshoulder_shotgun_sound_fix.sp - 565 views - 5.5 KB)

Last edited by MasterMind420; 08-09-2016 at 20:45.
MasterMind420 is offline
jking
AlliedModders Donor
Join Date: Jan 2012
Old 08-09-2016 , 22:25   Re: [L4D2] Thirdperson Shotgun sound bug fix
Reply With Quote #30

Quote:
Originally Posted by MasterMind420 View Post
Crossing fingers people but on an initial test with Ludastar it's looking promising, report any bugs and when they happened(echo returns), its very important for me to find and fix where the convarquerycheck is reporting falsely. So far i've narrowed it down to 4 instances mapchange, death, afk and rescue closet.
5x5 great work you guys
jking 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 04:19.


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