Answered Trying to get a sound to play when you melee with the Wolfbow

Collie

Veteran
Messages
9
Reaction score
12
Points
788
Exactly as the title says, I'm trying to get the game to play a specific sound when the player melees with the wolf bow out. I have put the sound in my mod's folders, however I am having difficulties getting the game to recognize that the player is holding the wolfbow. Here is the code I am using:
PHP:
function wbowmelee()
{
    for(;;)
    {
        if(self MeleeButtonPressed())
            {
                if(self getcurrentweapon()=="elemental_bow_wolf_howl")
                {
                    playsoundatposition( "mus_snarl", (0,0,0) );
                    wait(1.5);
                    continue;
                }
                else
                {
                    wait(2);
                    continue;
                }
            }
        wait(0.05);
    }
}
I know the issue is with the game not recognising that the wolfbow is equipped, as putting a iprintlnbold in along with the sound does not produce any results. In addition, if anyone has any experience with using sounds in mods could you tell me exactly how that works? I want to use sounds more in my mods, but I am unsure if I am doing it right here.
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,998
Reaction score
2,918
Points
1,053
Exactly as the title says, I'm trying to get the game to play a specific sound when the player melees with the wolf bow out. I have put the sound in my mod's folders, however I am having difficulties getting the game to recognize that the player is holding the wolfbow. Here is the code I am using:
PHP:
function wbowmelee()
{
    for(;;)
    {
        if(self MeleeButtonPressed())
            {
                if(self getcurrentweapon()=="elemental_bow_wolf_howl")
                {
                    playsoundatposition( "mus_snarl", (0,0,0) );
                    wait(1.5);
                    continue;
                }
                else
                {
                    wait(2);
                    continue;
                }
            }
        wait(0.05);
    }
}
I know the issue is with the game not recognising that the wolfbow is equipped, as putting a iprintlnbold in along with the sound does not produce any results. In addition, if anyone has any experience with using sounds in mods could you tell me exactly how that works? I want to use sounds more in my mods, but I am unsure if I am doing it right here.
Hi Collie,
this is a common issue with the weapon system you did. In Black Ops 3 weapons aren't strings, they are entity's. If you want to check the current weapon with a string you need to add this field to getcurrentweapon():

getcurrentweapon().name

This will return the weapon name as a string.

I will recode your function when I'm at home. Thank you!

Best regards,
CabCon.
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
Exactly as the title says, I'm trying to get the game to play a specific sound when the player melees with the wolf bow out. I have put the sound in my mod's folders, however I am having difficulties getting the game to recognize that the player is holding the wolfbow. Here is the code I am using:
PHP:
function wbowmelee()
{
    for(;;)
    {
        if(self MeleeButtonPressed())
            {
                if(self getcurrentweapon()=="elemental_bow_wolf_howl")
                {
                    playsoundatposition( "mus_snarl", (0,0,0) );
                    wait(1.5);
                    continue;
                }
                else
                {
                    wait(2);
                    continue;
                }
            }
        wait(0.05);
    }
}
I know the issue is with the game not recognising that the wolfbow is equipped, as putting a iprintlnbold in along with the sound does not produce any results. In addition, if anyone has any experience with using sounds in mods could you tell me exactly how that works? I want to use sounds more in my mods, but I am unsure if I am doing it right here.
It's like @CabCon said, I made a function which should work:
Code:
function wbowmelee()
{
    for(;;)
    {
        if(self MeleeButtonPressed())
        {
            if(self getcurrentweapon().name=="elemental_bow_wolf_howl")
            {
                self playSound("mus_snarl");
                wait 1.5;
            }
        }
    wait .05;
    }
}
 

Collie

Veteran
Messages
9
Reaction score
12
Points
788
Thanks for the help! I had a problem with actually getting the sound to play, but I solved that on my own.
 
Top