AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   New AMXX Menu System (https://forums.alliedmods.net/showthread.php?t=46364)

Hawk552 10-24-2006 22:04

Re: New AMXX Menu System
 
Quote:

Originally Posted by k007 (Post 394927)
hawk i saw your post and i understand but im asking this guy who thinks hes the smart ass, and he thinks he could do it and u think u need to delet the item everytime u change the cvar..i want see if he could prove u wrong!

I'm speaking out of personal experiences, and the last time I even touched it was when it was still in beta stages (half the functions, which I didn't even use anyway, were totally broken or essential things were missing).

I'm not trying to spark an argument, I just think his comment "hope this will start people to sway from the old style menus" is sort of stupid as they both have their uses.

Brad 10-24-2006 22:21

Re: New AMXX Menu System
 
The new menu system has grown up, some kinks worked out. You should try using it again.

Emp` 10-24-2006 22:22

Re: New AMXX Menu System
 
Quote:

Originally Posted by Hawk552 (Post 394938)
I'm not trying to spark an argument, I just think his comment "hope this will start people to sway from the old style menus" is sort of stupid as they both have their uses.

i now agree now that i see the faults. i however, will continue to use it though.

k007 10-24-2006 22:45

Re: New AMXX Menu System
 
well could u guys show me how now?

Emp` 10-24-2006 23:28

Re: New AMXX Menu System
 
Code:

new something[60]
format(something, 59, "wowz... %d", get_pcvar_num(wowz))
menu_additem(menu, something, "1", 0)

you should know that...

k007 10-24-2006 23:29

Re: New AMXX Menu System
 
ok thanks man ill try it

BAILOPAN 10-24-2006 23:52

Re: New AMXX Menu System
 
Hawk: you're being ignored because what you're saying has no relevance to the tutorial. Whatever design flaws you think it has aren't relevant to teaching how to use it.

In general, menus are static. For menus that are dynamic, they're usually short lived, which means it's appropriate to destroy them and create a new one. This was an efficiency trade-off since the data structure used to store menus is O(1) lookup but O(n) for mid-insertion/deletion.

For the sake of argument, let's consider your world where you can delete items on a menu:

1. Menu broadcasts to all players.
2. Player 1 selects something on the menu.
3. Menu handler deletes item N in response to action #2.
4. Player 2 selects an item that is now keyed to the wrong slot.
5. Menu handler passes the wrong item # and screws up internal bookkeeping in your plugin.

Solving a problem like this is expensive - you need to reshuffle the entire items pool, and then create a temporary data structure on each player which re-maps the old keys to the new ones. All of this takes memory, CPU, and man-hours to test and debug, when all you had to do was start a new menu (which is what you'd do with an old menu anyway, if you look closely).

You can't just say an API is deficient at something without understanding why certain decisions were made. As soon as you add unnecessary complexity, someone will abuse it, and then you're stuck supporting it for backwards compatibility.

You're historically mostly right about newmenus. They were introduced for www.esportsea.com a while ago with extra features (the menu system there allows menus to timeout). At the same time I wrote the system for CSDM. However I thought it had too much potential to stick around there and merged it into AMX Mod X.

Note that if you're getting hung up on the dynamicness of newmenus, you've missed their entire point. The point of newmenus is abstracting menu termination and pagination, the former which is vital to state-oriented plugins (the kind I am wont to write).

Hawk552 10-25-2006 15:38

Re: New AMXX Menu System
 
Quote:

Originally Posted by BAILOPAN (Post 394976)
Hawk: you're being ignored because what you're saying has no relevance to the tutorial. Whatever design flaws you think it has aren't relevant to teaching how to use it.

In general, menus are static. For menus that are dynamic, they're usually short lived, which means it's appropriate to destroy them and create a new one. This was an efficiency trade-off since the data structure used to store menus is O(1) lookup but O(n) for mid-insertion/deletion.

For the sake of argument, let's consider your world where you can delete items on a menu:

1. Menu broadcasts to all players.
2. Player 1 selects something on the menu.
3. Menu handler deletes item N in response to action #2.
4. Player 2 selects an item that is now keyed to the wrong slot.
5. Menu handler passes the wrong item # and screws up internal bookkeeping in your plugin.

Solving a problem like this is expensive - you need to reshuffle the entire items pool, and then create a temporary data structure on each player which re-maps the old keys to the new ones. All of this takes memory, CPU, and man-hours to test and debug, when all you had to do was start a new menu (which is what you'd do with an old menu anyway, if you look closely).

You can't just say an API is deficient at something without understanding why certain decisions were made. As soon as you add unnecessary complexity, someone will abuse it, and then you're stuck supporting it for backwards compatibility.

You're historically mostly right about newmenus. They were introduced for www.esportsea.com a while ago with extra features (the menu system there allows menus to timeout). At the same time I wrote the system for CSDM. However I thought it had too much potential to stick around there and merged it into AMX Mod X.

Note that if you're getting hung up on the dynamicness of newmenus, you've missed their entire point. The point of newmenus is abstracting menu termination and pagination, the former which is vital to state-oriented plugins (the kind I am wont to write).

Sorry if I came off as bashing it, what I meant is that it's just undeniably easier to use the old menu system when you need to dynamically add and remove items.

Anyway, I don't think the tutorial has anything to do with me being ignored - I was responding to k007's questions of implementation, since I think for what he's doing it would be much easier to use old style menus.

But as for the system itself, it does accomplish the paging, colors etc. with flying colors, but IMO it is very very far from being the be-all end-all.

As for the design decisions, I see what you mean, but you have to remember that I'm looking at it as someone that has never used it before (although I have) and I see that there are a number of things that are very confusing (as I said before, changing items). While the implementation may be fast, it's harder to learn. Since I'm starting to repeat myself, I'm just going to leave it at old menus being better for dynamic changes, and new menus being better for more static implementations.

Identity 03-14-2007 02:24

Re: New AMXX Menu System
 
Quote:

public menu_handler(id, menu, item)
{
//we don't want to deal with them if they exited a menu
if (item == MENU_EXIT)
{
menu_destroy(menu)
//Note that you will want to destroy the menu after they do something
return PLUGIN_HANDLED
}
Quote:

//lets finish up this function with a menu_destroy, and a return
menu_destroy(menu)
return PLUGIN_HANDLED
}
amxmodx.inc
//Destroys a menu - invalidates the handle
//This is safe, as it will go through the players and make
// sure they don't have this menu set anymore.

native menu_destroy(menu);

So this really executed after last menu_destroy called and in the example above it used correctly?

Minimum 03-17-2007 13:04

Re: New AMXX Menu System
 
Very nice tutorial. Helped me understand the new menu system very well. +karma and credit in my plugin for you.


All times are GMT -4. The time now is 08:40.

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