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)

Alka 12-28-2007 17:57

Re: New AMXX Menu System
 
You don't need to make button 8 for that option anyway, make it on button 7 or whatever...Buttons "Next / Back" and "Exit" are maded automaticly.

Gizmo 12-28-2007 19:13

Re: New AMXX Menu System
 
What i want is a switch ban times button in a playermenu (all the players on the server in the menu) so each time i press that button it cycle throu the ban times
and when i want to ban a player and press that players name he shall get banned with the bantime value visible in the menu right then, i hope i make sence here :S

Alka 12-29-2007 06:07

Re: New AMXX Menu System
 
Yeah, but with new amxx menu system is a bit hard...because you can't make a button that stays permanently on bottom of page...like in old style menu, but you already have this on "amxmodmenu" ...default by amxmodx.

Gizmo 12-29-2007 09:00

Re: New AMXX Menu System
 
I have been helping Lantz on amxbans alot and i was thinking of trying to use the new menus in amxbans.
I know a way to do it.
Playermenu where you select a player and when you press the player a ban time menu appears and when you select a bantime a reson menu appears but i dont like that way to do it :(

soccdoodcss 01-02-2008 12:29

Re: New AMXX Menu System
 
I believe it would be possible to store the ban time in a global variable. When you press the menu button it should cycle through the ban time once and reshow the menu again. If you understand what I mean?

JFeldon 01-04-2008 18:34

Re: New AMXX Menu System
 
Nice tutorial, helped me. I find this menu system a lot easier, and since I don't often use dynamic menus it's great for me. +Karma ;D

purple_pixie 01-09-2008 08:03

Re: New AMXX Menu System
 
Is there any chance of someone explaining / tutorialising the callback stuff?

IIRC you do something fancy with making a callback handle with a function name, and then passing that in, but the bit I don't really get is how to, say, remove options for a player.

If I took the time and trouble I'm sure I could learn this jazz, but I'm fairly sure someone already has, and isn't that the point of Snippets/Tutorials?

Generally I create / destroy a menu every time it is used, but at times it is useful to adjust a menu on the fly.

Alka 01-09-2008 09:22

Re: New AMXX Menu System
 
Hmm, lemme give you an eg:

Code:

new Menu = menu_create("\ySome Menu", "MenuHandler");
 new CallBack = menu_makecallback("MenuCallBack"); //Here is the trick.
 
 new Players[32], Num, Name[32];
 get_players(Players, Num, "ch");
 
 for(new i = 0 ; i < Num ; i++)
 {
  get_user_name(Players[i], Name, sizeof Name - 1);
 
  menu_additem(Menu, Name, "", 0, CallBack);
 }
 
 menu_display(id, Menu, 0);

This just make the menu and showit to players with callback option.

Code:

new iAccess, Name[32], iCallback;
 menu_item_getinfo(menu, item, iAccess, "", 0, Name, sizeof Name - 1, iCallback);
 
 new Target = get_user_index(Name); //Get the menu item name, in ower case is a player name.
 
 return is_user_admin(Target) ? ITEM_ENABLED : ITEM_DISABLED; //Now, if the Target player is an admin, then he will have the item enabled, else disabled.

This is the "MenuCallBack" public. Here we can disable, enable and skip a menu item. ;)

purple_pixie 01-09-2008 10:13

Re: New AMXX Menu System
 
And I would use menu_item_setname to screw with their text before showing onscreen?

Funky.

And thankyou.

Alka 01-09-2008 11:28

Re: New AMXX Menu System
 
Quote:

Originally Posted by purple_pixie (Post 572169)
And I would use menu_item_setname to screw with their text before showing onscreen?

Funky.

And thankyou.

Yeah, you can do that...oh, and np :wink:

linkosc 02-10-2008 06:21

Re: New AMXX Menu System
 
Hello All, Nub here :) I don't understand Any of the tutorials on Building menus. EX: the commands I dont know what they mean or do lol SOrry.
Anyhow Im working on a mod and I need some help with my menu system.
http://forums.alliedmods.net/showthread.php?t=66808 < thats were I originally posted for help. But.... I dont understand how it was explained to me. I will Post the Code Here: and THere So yall can help me, If ya want. Would be greatfully appreciated!:) Im not even sure Im using the New Menu system . LOL . Im really new so Dont Bash Hard :shock:
Actually Check out that forum Ill post on there tommorow. Sleepy

Merko 03-26-2008 21:56

Re: New AMXX Menu System
 
Hello :)

Just started with AMX Scripting. This was my first tutorial and it worked fine! :)

Thanks for great tut :]

PoSiTiOn Of PoWeR 05-18-2008 17:49

Re: New AMXX Menu System
 
very nice Emp` :mrgreen:

KingCommentor 07-29-2008 00:29

Re: New AMXX Menu System
 
Where is the client cmd that they actually say to get the menu up ?

PvtSmithFSSF 07-31-2008 22:28

Re: New AMXX Menu System
 
Quote:

Originally Posted by KingCommentor (Post 660773)
Where is the client cmd that they actually say to get the menu up ?

on line 7..

minimiller 08-17-2008 17:35

Re: New AMXX Menu System
 
Really nubbish question coming up...
How do i show the menu to all players on the server?
Its probly really easy to do, but my brain isnt working today :(

Emp` 08-17-2008 18:19

Re: New AMXX Menu System
 
Code:

new players[32], pnum;
get_players(players, pnum);
for( new i=0; i<pnum; i++ )
    menu_display(players[i], menu, 0);


AntiBots 09-25-2008 17:42

Re: New AMXX Menu System
 
You can put a Example to put more pages, Example, "Next Page..." Without do a menu2 :D

minimiller 09-25-2008 17:59

Re: New AMXX Menu System
 
u dont need a menu2
just put "cases"
if u do 11 cases, page1 will show the first 7; back; and next
then page2 will show 8, 9, 10, and 11
not too hard :)

AntiBots 09-25-2008 18:23

Re: New AMXX Menu System
 
Quote:

Originally Posted by minimiller (Post 690891)
u dont need a menu2
just put "cases"
if u do 11 cases, page1 will show the first 7; back; and next
then page2 will show 8, 9, 10, and 11
not too hard :)

how I can change the text of next and Exit?

IneedHelp 09-25-2008 19:07

Re: New AMXX Menu System
 
See newmenus.inc

PHP Code:

#define MPROP_BACKNAME    2        /* Name of the back button (param1 = string) */
#define MPROP_NEXTNAME    3        /* Name of the next button (param1 = string) */
#define MPROP_EXITNAME    4        /* Name of the exit button (param1 = string) */ 

I Think that this was the method to change that names:

PHP Code:

menu_setprop(MenuMPROP_NEXTNAME"Name"

PHP Code:

menu_setprop(MenuMPROP_EXITNAME"Exit Button name"

If i'm wrong, correct me please.

minimiller 09-25-2008 19:15

Re: New AMXX Menu System
 
that sounds about right to me

emsu66 11-04-2008 00:10

Re: New AMXX Menu System
 
Okay so, I have TWO problems!

1) Basically what I'm trying to do is create a system where Player A would say killchance in chat and has a chance (lets say 1/10) for a menu to come up. Would someone please provide an example on how I could make the odds (1/10) happen?

2) The point of my plugin is to get a chance at basically slaying someone of your choice through the effects of chance. I would like to add a menu of all the players in the current server to this one command that you may or may not win. How could I link an actual PLAYER to the menu instead of an item?

Basic Layout (What I'm Shooting For) :
1) Player B consistently kills player A.
2) Player A says killchance in chat and wins the 1/10 chance that he gets to slay him for a round!
3) Player A looks over the list and finds Player B so he hits his menu key (lets say 2)
4) Player B drops dead.
5) Player A has a good round =)

+Karma and credit in my plugin to whoever can give the slightest bit of help, thanks!

-Plugin will be called Random Kill Chance v1.0 if approved!

IneedHelp 11-04-2008 10:52

Re: New AMXX Menu System
 
Quote:

Originally Posted by emsu66
1) Basically what I'm trying to do is create a system where Player A would say killchance in chat and has a chance (lets say 1/10) for a menu to come up. Would someone please provide an example on how I could make the odds (1/10) happen?

PHP Code:

register_clcmd("say killchance""killchance")

[...]

public 
killchance(id)
{
         if (
random_num(010) == 7)
         {
                  
// Display menu here
         
}
         return 
PLUGIN_CONTINUE


You can do that menu with this tut..

emsu66 11-12-2008 16:00

Re: New AMXX Menu System
 
Yes that is very helpful and I will definately use that but that's not what I'm ultimately having trouble with. What I'm trying to do is instead of ITEMS coming up on the menu I would like players' names to come up so that they can slay that selected player.

Thanks,
emsu66

+Credit to you and Emp too!
+Karma if you and/or anyone can help me figure this one out!

Emp` 11-13-2008 01:00

Re: New AMXX Menu System
 
for the second param of menu_additem, use a string that has the players name (with get_user_name)

pass the players id within data (with num_to_str) then read the data (with str_to_num)

so total example would be:
Code:

function(id)
{
    new menu = menu_create("\rPlayer Menu:", "menu_handler");

    new name[32], id_string[5];
    new players[32], pnum, i, pid;
    get_players(players, pnum);
    for( i=0; i<pnum; i++ ){
        pid = players[i];
        get_user_name(pid, name, 31);
        num_to_str(pid, id_string, 4);
        menu_additem(menu, name, id_string);
    }

    menu_display(id, menu, 0);
}
public menu_handler(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
    new data[6], iName[64];
    new access, callback;
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

    new pid = str_to_num(data);
    // slay pid

    menu_destroy(menu);
    return PLUGIN_HANDLED;
}


AntiBots 11-19-2008 09:42

Re: New AMXX Menu System
 
how i can remove the num of page?

Exolent[jNr] 11-19-2008 11:22

Re: New AMXX Menu System
 
You have to use Old Style.

pro_on_0 11-25-2008 07:23

Re: New AMXX Menu System
 
O......very helpful....Thank you very much!

Particlman 12-21-2008 20:05

Re: New AMXX Menu System
 
I'm probably going to hit myself when you tell me what I did wrong but here.

I want the text of the item in the menu to not be defined there. I want it to be taken from outside. It kinda works right now but not really.

This is what I have.

Code:

new const BRANCH[] = {
        "None",
        "Army",
        "Marines"
}

Code:

public ChangeBranch(id)
{
        new branchmenu = menu_create("Branch Menu", "Branch_Handle");
        menu_additem(branchmenu, BRANCH[1], "1", 0);
        menu_additem(branchmenu, BRANCH[2], "2", 0);
        menu_setprop(branchmenu, MPROP_EXIT, MEXIT_ALL);
        menu_display(id, branchmenu, 0);
        return PLUGIN_CONTINUE;
}

The basis for the menu is taken from the XP tutorial but the only thing I really changed was the second param in menu_additem.
If there is a better way the menu should be done tell me please.

/changebranch opens ChangeBranch()

The way it works now is when I type /changebranch in game it gives me
Quote:

1. None
2. one
Have another similar problem but knowing how to fix this will fix that too.

Emp` 12-21-2008 22:37

Re: New AMXX Menu System
 
try
Code:

new const BRANCH[][] = {
        "None",
        "Army",
        "Marines"
}


Particlman 12-21-2008 23:30

Re: New AMXX Menu System
 
I swear I tried that at some point and it gave me a lot of errors down the line.
I must have miss typed it or something the first time cause this time it only gave me 2 errors yelling at me about one thing not having the 2nd [] in there so just threw those in there and tested it and everything works now.

Thank you.

DarkMidoriko 12-22-2008 02:08

Re: New AMXX Menu System
 
I'm having a problem, while writing and testing my code i found a small bug and don't know why it is occuring.

So this code makes it so that when you spawn a menu will show up with multiple pages.

If someone were to ignore it and hit the "Select Team" key, which will remove the menu and open up the Team Selection Menu. But on the next round if you try to go to the next page it will bring up the Team Selection Menu.

Instead of the "Select Team" key, the "Equipment Menu" was hit. On the next round you can go to the next page, but if you try to go back, it will send you to the previous page, but you would have bought a "Shield".

So if anyone knows how to fix this problem, any help would be appreciated. I've tested it with the tutorial code as well and i get the same outcome.

Code:

#include <amxmodx>
#include <hamsandwich>

new bool:FirstSpawn[33]
public plugin_init()
{
    RegisterHam        (Ham_Spawn, "player", "Player_Spawn", 1)
}
public Player_Spawn(id)
{
    if( !is_user_alive(id) )
    // this spawn occurs when a player connects to the server, so this is a good place to reset the value
        {
            FirstSpawn[id] = true
            return
        }
    FirstSpawn[id] = false
   
    new menu = menu_create("Faction Menu" , "Class_Menu")
    menu_additem(menu ,"Test1", "1" , 0);
    menu_additem(menu ,"Test2", "2" , 0);
    menu_additem(menu ,"Test3", "3" , 0);
    menu_additem(menu ,"Test4", "4" , 0);
    menu_additem(menu ,"Test5", "5" , 0);
    menu_additem(menu ,"Test6", "6" , 0);
    menu_additem(menu ,"Test7", "7" , 0);
    menu_additem(menu ,"Test8", "8" , 0);
    menu_additem(menu ,"Test9", "9" , 0);

    //Set exit
    menu_setprop(menu , MPROP_EXIT , MEXIT_ALL);
       
    //Show menu
    menu_display(id , menu , 0);
}
public Class_Menu(id , menu , item)
{
    //If he choice exit then destroy the menu
    if(item == MENU_EXIT)
    {   
        menu_destroy(menu);   
        return PLUGIN_HANDLED
    }
    //Sorting code goes here
    menu_destroy(menu);   
    return PLUGIN_HANDLED
}


fysiks 01-07-2009 14:12

Re: New AMXX Menu System
 
Quote:

public menu_handler(id, menu, item)


So, does "item" here return one of the following?:

Code:


#define MENU_KEY_1  (1<<0)
#define MENU_KEY_2  (1<<1)
#define MENU_KEY_3  (1<<2)
#define MENU_KEY_4  (1<<3)
#define MENU_KEY_5  (1<<4)
#define MENU_KEY_6  (1<<5)
#define MENU_KEY_7  (1<<6)
#define MENU_KEY_8  (1<<7)
#define MENU_KEY_9  (1<<8)
#define MENU_KEY_0  (1<<9)
#define MENU_EXIT -3
#define MENU_BACK -2
#define MENU_MORE -1

Also, in mapchooser.sma (old menu system I think), the menu command is countVote(id,key) and key returns a number 0 to 6. So, in this case it's not returning one of the MENU_KEY_#?

Basically, I'm confused by the vars passed to the function assigned to the menu.

tuty 01-12-2009 15:02

Re: New AMXX Menu System
 
good job emp'

i gonna like this kind of menu
:)

Owyn 03-10-2009 15:12

Re: New AMXX Menu System
 
Code:

        case 1:{
            client_print(id, print_chat, "Hooray! You selected the Awesome 1st Selection")
            //note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
            menu_destroy(menu)
            return PLUGIN_HANDLED
        }
        case 2:{
            client_print(id, print_chat, "OH NO! You selected the Awesome 2nd Selection! BEWARE!")
        }
        case 3:{ //again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
            client_print(id, print_chat, "You have selected the Awesome Admin Selection! Hail Teh Bail!")
            menu_destroy(menu)
            return PLUGIN_HANDLED

why does case2 has no menu destroy and no return?

Emp` 03-30-2009 13:54

Re: New AMXX Menu System
 
Added an example player menu to main post.

alan_el_more 03-30-2009 19:52

Re: New AMXX Menu System
 
Thank you, i needed much :D

Drak 04-05-2009 01:10

Re: New AMXX Menu System
 
I'm curious, if I have:
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("amx_newmenu","newMenu");     register_clcmd("amx_oldmenu","oldMenu"); } public NewMenu(id) {     new Menu = menu_create("My New Menu","SomeFunction");         menu_additem(Menu,"Blah");     menu_additem(Menu,"Blah 2");     menu_additem(Menu,"Blah 3");         menu_display(id,Menu); } public SomeFunction() {} public OldMenu(id) {     new Menu[128]     format(Menu,127,"My Old Menu^n^n1. Blah^n2. Blah 2^n3. Blah 3");     show_menu(id,MENU_KEY_0,Menu); }

What if I called "NewMenu" and then, before I destory the menu, i call "OldMenu". Will the instance of that menu, ever be destroyed? I figure if i call "NewMenu" again, it will just make another menu.

fysiks 04-05-2009 18:17

Re: New AMXX Menu System
 
I tried to pass a long string (long -> >6 charaters) and it didn't work. It seems I'm limited to data[6] :(. Is this correct?

I was trying to avoid using newplayername[33][32] to pass the new name through to the handler.


All times are GMT -4. The time now is 02:21.

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