Im making hitsounds for this mod im doing and im having a little trouble with it. The problem is that when a person gets shot, everyone hears the hitsound not just the person who was shooting. Here is the code i used.
In function g_damage in g_combat i have this code right above where it does damage distance falloff
if( headShot)
{
if( OnSameTeam( attacker, targ ) )
G_AddEvent( attacker, EV_TEAMHITSOUND, 0 );
else G_AddEvent( attacker, EV_HEADSHOTSOUND, 0 );
}
else
{
if ( OnSameTeam(attacker, targ) )
G_AddEvent( attacker, EV_TEAMHITSOUND, 0 );
else G_AddEvent( attacker, EV_HITSOUND, 0 );
}
Then in function cg_entityevent in cg_event i have this.
case EV_HEADSHOTSOUND:
DEBUGNAME(“EV_HEADSHOTSOUND”);
trap_S_StartLocalSound( trap_S_RegisterSound( “sound/headshot.wav”, qtrue ), CHAN_LOCAL_SOUND );
break;
case EV_HITSOUND:
DEBUGNAME("EV_HITSOUND");
trap_S_StartLocalSound( trap_S_RegisterSound( "sound/hit.wav", qtrue ), CHAN_LOCAL_SOUND );
break;
case EV_TEAMHITSOUND:
DEBUGNAME("EV_TEAMHITSOUND");
trap_S_StartLocalSound( trap_S_RegisterSound( "sound/hitteammate.wav", qtrue ), CHAN_LOCAL_SOUND );
break;
At first i thought the CHAN thing was wrong but i tried other ones and still had the same problem. Any help would be appreciated.