Raised This Month: $ Target: $400
 0% 

Does AddNormalSoundHook only work with one plugin at a time? Bug? Intentional?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 08-08-2014 , 22:17   Does AddNormalSoundHook only work with one plugin at a time? Bug? Intentional?
Reply With Quote #1

I'm having an issue where if I have a plugin with AddNormalSoundHook, any other plugins that have AddNormalSoundHook absolutely refuse to fire their callbacks whatsoever, effectively rendering them non-functional.

Is this a bug? Intentional? or what? It's making me want to rip my fucking hair out that much I can discern.

The code below refuses to run.

PHP Code:
public OnPluginStart()
{
    
GetGame(); // Works
    
AddNormalSoundHook(SoundHook); // Doesn't Work
}

public 
OnMapStart()
{
    if(
game == TF2)
    {
        
LoadSoundSet(DispenserSongsNumDispenserSongs); // Works
    
}
}

public 
Action:SoundHook(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags// Doesn't work.
{
    
PrintToChatAll("%s"sample); // Test to see if the hook is firing. Doesn't ever trigger. Nothing below does either.
    
    
if(game == TF2)
    {
        if(
StrEqual(sample"weapons/dispenser_idle.wav"false))
        {
            new 
client GetEntPropEnt(entityProp_Send"m_hBuilder");
            
            if(
IsValidClient(client))
            {
                new 
dispenser_song StrikerMod_GetDonatorInfo_Int(clientDonatorInfo_Int_DispenserMusic);
                
                if(
dispenser_song && dispenser_song <= NumDispenserSongs)
                {
                    
sample DispenserSongs[dispenser_song-1];
                    
level SNDLEVEL_MINIBIKE;
                }
                else
                {
                    return 
Plugin_Continue;
                }
            }
            else
            {
                return 
Plugin_Continue;
            }
            
            return 
Plugin_Changed;
        }
    }
    
    return 
Plugin_Continue;

This is code from another plugin of mine. This is the only soundhook that works it seems...
Just warning, it's a fucking mess and I need to clean it up soon.

PHP Code:
public Action:SoundHook(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
    if(
GetConVarBool(cv_sounddebug))
    {
        if(
StrContains(sample"player/footsteps"false) == -&& StrContains(sample"physics/"false) == -1)
        {
            
PrintToChatAll("[DEBUG] Sound Played: %s"sample);
        }
    }
    
    if(
game == TF2)
    {
        
decl bool:PitchShifted;
        
        if(
StrEqual(sample")weapons/sentry_shoot_mini.wav"false))
        {
            
sample ")sm_weapons/sentry_shoot_mini.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample")weapons/sentry_shaft_shoot.wav"false))
        {
            
channel SNDCHAN_AUTO;
            
sample ")sm_weapons/sentry_shaft_shoot.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample")weapons/sentry_shaft_shoot2.wav"false))
        {
            
channel SNDCHAN_AUTO;
            
sample ")sm_weapons/sentry_shaft_shoot2.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample")weapons/sentry_shaft_shoot3.wav"false))
        {
            
channel SNDCHAN_AUTO;
            
sample ")sm_weapons/sentry_shaft_shoot3.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample"player/invulnerable_on.wav"false))
        {
            
sample "ShadowMavs/invulnerable_on.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample"player/quickfix_invulnerable_on.wav"false))
        {
            
sample "ShadowMavs/quickfix_invulnerable_on.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample")weapons/weapon_crit_charged_on.wav"false))
        {
            
sample "ShadowMavs/weapon_crit_charged_on.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample"weapons/sentry_spot_client.wav"false))
        {
            
sample "ShadowMavs/sentry_spot.wav";
            return 
Plugin_Changed;
        }
        else if(
StrEqual(sample"weapons/sentry_spot.wav"false))
        {
            
sample "ShadowMavs/sentry_spot.wav";
            return 
Plugin_Changed;
        }
        else if(
StrContains(sample"cleaver_hit_world_"false) > -1)
        {
            switch(
cleaver_type[entity])
            {
                case 
1,2:
                {
                    
sample "sm_weapons/mario_fireball_hit.wav";
                    return 
Plugin_Changed;
                }
                case 
3:
                {
                    
sample PlasmaImpactSounds[GetRandomInt(0NumPlasmaImpactSounds-1)];
                    
CreateTimer(0.1Timer_KillEntityentity);
                    return 
Plugin_Changed;
                }
                case 
99:
                {
                    
sample PlasmaImpactSounds[GetRandomInt(0NumPlasmaImpactSounds-1)];
                    
CreateParticle(entity"eb_aura_calm01"1.0falsefalsetrue);
                    
CreateTimer(0.1Timer_KillEntityentity);
                    return 
Plugin_Changed;
                }
            }
        }
        else if(
StrContains(sample"cleaver_hit_"false) > -1)
        {
            switch(
cleaver_type[entity])
            {
                case 
1,2:
                {
                    
sample "sm_weapons/mario_fireball_hit_enemy.wav";
                    return 
Plugin_Changed;
                }
                case 
3:
                {
                    
sample ")sm_weapons/aura_hit.wav";
                    if(
entity MaxClients)
                    {
                        
CreateTimer(0.1Timer_KillEntityentity);
                    }
                    return 
Plugin_Changed;
                }
                case 
99:
                {
                    
sample ")sm_weapons/aura_hit.wav";
                    if(
entity MaxClients)
                    {
                        
CreateParticle(entity"eyeboss_aura_calm"1.0falsefalsetrue);
                        
CreateParticle(entity"eb_tp_escape_bits"1.0falsefalsetrue);
                        
CreateTimer(0.1Timer_KillEntityentity);
                    }
                    return 
Plugin_Changed;
                }
            }
        }
        else if(
StrContains(sample"physics/plastic/plastic_box_impact_"false) > -1)
        {
            return 
Plugin_Handled;
        }
        else if(
StrContains(sample"vo/"false) > -&& IsValidClient(entity))
        {
            if(!
IsMvM())
            {
                new 
Float:BodyScale GetEntPropFloat(entityProp_Send"m_flModelScale");
                new 
Float:HeadScale GetEntPropFloat(entityProp_Send"m_flHeadScale");
            
                if(
BodyScale != 1.0 || HeadScale != 1.0)
                {
                    if(
channel == SNDCHAN_VOICE)
                    {
                        
pitch RoundToNearest((175 / (+ (BodyScale HeadScale))) + 75);
                        
flags |= SND_CHANGEPITCH;
                        
PitchShifted true;
                    }
                }
            }
            
            if(
StrContains(sample"vo/pyro_"false) > -&& IsValidClient(entity))
            {
                switch(
pyro_model[entity])
                {
                    case 
1:
                    {
                        
pitch += 20;
                        
flags |= SND_CHANGEPITCH;
                        
PitchShifted true;
                    }
                    case 
2:
                    {
                        
ReplaceString(sample255"vo/""ShadowMavs/voices/gaben/"false);
                        
String_ToLower(samplesample255);
                        
                        if(
TF2_IsPlayerInCondition(entityTFCond_Taunting))
                        {
                            if(
StrEqual(sample"shadowmavs/voices/gaben/pyro_painsevere01.wav"false))
                            {
                                
sample "shadowmavs/voices/gaben/gabe_shinku_v2.wav";
                            }
                            else if(
StrEqual(sample"shadowmavs/voices/gaben/pyro_headright01.wav"false))
                            {
                                
sample "shadowmavs/voices/gaben/gabe_hadouken_v2.wav";
                            }
                            else if(
StrEqual(sample"shadowmavs/voices/gaben/pyro_paincrticialdeath01.wav"false))
                            {
                                
sample "shadowmavs/voices/gaben/gabe_tostopagaben.wav";
                            }
                            else if(
StrEqual(sample"shadowmavs/voices/gaben/pyro_paincrticialdeath03.wav"false))
                            {
                                
sample "shadowmavs/voices/gaben/gabe_fasterstrongerbettergaben.wav";
                            }
                        }
                        
                        return 
Plugin_Changed;
                    }
                }
            }
            else if((
StrContains(sample"vo/heavy_"false) > -1) && GetConVarBool(cv_voices))
            {
                if(
is_tourettes[entity])
                {
                    
ReplaceString(sample255"vo/""ShadowMavs/voices/tourettes_v2/"false);
                    
String_ToLower(samplesample255);
                    return 
Plugin_Changed;
                }
            }
            else if(
StrContains(sample"vo/taunts/medic_taunts16"false) > -&& IsValidClient(entity))
            {
                if(
TF2_IsPlayerInCondition(entityTFCond_Taunting))
                {
                    
                    
sample ")ShadowMavs/smokeweedeveryday.mp3";
                    return 
Plugin_Changed;
                }
            }
        }
        
        if(
GetConVarBool(cv_quake))
        {
            if(
StrContains(sample"weapons/shotgun_shoot"false) > -1)
            {
                
sample ")ShadowMavs/weapons/railgun_v1.wav";
                return 
Plugin_Changed;
            }
        }
        
        if(
PitchShifted)
        {
            return 
Plugin_Changed;
        }
    }
    else if(
game == CSTRIKE || game == HL2DM)
    {
        if(
GetConVarBool(cv_voices))
        {
            if(
StrContains(sample"player/death"false) > -||
            
StrContains(sample"pain07.wav"false) > -|| 
            
StrContains(sample"pain08.wav"false) > -|| 
            
StrContains(sample"pain09.wav"false) > -)
            {
                
decl String:ModelName[128];
                
GetEntPropString(entityProp_Data"m_ModelName"ModelNamesizeof(ModelName));
                
                if(
StrContains(ModelName"renamon"false) > -1)
                {
                    
sample RenamonDeathSounds[GetRandomInt(0NumRenamonDeathSounds-1)];
                }
                else if(
StrContains(ModelName"combine"false) > -|| StrContains(ModelName"neo_heavy"false) > -1)
                {
                    
sample CombineDeathSounds[GetRandomInt(0NumCombineDeathSounds-1)];
                }
                else if(
StrContains(ModelName"police"false) > -1)
                {
                    
sample MetroCopDeathSounds[GetRandomInt(0NumMetroCopDeathSounds-1)];
                }
                else if(
StrContains(ModelName"duke"false) > -1)
                {
                    
sample DukeDeathSounds[GetRandomInt(0NumDukeDeathSounds-1)];
                }
                else if(
StrContains(ModelName"spy"false) > -1)
                {
                    
sample SpyDeathSounds[GetRandomInt(0NumSpyDeathSounds-1)];
                }
                else if(
StrContains(ModelName"sniper"false) > -1)
                {
                    
sample SniperDeathSounds[GetRandomInt(0NumSniperDeathSounds-1)];
                }
                else
                {
                    if(
game == CSTRIKE)
                    {
                        
sample CSSDeathSounds[GetRandomInt(0NumCSSDeathSounds-1)];
                    }
                    else
                    {
                        return 
Plugin_Continue;
                    }
                }
                
                
level SNDLEVEL_MINIBIKE;
                return 
Plugin_Changed;
            }
        }
    }
    
    return 
Plugin_Continue;

edit:
Code:
00:07  <Striker>    Yeah, I'm convinced there's either a limitation or a bug in sourcemod at this point...
00:08  <Striker>    There's literally nothing wrong with the code I had written. Most of it came from the plugin that's working anyway. It just refuses to even consider running the Sound Hook..

Last edited by StrikerMan780; 08-08-2014 at 23:11.
StrikerMan780 is offline
StrikerMan780
AlliedModders Donor
Join Date: Jul 2009
Location: Canada
Old 08-08-2014 , 23:52   Re: Does AddNormalSoundHook only work with one plugin at a time? Bug? Intentional?
Reply With Quote #2

After disabling all sound hooks in other plugins, the sound hook works. It seems like a sound hook will block all other sound hooks regardless of whether or not one returns Plugin_Continue or not. It's as if the first plugin to hook sounds, is the only one allowed to. This would seem like a bug to me, as it could cause all sorts of conflicts.

EDIT:
Code:
01:27  <Striker>    Ok, I made sure that it is indeed returning Plugin_Continue
01:27  <Striker>    however, here's where it gets strange
01:27  <Striker>    I made two plugins that use a soundhook, but, they both work without halting the other.
01:28  <Striker>    and they function much the same way...
01:29  <Striker>    Does it make a difference that the 2nd plugin relies on the Main? (ie. A Core Plugin with many Natives, and Modules for it.)
01:36  <Striker>    Ok... after recompiling my main plugins and reloading it again... it works
01:37  <Striker>    Even though no changes were made
01:37  <Striker>    I'm confused as fuck, but I'm satisfied.

Last edited by StrikerMan780; 08-09-2014 at 00:38.
StrikerMan780 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 01:46.


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