Raised This Month: $ Target: $400
 0% 

Play audio on menu select


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 13:29   Play audio on menu select
Reply With Quote #1

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!

Last edited by DarthMan; 03-02-2017 at 13:30.
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2017 , 13:34   Re: Play audio on menu select
Reply With Quote #2

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.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 13:39   Re: Play audio on menu select
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
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;
}
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2017 , 13:43   Re: Play audio on menu select
Reply With Quote #4

Where's the code that plays the audio? Show us what you tried.
Also, what are menu_setprop functions doing in a menu handler?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 13:53   Re: Play audio on menu select
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
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.
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2017 , 13:55   Re: Play audio on menu select
Reply With Quote #6

There's nothing wrong with that code. Probably you don't have the sound in your directory.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 13:57   Re: Play audio on menu select
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
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.
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-02-2017 , 13:58   Re: Play audio on menu select
Reply With Quote #8

Show the full code with the sound line inside it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-02-2017 , 14:04   Re: Play audio on menu select
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
Show the full code with the sound line inside it.
Ah, it works now. My bad, I forgot to put a " on the code.
DarthMan is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-02-2017 , 14:40   Re: Play audio on menu select
Reply With Quote #10

Quote:
Originally Posted by OciXCrom View Post
you can't detect the back/next menu keys.
There are MENU_BACK and MENU_NEXT status codes, just like MENU_EXIT.
klippy 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 21:00.


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