AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Play audio on menu select (https://forums.alliedmods.net/showthread.php?t=294586)

DarthMan 03-02-2017 13:29

Play audio on menu select
 
Hello, I ahve a problem. I want to play a sound each time an item from my menu is selected, but I failed. How can I do that and so it will also work for backward, forward and close menu keys? Thanks!

OciXCrom 03-02-2017 13:34

Re: Play audio on menu select
 
If you're using the new menu system, you can't detect the back/next menu keys. For the other ones - you provided no code and we can only guess what you have done.

DarthMan 03-02-2017 13:39

Re: Play audio on menu select
 
Quote:

Originally Posted by OciXCrom (Post 2500161)
If you're using the new menu system, you can't detect the back/next menu keys. For the other ones - you provided no code and we can only guess what you have done.

This is how the menu looks like :) , it's just a aprt of the script.

Code:

public mh_PMenu(id, menu, item)
{
        if(item == MENU_EXIT)
        {
                menu_cancel(id);
                return PLUGIN_HANDLED;
        }

        new command[6], name[64], access, callback;
        new line[3];

        menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);

        switch(item)
        {
                case 0:
                {
                new menu_model = menu_create("Models Menu", "mh_MMenu")
                for (new i; (i < file_size(conffile_model, 1)); i++)
                {
                        new buffer;
                        read_file(conffile_model, i, file_model, 127, buffer)
                        //format(file_model,127,"%s^" ^"%d^"",local_models,local_skins)
                        parse(file_model,g_models, 127, g_skins, 127)
                        format(line,2,"%i",i)
                        menu_additem(menu_model, g_models, line);
                }               
                menu_setprop(menu_model, MPROP_EXIT, MEXIT_ALL);
                menu_setprop(menu_model, MPROP_BACKNAME, "Back");
                menu_setprop(menu_model, MPROP_NEXTNAME, "Next");
                menu_setprop(menu_model, MPROP_EXITNAME, "Close");
                menu_destroy(menu);
                menu_display(id, menu_model, 0);
                }
                case 1:
                {       
                if (g_thirdperson==0)
                    {
                        client_print(id, print_chat, "You have selected Thirdperson View");
                        g_thirdperson=1;
                        set_view(id, CAMERA_3RDPERSON);
                        return PLUGIN_CONTINUE;
                    }
                else
                    {
                        client_print(id, print_chat, "You have selected Firstperson View");
                        g_thirdperson=0;
                        set_view(id, CAMERA_NONE);
                        return PLUGIN_CONTINUE;
                    }               
                }
        }

        return PLUGIN_HANDLED;
}


OciXCrom 03-02-2017 13:43

Re: Play audio on menu select
 
Where's the code that plays the audio? Show us what you tried.
Also, what are menu_setprop functions doing in a menu handler?

DarthMan 03-02-2017 13:53

Re: Play audio on menu select
 
Quote:

Originally Posted by OciXCrom (Post 2500173)
Where's the code that plays the audio? Show us what you tried.
Also, what are menu_setprop functions doing in a menu handler?

Code:

client_cmd(id, "spk ^"fm/menuselect^"");
That's what I have tried to put when the emnu gets executed.
The function are from the amxx menu generator which you can find on this forum, they were automatically created.

OciXCrom 03-02-2017 13:55

Re: Play audio on menu select
 
There's nothing wrong with that code. Probably you don't have the sound in your directory.

DarthMan 03-02-2017 13:57

Re: Play audio on menu select
 
Quote:

Originally Posted by OciXCrom (Post 2500184)
There's nothing wrong with that code. Probably you don't have the sound in your directory.

I do, it just gave me an error, while compiling it, idk why.

OciXCrom 03-02-2017 13:58

Re: Play audio on menu select
 
Show the full code with the sound line inside it.

DarthMan 03-02-2017 14:04

Re: Play audio on menu select
 
Quote:

Originally Posted by OciXCrom (Post 2500187)
Show the full code with the sound line inside it.

Ah, it works now. My bad, I forgot to put a " on the code.

klippy 03-02-2017 14:40

Re: Play audio on menu select
 
Quote:

Originally Posted by OciXCrom (Post 2500161)
you can't detect the back/next menu keys.

There are MENU_BACK and MENU_NEXT status codes, just like MENU_EXIT.


All times are GMT -4. The time now is 21:00.

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