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

Solved how to add item for the category number 8 of the menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-25-2022 , 11:30   how to add item for the category number 8 of the menu
Reply With Quote #1

how to add item for the category number 8 of the menu or how to replace an item instead of back category ? I tried some ways but some of these ways do shut down the server and others send error messages:

I tried this but is not work:
PHP Code:
menu_setpropiMenuMPROP_BACKNAMEfmt"\wTest Item %s"IsHouriStartiEnd ) ? "\y[Active]" "\d[Disactive]" ) )

//menu handler:
switch( iItem )
    {
        case 
MENU_EXITmenu_destroyiMenu );
        case 
MENU_BACKclient_print_coloridprint_team_default"^4[Items]^1 Test Item is not active^1.")//, iStart, iEnd )
/// code.... 
It replacing the name but can't press on it, also i wanna use it with array so i dont want to use just 8 categories by using the old menu style or adding menu_setprop( iMenu, MPROP_PERPAGE, 0 ); and use menu_additem
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 02-26-2022 at 13:29.
Supremache is offline
zXCaptainXz
Member
Join Date: May 2017
Old 02-25-2022 , 11:41   Re: how to add item for the category number 8 of the menu
Reply With Quote #2

Use the old menu system and save yourself a lot of headaches.
zXCaptainXz is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-25-2022 , 11:52   Re: how to add item for the category number 8 of the menu
Reply With Quote #3

Quote:
Originally Posted by zXCaptainXz View Post
Use the old menu system and save yourself a lot of headaches.
Read again, also the old menu system is the same of the new but the difference thing is the new has created with stock that let the menu be easier to use, Also I remember i saw it on a plugin but couldn't find it

Edit: is it possible or not with new menu style?


Tried but i can not press the category:
PHP Code:
public CreateSubMenuid )
{
    new 
szPlayersMAX_PLAYERS ], iNumszID], iMenu menu_create"Test""SubMenuHandler" );
    
get_playersszPlayersiNum"ch" );
    
    for( new 
iNumi++)
    {
        
num_to_striszIDcharsmaxszID ) );
        
menu_additemiMenufmt"%n"id ), szID );
    }
    
    
menu_setpropiMenuMPROP_BACKNAME"\wReplace item" )
    
    if( !
menu_pagesiMenu ) )
    {
        
client_printidprint_chat"There's no players found...")
    }
    else 
menu_displayidiMenu, .page );

    return 
PLUGIN_HANDLED;
}

public 
SubMenuHandleridiMenuiItem 
{
    switch( 
iItem )
    {
        case 
MENU_EXITmenu_destroyiMenu );
        case 
MENU_BACKclient_print_coloridprint_team_default"^4[Items]^1 Test category number 8^1.")
    }

    return 
PLUGIN_HANDLED;

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 02-25-2022 at 15:23.
Supremache is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-25-2022 , 17:22   Re: how to add item for the category number 8 of the menu
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=147393
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-25-2022 , 17:42   Re: how to add item for the category number 8 of the menu
Reply With Quote #5

Quote:
Originally Posted by iceeedr View Post
Quote:
I wanna use it with array so i dont want to use just 8 categories by using the old menu style or adding menu_setprop( iMenu, MPROP_PERPAGE, 0 ); and use menu_additem
Quote:
Edit: is it possible or not with new menu style?
If it is possible, how because of If it is not possible then i have no choice i will type a lot with using old menu style
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-25-2022 , 19:40   Re: how to add item for the category number 8 of the menu
Reply With Quote #6

Check if that helps you
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
zXCaptainXz
Member
Join Date: May 2017
Old 02-25-2022 , 21:15   Re: how to add item for the category number 8 of the menu
Reply With Quote #7

Quote:
Originally Posted by Supremache View Post
Read again, also the old menu system is the same of the new but the difference thing is the new has created with stock that let the menu be easier to use, Also I remember i saw it on a plugin but couldn't find it

Edit: is it possible or not with new menu style?
I’m saying that because new menus are not easy to help you out with, they behave differently depending on your AMXX version. I gave up on 1.8.2 menus because they are buggy and a nightmare to customize, it’s just a one trick pony which can only properly do what it does by default.

What AMXX version are you currently using so we can better try to help you?

EDIT: If you need help with old menus, you can check out how they’re done in the base AMXX plugins, they use 8 items with 9 for back and 0 for next.

Last edited by zXCaptainXz; 02-25-2022 at 21:19.
zXCaptainXz is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-26-2022 , 08:44   Re: how to add item for the category number 8 of the menu
Reply With Quote #8

You can easily make a new menu out of the old menu.
Say /menu to pop up our cool menu.

Code:
#include <amxmodx>
#include <amxmisc>

new Array:g_menuItems

new g_playerMenuPage[33]
new g_playerMenuItemData[33][10]

public plugin_init()
{
	g_menuItems = ArrayCreate(32)

	for (new i = 1; i <= 20; i++)
	{
		ArrayPushString(g_menuItems, fmt("Item %d", i))
	}

	register_clcmd("say /menu", "ShowMenu")

	register_menu("Cool Menu", -1, "MenuHandler")
}

public ShowMenu(index)
{
	const itemsPerPage = 7
	new itemCount = ArraySize(g_menuItems)
	new pageCount = floatround(itemCount / float(itemsPerPage), floatround_ceil)
	new page = clamp(g_playerMenuPage[index], 0, pageCount - 1)
	new offset = page * itemsPerPage

	new buffer[32], menu[MAX_MENU_LENGTH], len, key

	len = copy(menu, charsmax(menu), "\yCool Menu")

	if (pageCount > 1)
	{
		len += formatex(menu[len], charsmax(menu) - len, " %d/%d", page + 1, pageCount)
	}

	len += copy(menu[len], charsmax(menu) - len, "^n^n")

	arrayset(g_playerMenuItemData[index], -1, sizeof g_playerMenuItemData[])

	for (new i = offset, limit = min(itemCount, offset + itemsPerPage); i < limit; i++)
	{
		ArrayGetString(g_menuItems, i, buffer, charsmax(buffer))
		g_playerMenuItemData[index][key] = i
		len += formatex(menu[len], charsmax(menu) - len, "\r%d. \w%s^n", ++key, buffer)
	}

	for (new i = key; i <= itemsPerPage; i++)
	{
		len += copy(menu[len], charsmax(menu) - len, "^n")
	}

	if (pageCount > 1)
	{
		if (page > 0)
		{
			len += copy(menu[len], charsmax(menu) - len, "\r8. \wBack^n")
		}
		else
		{
			len += copy(menu[len], charsmax(menu) - len, "\r8. \dBack^n")
		}
		
		if (page < pageCount - 1)
		{
			len += copy(menu[len], charsmax(menu) - len, "\r9. \wMore^n")
		}
		else
		{
			len += copy(menu[len], charsmax(menu) - len, "\r9. \dMore^n")
		}
	}

	len += copy(menu[len], charsmax(menu) - len, "\r0. \wExit")

	g_playerMenuPage[index] = page

	show_menu(index, -1, menu, -1, "Cool Menu")
}

public MenuHandler(index, key)
{
	switch (key)
	{
		case 7:
		{
			// Back
			g_playerMenuPage[index] -= 1
			ShowMenu(index)
		}
		case 8:
		{
			// More
			g_playerMenuPage[index] += 1
			ShowMenu(index)
		}
		case 9:
		{
			// Exit
		}
		default:
		{
			new item = g_playerMenuItemData[index][key]

			if (0 <= item < ArraySize(g_menuItems))
			{
				new buffer[32]
				ArrayGetString(g_menuItems, item, buffer, charsmax(buffer))
				client_print(index, print_chat, "You've selected ^"%s^"", buffer)
			}

			ShowMenu(index)
		}
	}

	return PLUGIN_HANDLED
}
__________________









Last edited by CrazY.; 02-26-2022 at 08:44.
CrazY. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-26-2022 , 13:29   Re: how to add item for the category number 8 of the menu
Reply With Quote #9

I thought it was possible to do this with the new menu system.
Anyway, thank you all I will be using the old system.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-21-2022 , 18:28   Re: how to add item for the category number 8 of the menu
Reply With Quote #10

@CrazY.
I tried using the code you posted but I ran into a problem when I tried to create multiple menus together and I don't know how to fix it, this what i did:

Code:
#include <amxmodx>
#include <amxmisc>

new Array:g_menuItems

enum _:ArrayTest
{
	Location,
	Item[ 32 ]
}

new g_playerMenuPage[33]
new g_menuloction[33]
new g_playerMenuItemData[33][10]
new eData[ ArrayTest ]

public plugin_init()
{
	g_menuItems = ArrayCreate(ArrayTest)

	for (new i = 1; i <= 5; i++)
	{
		eData[ Location ] = 1;
		copy( eData[ Item ], charsmax( eData[ Item ] ), fmt( "Item %d", i ) )
		ArrayPushArray(g_menuItems, eData )
	}
	
	for (new i = 1; i <= 5; i++)
	{
		eData[ Location ] = 2;
		copy( eData[ Item ], charsmax( eData[ Item ] ), fmt( "ItemPlus %d", i ) )
		ArrayPushArray(g_menuItems, eData )
	}

	register_clcmd("say /menu", "@TestMenu")

	register_menu("Cool Menu", -1, "MenuHandler")
}

@TestMenu( id )
{
	new iMenu = menu_create( "\yTest Menu:", "@TestHandler" );
	
	menu_additem( iMenu, "Location One", "1" );
	menu_additem( iMenu, "Location Two", "2" );
	
	menu_display(id, iMenu)
	return PLUGIN_HANDLED;
}

@TestHandler( id, iMenu, iItem ) 
{
	if(iItem != MENU_EXIT) 
	{
		new szData[ 10 ], iUnused;
		menu_item_getinfo( iMenu, iItem, iUnused, szData, charsmax( szData ), .callback = iUnused )
		
		new iItemID = str_to_num( szData ); 
		
		ShowMenu(id, iItemID )
	}
	menu_destroy(iMenu);
	return PLUGIN_HANDLED;

}


public ShowMenu(index, iLocation )
{
	const itemsPerPage = 7
	new itemCount = ArraySize(g_menuItems)
	new pageCount = floatround(itemCount / float(itemsPerPage), floatround_ceil)
	new page = clamp(g_playerMenuPage[index], 0, pageCount - 1)
	new offset = page * itemsPerPage
	g_menuloction[ index ] = iLocation
	new menu[MAX_MENU_LENGTH], len, key

	len = copy(menu, charsmax(menu), "\yCool Menu")

	if (pageCount > 1)
	{
		len += formatex(menu[len], charsmax(menu) - len, " %d/%d", page + 1, pageCount)
	}

	len += copy(menu[len], charsmax(menu) - len, "^n^n")

	arrayset(g_playerMenuItemData[index], -1, sizeof g_playerMenuItemData[])

	for (new i = offset, limit = min(itemCount, offset + itemsPerPage); i < limit; i++)
	{
		ArrayGetArray(g_menuItems, i, eData )
		
		if( eData[ Location ] && eData[ Location ] != iLocation )
		{
			continue;
		}
		
		g_playerMenuItemData[index][key] = i
		
		len += formatex(menu[len], charsmax(menu) - len, "\r%d. \w%s^n", ++key, eData[ Item ])
		
	}

	for (new i = key; i <= itemsPerPage; i++)
	{
		len += copy(menu[len], charsmax(menu) - len, "^n")
	}

	if (pageCount > 1)
	{
		if (page > 0)
		{
			len += copy(menu[len], charsmax(menu) - len, "\r8. \wBack^n")
		}
		else
		{
			len += copy(menu[len], charsmax(menu) - len, "\r8. \dBack^n")
		}
		
		if (page < pageCount - 1)
		{
			len += copy(menu[len], charsmax(menu) - len, "\r9. \wMore^n")
		}
		else
		{
			len += copy(menu[len], charsmax(menu) - len, "\r9. \dMore^n")
		}
	}

	len += copy(menu[len], charsmax(menu) - len, "\r0. \wExit")

	g_playerMenuPage[index] = page

	show_menu(index, -1, menu, -1, "Cool Menu")
}

public MenuHandler(index, key)
{
	switch (key)
	{
		case 7:
		{
			// Back
			g_playerMenuPage[index] -= 1
			ShowMenu(index, g_menuloction[ index ])
		}
		case 8:
		{
			// More
			g_playerMenuPage[index] += 1
			ShowMenu(index, g_menuloction[ index ])
		}
		case 9:
		{
			// Exit
		}
		default:
		{
			new item = g_playerMenuItemData[index][key]

			if (0 <= item < ArraySize(g_menuItems))
			{
				new buffer[32]
				ArrayGetString(g_menuItems, item, buffer, charsmax(buffer))
				client_print(index, print_chat, "You've selected ^"%s^"", buffer)
			}

			ShowMenu(index, g_menuloction[ index ])
		}
	}

	return PLUGIN_HANDLED
}
Menu number one:



Menu number two:



As you can see, they are combined, each menu is reading the same number, not like the new menu style, Please try to test the code to understand more about the issue.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 07:30.


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