Jump to content
Coldfront15

Need help with ContainerOpened event handler.

Recommended Posts

Hello, I am trying to play a certain sound upon opening a container i'm importing into the game.

However, I don't really know how to do this. Currently I am doing the following but to no avail:

 

config.cpp

 

Quote

class CfgSounds

{

    sounds[] = {bagopen, bagclose};

 

    class bagopen

    {

        name = "BagOpen";

        sound[] = {\simc_obj_44\sounds\open_bag.ogg, db+1, 1.0};

        titles[] = {0, ""};

    };

    class bagclose

    {

        name = "BagClose";

        sound[] = {\simc_obj_44\sounds\close_bag.ogg, db+1, 1.0};

        titles[] = {0, ""};

    };

};

class CfgFunctions

{

    class bagsounds_tag

    {

        class bagsounds_category

        {

            class bagsounds_function

            {

                file = "\simc_obj_44\bagsounds.sqf";

                preInit = 1;

                postInit = 1;

                preStart = 1;

                recompile = 1;

                ext = ".sqf";

                headerType = -1;

            };

        };

    };

};

 

bagsounds.sqf

 

Quote

player addEventHandler ["ContainerOpened", {

    params ["simc_a5_container"];

    playSound "bagopen"; 

}];

player addEventHandler ["ContainerClosed", {

    params ["simc_a5_container"];

    playSound "bagclose"; 

}];

 

Everything else about my object works as it should and acts as a proper container: I just cannot figure out how to play these sounds to the player locally upon opening or closing the bag. Any help is appreciated.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×