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

little menu problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 05-29-2014 , 06:45   little menu problem
Reply With Quote #1

Hi,

when I toggle the option on my 2nd menu page I want to stay at that page but I dont
really know to do that.

Code:
...
		case 8: {
			cmdBlockSounds(id);
			cmdShowSettingsMenu(id);
		}
...
Instead I'm going to the first one which is just logic, but any idea how to stay at the 2nd?
I'm using new menu system.
Attached Thumbnails
Click image for larger version

Name:	2014-05-29_00003.jpg
Views:	123
Size:	89.3 KB
ID:	133922  

Last edited by wAyz; 05-29-2014 at 06:52.
wAyz is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-29-2014 , 06:52   Re: little menu problem
Reply With Quote #2

Code:
/**
 * Displays a menu to one client.  This should never be called from a handler 
 * when the item is less than 0 (i.e. calling this from a cancelled menu will 
 * result in an error).
 *
 * @param id			Client index.
 * @param menu			Menu resource identifier.
 * @param page			Page to start from (starting from 0).
 * @noreturn
 * @error				Invalid menu resource or client index.
 */
native menu_display(id, menu, page=0);
jimaway is offline
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 05-29-2014 , 06:54   Re: little menu problem
Reply With Quote #3

Quote:
Originally Posted by jimaway View Post
Code:
/**
 * Displays a menu to one client.  This should never be called from a handler 
 * when the item is less than 0 (i.e. calling this from a cancelled menu will 
 * result in an error).
 *
 * @param id			Client index.
 * @param menu			Menu resource identifier.
 * @param page			Page to start from (starting from 0).
 * @noreturn
 * @error				Invalid menu resource or client index.
 */
native menu_display(id, menu, page=0);
I tried this:

Code:
...
		case 8: {
			cmdBlockSounds(id);
		        menu_display(id, menu, 2)
		}
...
am I wrong with that? Doesn't work.

Last edited by wAyz; 05-29-2014 at 06:56.
wAyz is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-29-2014 , 06:57   Re: little menu problem
Reply With Quote #4

Maybe, if this doesn't work, you should post a bit more of the code to see what exactly 'menu' is and which cases you switch, etc, etc...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 05-29-2014 , 06:58   Re: little menu problem
Reply With Quote #5

Code:
public cmdShowSettingsMenu(id) {
	if(!is_user_alive(id) || !is_user_localhost(id)) {
		return PLUGIN_HANDLED;
	}
	
	new sTemp[128];
	new menu = menu_create("\yKZ Demo Plugin: \wSettings", "handlerShowSettingsMenu") ;
	
	formatex(sTemp, charsmax(sTemp), "\wAuto heal 10'000 HP:%s", g_bHealsOnMap ? (get_pcvar_num(g_pcvarAutoheal) == 1 ? "\y ON" : "\r OFF") : "\d Couldn't find HP booster");
	menu_additem(menu, sTemp, "1");
	
	formatex(sTemp, charsmax(sTemp), "\wGod mode:%s", get_pcvar_num(g_pcvarGodmode) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "2");
	
	formatex(sTemp, charsmax(sTemp), "\wShow timer:%s", g_bShowTimer[id] ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "3");
	
	formatex(sTemp, charsmax(sTemp), "\wSave start angles:%s", get_pcvar_num(g_pcvarStartAngles) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "4");	
	
	formatex(sTemp, charsmax(sTemp), "\wSave cp angles:%s", get_pcvar_num(g_pcvarCPAngles) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "5");
	
	formatex(sTemp, charsmax(sTemp), "\wBlock join to CT:%s", get_pcvar_num(g_pcvarBlockCT) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "6");
	
	formatex(sTemp, charsmax(sTemp), "\wShow demo attempts:%s", get_pcvar_num(g_pcvarAttempt) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "7");
	
	formatex(sTemp, charsmax(sTemp), "\wBlock startround sounds:%s^n", get_pcvar_num(g_pcvarBlockSounds) == 1 ? "\y ON" : "\r OFF");
	menu_additem(menu, sTemp, "8");
	
	menu_display(id, menu, 0);
	
	return PLUGIN_HANDLED;
}





public handlerShowSettingsMenu(id, menu, item) {
	if(item == MENU_EXIT) {
		menu_destroy(menu);
		
		return PLUGIN_HANDLED;
	}
	
	new sData[6];
	new iAccess, iCallback;
	
	menu_item_getinfo(menu, item, iAccess, sData, charsmax(sData), _, _, iCallback);
	
	switch(str_to_num(sData)) {
		case 1: {
			cmdAutoheal(id);
			cmdShowSettingsMenu(id);
		}
		case 2: {
			cmdGodmode(id);
			cmdShowSettingsMenu(id);
		}
		case 3: {
			cmdTimer(id);
			cmdShowSettingsMenu(id);
		}
		case 4: {
			cmdStartAngles(id);
			cmdShowSettingsMenu(id);
		}
		case 5: {
			cmdCPAngles(id);
			cmdShowSettingsMenu(id);
		}
		case 6: {
			cmdBlockCT(id);
			cmdShowSettingsMenu(id);
		}
		case 7: {
			cmdAttempt(id);
			cmdShowSettingsMenu(id);
		}
		case 8: {
			cmdBlockSounds(id);
			cmdShowSettingsMenu(id);
		}
	}
	
	menu_destroy(menu);
	
	return PLUGIN_HANDLED;
}

Last edited by wAyz; 05-29-2014 at 06:59.
wAyz is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-29-2014 , 07:04   Re: little menu problem
Reply With Quote #6

Page to start from (starting from 0).

Code:
menu_display(id, menu, 1)
jimaway is offline
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 05-29-2014 , 07:07   Re: little menu problem
Reply With Quote #7

Quote:
Originally Posted by jimaway View Post
Page to start from (starting from 0).

Code:
menu_display(id, menu, 1)
That seems to work better but the whole menu is closing after I toggle it more
than one time o0
wAyz is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-29-2014 , 07:12   Re: little menu problem
Reply With Quote #8

you are destroying the menu, and it isn't re-created

i suggest you create the menu into a global variable and change the ON/OFF text in menu callback. destroy the menu in plugin_end

Last edited by jimaway; 05-29-2014 at 07:14.
jimaway 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 05:58.


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