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

Menus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 15:01   Menus
Reply With Quote #1

Can someone show me how to write a menu? AMX documentation looks outdated. I used AMXX-Studio's Menu Generator and that just confused me more....

so far i have....
Code:
public cmdAdminMenu(id, level, cid)
{
	if(!cmd_access(id, level, cide, 1))
		return PLUGIN_HANDLED
	/* Menu BKF Admin */
	/* Use menu_display(id, mBKFAdmin, 0) to show the menu to an user. */
	m_adminMenu = menu_create("BKF Admin", "mh_BKFAdmin")
	menu_additem(a_adminMenu, "Set Player Level", "1", ADMIN_KICK)
	menu_additem(a_adminMenu, "Set Player Frags", "ma_BKFAdmin", ADMIN_KICK, mcbBKFAdmin)
	menu_additem(a_adminMenu, "Give Player Frags", "ma_BKFAdmin", ADMIN_KICK, mcbBKFAdmin)
	menu_additem(a_adminMenu, "Prune Vault", "ma_BKFAdmin", ADMIN_BAN, mcbBKFAdmin)
	menu_additem(a_adminMenu, "Set CVARs", "ma_BKFAdmin", ADMIN_CFG, mcbBKFAdmin)
	/* Menu End */

	menu_display(id, a_adminMenu, 0)
	return PLUGIN_HANDLED
}

public mh_BKFAdmin(id, menu, item) 
{
	switch(item)
	{
		case 0:
			// is that how it works?
		default:
			menu_destroy()
			
	}
	return PLUGIN_HANDLED
}

public ma_BKFAdmin(id) {
	/* This event is called when an item was selected */
}
public mcb_BKFAdmin(id, menu, item) {
	/* This is the callback-event, here you can set items enabled or disabled. */
	/* If you want to enable an item, use: return ITEM_ENABLED */
	/* If you want to disable an item, use: return ITEM_DISABLED */
}
I called cmdAdminMenu from client_concmd(\\stuffs)
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-17-2012 , 15:07   Re: Menus
Reply With Quote #2

have you tried reading the menu tut ?
http://forums.alliedmods.net/showthread.php?t=46364

Last edited by EpicMonkey; 05-17-2012 at 15:43.
EpicMonkey is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 15:14   Re: Menus
Reply With Quote #3

Quote:
Originally Posted by EpicMonkey View Post
I have now!

Many thanks.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 05-17-2012 at 15:14.
Liverwiz is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-17-2012 , 17:41   Re: Menus
Reply With Quote #4

An empty menu if you still didnt came further.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /test""CmdTest")
}

public 
CmdTest(id)
{
    new 
menu menu_create("Menu title""Menuhandler")
    
    
menu_additem(menu"Option 1""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
Menuhandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64], accescallback
    menu_item_getinfo
(menuitemaccesdatacharsmax(data), namecharsmax(name), callback)
    new 
key str_to_num(data)
    
    switch (
key)
    {
        case 
1client_print(idprint_center"Awesome u pressed the first option!")
        }
    return 
PLUGIN_HANDLED

__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.

Last edited by Bilal Pro; 05-17-2012 at 17:41.
Bilal Pro is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-17-2012 , 18:27   Re: Menus
Reply With Quote #5

You should destroy the menu in the handler btw.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-17-2012 , 19:26   Re: Menus
Reply With Quote #6

I did?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 05-17-2012 , 20:02   Re: Menus
Reply With Quote #7

Quote:
Originally Posted by Bilal Pro View Post
I did?
You did, if they press exit.

He means you should at the end of the function.
__________________
Hi.
Kreation is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 20:41   Re: Menus
Reply With Quote #8

I've got another question. Is there a way for a menu's handler to return a value to its calling function.
For instance.....i want the client to choose a value, then implement the chosen value in the calling function.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 20:42   Re: Menus
Reply With Quote #9

Quote:
Originally Posted by mottzi View Post
You should destroy the menu in the handler btw.
He had a bunch of errors in that code. But i got what he was trying to say. That tut that EpicMonkey posted was awesome.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 05-17-2012 , 20:48   Re: Menus
Reply With Quote #10

Quote:
Originally Posted by mottzi View Post
You should destroy the menu in the handler btw.
thatīs really necesary?
__________________
Steam: stickp0le
StickP0le 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 09:22.


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