Raised This Month: $51 Target: $400
 12% 

Solved [HELP] Stop HeartBeat Sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-26-2018 , 14:43   [HELP] Stop HeartBeat Sound
Reply With Quote #1

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...
__________________

Last edited by hellmonja; 04-26-2018 at 15:25.
hellmonja is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 04-26-2018 , 14:54   Re: [HELP] Stop HeartBeat Sound
Reply With Quote #2

Stopsound is the correct way!

Quote:
Originally Posted by hellmonja View Post
But it doesn't seem to work. The sound keeps looping even after I die or onto another round...
Make changes in plugin then ..
instinctpt1 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-26-2018 , 14:59   Re: [HELP] Stop HeartBeat Sound
Reply With Quote #3

Quote:
Originally Posted by instinctpt1 View Post
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 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-26-2018 , 15:13   Re: [HELP] Stop HeartBeat Sound
Reply With Quote #4

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 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 04-26-2018 , 15:24   Re: [HELP] Stop HeartBeat Sound
Reply With Quote #5

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...
__________________
hellmonja 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 07:24.


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