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

New AMXX Menu System


Post New Thread Reply   
 
Thread Tools Display Modes
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 08-18-2009 , 17:04   Re: New AMXX Menu System
Reply With Quote #131

Quote:
Originally Posted by Exolent[jNr] View Post
Doesn't work.
I've tried it and it gave me an error in the logs saying that you can't have more than 7 per page.
Yeah, I've tried it too. But is there any other way to make it?
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!

LaineN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-18-2009 , 17:06   Re: New AMXX Menu System
Reply With Quote #132

Quote:
Originally Posted by LaineN View Post
Yeah, I've tried it too. But is there any other way to make it?
Just use 0 and add the exit button yourself.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 08-18-2009 , 17:07   Re: New AMXX Menu System
Reply With Quote #133

Quote:
Originally Posted by Exolent[jNr] View Post
Just use 0 and add the exit button yourself.
Okey, thanks. But what about the other problem? With the 'AMX Mod X Menu'? Do you know how to solve it?

EDIT: Can I add the exit button by using MENU_EXIT? Or I have to use like the old menu system?
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!

LaineN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-18-2009 , 17:17   Re: New AMXX Menu System
Reply With Quote #134

Code:
static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
{
	int ilen = 0, ilen2 = 0;
	char *sMenu = get_amxstring(amx, params[3], 0, ilen);
	char *lMenu = get_amxstring(amx, params[5], 1, ilen2);
	int menuid = 0;
	
	if (ilen2 && lMenu)
	{
		menuid = g_menucmds.findMenuId(lMenu, amx);
	} else {
		menuid = g_menucmds.findMenuId(sMenu, amx);
	}
	
	int keys = params[2];
	int time = params[4];
	
	if (params[1] == 0)
	{
		for (int i = 1; i <= gpGlobals->maxClients; ++i)
		{
			CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);

			if (pPlayer->ingame)
			{
				pPlayer->keys = keys;
				pPlayer->menu = menuid;
				pPlayer->vgui = false;
				
				if (time == -1)
					pPlayer->menuexpire = INFINITE;
				else
					pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
				
				pPlayer->newmenu = -1;
				pPlayer->page = 0;
				UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
			}
		}
	} else {
		int index = params[1];
		
		if (index < 1 || index > gpGlobals->maxClients)
		{
			LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);
			return 0;
		}
		
		CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);

		if (pPlayer->ingame)
		{
			pPlayer->keys = keys;
			pPlayer->menu = menuid;
			pPlayer->vgui = false;			

			if (time == -1)
				pPlayer->menuexpire = INFINITE;
			else
				pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
			
			pPlayer->newmenu = -1;
			pPlayer->page = 0;
			UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
		}
	}
	
	return 1;
}
Code:
// menu_display( ) calls this

bool Menu::Display(int player, page_t page)
{
	int keys = 0;
	const char *str = GetTextString(player, page, keys);

	if (!str)
		return false;

	static char buffer[2048];
	int len = _snprintf(buffer, sizeof(buffer)-1, "%s", str);

	CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);

	pPlayer->keys = keys;
	pPlayer->menu = menuId;
	pPlayer->newmenu = thisId;
	pPlayer->page = (int)page;

	UTIL_ShowMenu(pPlayer->pEdict, keys, -1, buffer, len);

	return true;
}
Code:
void UTIL_ShowMenu(edict_t* pEdict, int slots, int time, char *menu, int mlen)
{
	char *n = menu;
	char c = 0;
	int a;

	if (!gmsgShowMenu)
		return;			// some games don't support ShowMenu (Firearms)

	while (*n)
	{
		a = mlen;
		if (a > 175) a = 175;
		mlen -= a;
		c = *(n+=a);
		*n = 0;
		
		MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
		WRITE_SHORT(slots);
		WRITE_CHAR(time);
		WRITE_BYTE(c ? TRUE : FALSE);
		WRITE_STRING(menu);
		MESSAGE_END();
		*n = c;
		menu = n;
	}
}
The show_menu( ) and menu_display( ) natives send the ShowMenu message straight to the game, so it's impossible to hook when the menu is displayed from another plugin.
Therefore, you cannot hook those menus.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 08-18-2009 , 17:26   Re: New AMXX Menu System
Reply With Quote #135

Quote:
Originally Posted by Exolent[jNr] View Post
The show_menu( ) and menu_display( ) natives send the ShowMenu message straight to the game, so it's impossible to hook when the menu is displayed from another plugin.
Therefore, you cannot hook those menus.
Oh. I have to convert the 'AMX Mod X Menu' to use the new menu system then.

But what about my other question?
Quote:
Originally Posted by LaineN View Post
Can I add the exit button by using MENU_EXIT? Or I have to use like the old menu system?
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!

LaineN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-18-2009 , 17:38   Re: New AMXX Menu System
Reply With Quote #136

Quote:
Originally Posted by LaineN View Post
But what about my other question?
PHP Code:
new menu menu_create("Main Menu""MainMenuHandle");
menu_additem(menu"1""1");
menu_additem(menu"2""2");
menu_additem(menu"3""3");
menu_additem(menu"4""4");
menu_additem(menu"5""5");
menu_additem(menu"6""6");
menu_additem(menu"7""7");
menu_additem(menu"8""8");
menu_addblank(menu0);
menu_additem(menu"Exit""*");
menu_setprop(menuMPROP_PERPAGE0);
menu_display(idmenu);

// ...

public MainMenuHandle(idmenuitem)
{
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfosizeof(info) - 1__callback);
    
    if( 
info[0] == '*' )
    {
        
menu_destroy(menu);
        return;
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 08-18-2009 , 17:42   Re: New AMXX Menu System
Reply With Quote #137

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
new menu menu_create("Main Menu""MainMenuHandle");
menu_additem(menu"1""1");
menu_additem(menu"2""2");
menu_additem(menu"3""3");
menu_additem(menu"4""4");
menu_additem(menu"5""5");
menu_additem(menu"6""6");
menu_additem(menu"7""7");
menu_additem(menu"8""8");
menu_addblank(menu0);
menu_additem(menu"Exit""*");
menu_setprop(menuMPROP_PERPAGE0);
menu_display(idmenu);

// ...

public MainMenuHandle(idmenuitem)
{
    static 
_accessinfo[3], callback;
    
menu_item_getinfo(menuitem_accessinfosizeof(info) - 1__callback);
    
    if( 
info[0] == '*' )
    {
        
menu_destroy(menu);
        return;
    }

Thanks!
But will the '*' show as 0 in-game?
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!

LaineN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-18-2009 , 17:52   Re: New AMXX Menu System
Reply With Quote #138

Quote:
Originally Posted by LaineN View Post
Thanks!
But will the '*' show as 0 in-game?
The * is the info sent to the handler, not the number shown next to the item.
The item number will be 9. You can try adding another blank, but i think it will be 10 and not 0.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 08-19-2009 , 05:20   Re: New AMXX Menu System
Reply With Quote #139

Hi, i have a question... how can i remove the "EXIT" Option?

Yes, i know:

Quote:
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
But i dont understand how to use it... i tried with menu_setprop but failed.

Thx to much.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 08-19-2009 , 07:21   Re: New AMXX Menu System
Reply With Quote #140

Quote:
Originally Posted by Alucard^ View Post
Hi, i have a question... how can i remove the "EXIT" Option?
menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!

LaineN 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 11:42.


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