AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] Stop HeartBeat Sound (https://forums.alliedmods.net/showthread.php?t=307104)

hellmonja 04-26-2018 14:43

[HELP] Stop HeartBeat Sound
 
This is probably a stupid question but how do I stop a looping heartbeat sound? Here's how I play the sound:

PHP Code:

new const HEARTBEAT_SOUND[]    = "player/heartbeat1.wav";
...
client_cmd(victim"spk %s"HEARTBEAT_SOUND); 

I've seen some plugins stop them like this:
PHP Code:

client_cmd(victim"stopsound"); 

But it doesn't seem to work. The sound keeps looping even after I die or onto another round...

instinctpt1 04-26-2018 14:54

Re: [HELP] Stop HeartBeat Sound
 
Stopsound is the correct way!

Quote:

Originally Posted by hellmonja (Post 2589573)
But it doesn't seem to work. The sound keeps looping even after I die or onto another round...

Make changes in plugin then ..

hellmonja 04-26-2018 14:59

Re: [HELP] Stop HeartBeat Sound
 
Quote:

Originally Posted by instinctpt1 (Post 2589574)
Make changes in plugin then ..

Hmm, thank you. At least I know I'm on the right track. But what should be changed?
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

new const PLUGIN[]         = "Heartbeat";
new const 
VERSION[]         = "0.1b";

new const 
HEARTBEAT_SOUND[]    = "player/heartbeat1.wav";

new 
bool:g_is_critical[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"hellmonja");

    
RegisterHam(Ham_Spawn"player""Ham_Heartbeat_Stop_Post"true);
    
RegisterHam(Ham_Killed"player""Ham_Heartbeat_Stop_Post"true);
    
RegisterHam(Ham_TakeDamage"player""Ham_TakeDamage_Post"true);
    
}

public 
Ham_Heartbeat_Stop_Post(player)
{
    if(
g_is_critical[player] == true)
    {
        
g_is_critical[player] = false;
        
client_cmd(player"stopsound");
    }
}

public 
Ham_TakeDamage_Post(victiminflictorattackerFloat:damagedmgbits)
{
    if(
g_is_critical[victim] == true)
        return 
HAM_IGNORED
    
    
if(get_user_health(victim) <= 25)
    {
        
client_cmd(victim"spk %s"HEARTBEAT_SOUND);
        
g_is_critical[victim] = true;
    }
    
    return 
HAM_IGNORED
    


The plugin seem pretty straight forward...

hellmonja 04-26-2018 15:13

Re: [HELP] Stop HeartBeat Sound
 
I am definitely doing something wrong. I did this:
PHP Code:

    register_concmd("debug""Debug");
}

public 
Debug(player)
{
    if(
g_is_critical[player] == false)
    {
        
client_cmd(player"spk %s"HEARTBEAT_SOUND);
        
g_is_critical[player] = true;
    }
    else
    {
        
client_cmd(player"stopsound");
        
g_is_critical[player] = false;
    }


And it works. The sound starts and stops. I must find why the "stopsound" doesn't work on other hooks. I will come back when I have the solution-- or got stumped...

hellmonja 04-26-2018 15:24

Re: [HELP] Stop HeartBeat Sound
 
I separated Ham_Killed and Ham_Spawn into their own functions and for some reason it now works. I probably just missed something that got fixed in the rewrite...


All times are GMT -4. The time now is 04:36.

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