Raised This Month: $ Target: $400
 0% 

Menu not showing all options


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-06-2014 , 21:24   Menu not showing all options
Reply With Quote #1

Hi. I made some plugin for my servers with multi-leveled menu:
RegAdminCmd("sm_somemenu", Menu1, ADMFLAG_RESERVATION);
Menu1 works fine:
1. FakeClientCommand(client, "..."); [working good]
2. Menu2(client);
3. Menu3(client);
4. SomeSwitchFunction(client); [working good]

Menu2 and Menu3 are similar:
Code:
new IDs[8] = {0, 1, 2, 3, 4, 5, 6, 7};
new String:Names[8][24] = {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"};
...
public Menu2(client)
{
	new Handle:menu2 = CreateMenu(Menu2Handler);
	for(new i=0; i < sizeof(IDs); i++)
		AddMenuItem(menu2, "", Names[i]);
	SetMenuExitBackButton(menu2, true);
	SetMenuExitButton(menu2, true);
	SetMenuTitle(menu2, "[Max-Play.pl]");
	DisplayMenu(menu2, client, 30 );
}

public Menu2Handler(Handle:menu3, MenuAction:action, client, args)
{	
	if (action == MenuAction_Select)
	{
		...
		some functions works good for shown items
		...
	}
	else if ((action == MenuAction_Cancel) && (args == MenuCancel_ExitBack))
		Menu1(client, 0);
}
and i've got a problem: when entering e.g into Menu2 we should get 8 items from "Names" but sometimes we've got 7 (without e.g 5th item), sometimes 8 and sometimes even 5 (without 3rd, 6th and 7th items). Randomly. I tried to build menu OnMapStart like here and tried reload map few times and check, and sometimes still menu is built with wrong count of items, and then this menu is broken to next mapchange. It is annoying for me, that it's broken. Anyone could help me? Thanks

Last edited by killerps; 02-07-2014 at 18:55.
killerps is offline
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-07-2014 , 08:09   Re: Menu not showing all options
Reply With Quote #2

example screen - there is no item5, so there is no 'next' option, where should be item8

Last edited by killerps; 02-07-2014 at 08:10.
killerps is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-07-2014 , 08:54   Re: Menu not showing all options
Reply With Quote #3

SetMenuPagination()
bl4nk is offline
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-07-2014 , 10:12   Re: Menu not showing all options
Reply With Quote #4

Quote:
Originally Posted by bl4nk View Post
no effect.
btw: i noticed that usually there is no #5. strange ;/

Last edited by killerps; 02-07-2014 at 10:14.
killerps is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 02-07-2014 , 14:18   Re: Menu not showing all options
Reply With Quote #5

You should getting some wired and awesome silent warning like..
The array size defined is lesser than the string bit.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-07-2014 , 14:55   Re: Menu not showing all options
Reply With Quote #6

no, it is not lesser. sizeof(IDs) always return good count (tested). even if would be wrong, then last item shouldnt be added - not item in middle ( 5th / 8 ).

Last edited by killerps; 02-07-2014 at 15:35.
killerps is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 02-07-2014 , 17:26   Re: Menu not showing all options
Reply With Quote #7

i m talking about the size of the string..
Is the String you try to put inside the array is shorter that the max size of the array?
Or they are barely squeezing them self in it?

EDIT: Yet, i m just guessing since you did not show the actual code..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 02-07-2014 at 17:27.
GsiX is offline
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-07-2014 , 18:50   Re: Menu not showing all options
Reply With Quote #8

longest string: 21chars, in this code defined 24, but i also tried on dynamic array (new String:Names[][]) - the same effect.
killerps is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-08-2014 , 11:38   Re: Menu not showing all options
Reply With Quote #9

You should show whole code if you want help, that snippet not tell anything why its happen.
You maybe messing your global variable String:Names or integer IDs without noticing it.

You could try change this but, we just have to guess and look crystal ball to find your mistake like psychic
PHP Code:
for(new i=0sizeof(IDs); i++)
to
for(new i=0sizeof(Names); i++) 

Last edited by Bacardi; 02-08-2014 at 11:38. Reason: maybe not
Bacardi is offline
killerps
Member
Join Date: Jun 2011
Location: Libusza / Poland
Old 02-08-2014 , 14:40   Re: Menu not showing all options
Reply With Quote #10

all related with menus is here ;x all seems ok?
Code:
new IDs[8] = {0, 1, 2, 3, 4, 5, 6, 7};
new String:Names[8][24] = {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"};
//...
public Action:XMenu1(client, args)
{
	if(client != 0)
	{
		new Handle:menu1 = CreateMenu(Menu1Handler);
		SetMenuTitle(menu1, "[Max-Play.pl]:");
		AddMenuItem(menu1, "0", "other plugin menu");
		AddMenuItem(menu1, "1", "Menu2");
		AddMenuItem(menu1, "2", "Menu3");
		AddMenuItem(menu1, "3", "Function");
		SetMenuExitButton(menu1, true);
		DisplayMenu(menu1, client, 30 );
	}
	return Plugin_Continue;
}

public Menu1Handler(Handle:menu1, MenuAction:action, client, args)
{	
	if (action == MenuAction_Select)
	{
		new String:choice[3];
		GetMenuItem(menu1, args, choice, sizeof(choice));
		switch(StringToInt(choice))
		{
			case 0:
				FakeClientCommand(client, "sm_otherpluginmenu");
			case 1:
				XMenu2(client);
			case 2:
				XMenu3(client);
			case 3:
				Function(client);
		}
	}
	else if(action == MenuAction_End)
		CloseHandle(menu1);
}

public XMenu2(client)
{
	new Handle:menu2 = CreateMenu(Menu2Handler);
	for(new i=0; i < sizeof(IDs); i++)
		AddMenuItem(menu2, "", Names[i]);
	SetMenuExitBackButton(menu2, true);
	SetMenuExitButton(menu2, true);
	SetMenuTitle(menu2, "[Max-Play.pl]");
	DisplayMenu(menu2, client, 30 );
}

public Menu2Handler(Handle:menu3, MenuAction:action, client, args)
{	
	if (action == MenuAction_Select)
	{
		// ...
		// some functions works good for shown items
		// ...
	}
	else if ((action == MenuAction_Cancel) && (args == MenuCancel_ExitBack))
		XMenu1(client, 0);
}
killerps 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 14:36.


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