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)

Drak 05-22-2009 21:52

Re: New AMXX Menu System
 
The Item Param seems to send off "0-MAX_ITEMS". Why do we do "menu_additem(Menu,"Text","1");"?

This simply works:
Code:
new Menu = menu_create("Hello World","_MyMenu"); menu_addtext(Menu,"Test"); public _MyMenu(id,Menu,Item) {     switch(Item)     {         case 0: client_print(id,print_chat,"Test Selected.");     } }

Emp` 05-22-2009 22:12

Re: New AMXX Menu System
 
Quote:

Originally Posted by Drak (Post 832753)
The Item Param seems to send off "0-MAX_ITEMS". Why do we do "menu_additem(Menu,"Text","1");"?

This simply works:
Code:
new Menu = menu_create("Hello World","_MyMenu"); menu_addtext(Menu,"Test"); public _MyMenu(id,Menu,Item) {     switch(Item)     {         case 0: client_print(id,print_chat,"Test Selected.");     } }

While that works, the other method gives people a better understanding of the menus for different things. Also, if you want to reorganize a menu, you can just change where it is added, with this method you would need to change where it is added and the code in the handler function.

anchit211 05-29-2009 08:01

Re: New AMXX Menu System
 
hey i want to make a basic menu and as soon as aplaer joins the menu is displayed to him automatically and he can select an option how to do this??

fysiks 05-29-2009 19:12

Re: New AMXX Menu System
 
You might be able to show the menu on client_putinserver(id) or you can do it on first spawn using Ham and a bool check to see if it's the first spawn.

anchit211 05-30-2009 06:11

Re: New AMXX Menu System
 
can u just give me the coding part for this i mean any exmaple for showing the menu i am not a programmer u see and i need it for a plugin

edga85 07-02-2009 18:06

Re: New AMXX Menu System
 
So somebody can make example how to make that menu shows only admins....

AntiBots 07-02-2009 20:48

Re: New AMXX Menu System
 
Quote:

Originally Posted by edga85 (Post 862767)
So somebody can make example how to make that menu shows only admins....

I dont code any thing time ago, so sorry if I do something wrong :P

PHP Code:

#include <amxmodx>
#include <amxmisc>

new g_bAdmin[33]

new 
g_iMaxPlayers

public plugin_init()
{
    
register_plugin("Show Admin""1.0""ReymonARG")
    
    
register_clcmd("say /lala""chat")
    
    
g_iMaxPlayers get_maxplayers()
}

public 
client_putinserver(id)
{
    
g_bAdmin[id] = bool:is_user_admin(id)
}

public 
client_disconnect(id)
{
    
g_bAdmin[id] = false
}

public 
chat(id)
{
    
openmenu(id0)
    return 
PLUGIN_HANDLED
}

stock openmenu(idpage)
{        
    static 
menumenu menu_create("\r[ReymonARG] \yAdmin Show Menu""menuaccion")
    static 
StrMsg[64], StrName[32], iStrNum[3]
    
    for(
1<= g_iMaxPlayers i++)
    {
        if( !
g_bAdmin[i] ) continue;
        
        
get_user_name(iStrName31);  num_to_str(iStrNum2)
        
        
formatex(StrMsg63"%s"StrName)
        
menu_additem(menuStrMsgStrNum)
    }
    
    
menu_display(idmenupage)
    
    return 
PLUGIN_HANDLED;
}

public 
menuaccion(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        return 
PLUGIN_HANDLED
    
}
    
    static 
iStrData[3]; menu_item_getinfo(menuitemiStrData2__i)
    static 
szName[32];
    
    
str_to_num(StrData)
    
get_user_name(iszName31);
    
    if( 
g_bAdmin[i] )
        
client_print(idprint_chat"You Select Admin: %s"szName)
    
    
openmenu(id0)
    return 
PLUGIN_HANDLED



edga85 07-03-2009 07:26

Re: New AMXX Menu System
 
Quote:

Originally Posted by AntiBots (Post 862832)
I dont code any thing time ago, so sorry if I do something wrong :P

PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_bAdmin[33]
 
new 
g_iMaxPlayers
 
public plugin_init()
{
    
register_plugin("Show Admin""1.0""ReymonARG")
 
    
register_clcmd("say /lala""chat")
 
    
g_iMaxPlayers get_maxplayers()
}
 
public 
client_putinserver(id)
{
    
g_bAdmin[id] = bool:is_user_admin(id)
}
 
public 
client_disconnect(id)
{
    
g_bAdmin[id] = false
}
 
public 
chat(id)
{
    
openmenu(id0)
    return 
PLUGIN_HANDLED
}
 
stock openmenu(idpage)
{        
    static 
menumenu menu_create("\r[ReymonARG] \yAdmin Show Menu""menuaccion")
    static 
StrMsg[64], StrName[32], iStrNum[3]
 
    for(
1<= g_iMaxPlayers i++)
    {
        if( !
g_bAdmin[i] ) continue;
 
        
get_user_name(iStrName31);  num_to_str(iStrNum2)
 
        
formatex(StrMsg63"%s"StrName)
        
menu_additem(menuStrMsgStrNum)
    }
 
    
menu_display(idmenupage)
 
    return 
PLUGIN_HANDLED;
}
 
public 
menuaccion(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        return 
PLUGIN_HANDLED
    
}
 
    static 
iStrData[3]; menu_item_getinfo(menuitemiStrData2__i)
    static 
szName[32];
 
    
str_to_num(StrData)
    
get_user_name(iszName31);
 
    if( 
g_bAdmin[i] )
        
client_print(idprint_chat"You Select Admin: %s"szName)
 
    
openmenu(id0)
    return 
PLUGIN_HANDLED



Not working... :(

fysiks 07-03-2009 19:41

Re: New AMXX Menu System
 
Quote:

Originally Posted by edga85 (Post 862767)
So somebody can make example how to make that menu shows only admins....

Emp's player menu example with admin check (see highlighted lines):

Code:
#include <amxmodx>  #include <amxmisc>  #include <fun>  public plugin_init()  {     //Register a way to get to your menu...     register_clcmd( "my_player_menu","AwesomeMenu");  }  public AwesomeMenu(id)  {     //Create a variable to hold the menu     new menu = menu_create("\rLook at this Player Menu!:", "menu_handler");     //We will need to create some variables so we can loop through all the players     new players[32], pnum, tempid;     //Some variables to hold information about the players     new szName[32], szTempid[10];     //Fill players with available players     get_players(players, pnum);     //Start looping through all players     for( new i; i<pnum; i++ )     {         //Save a tempid so we do not re-index         tempid = players[i];        
        if( is_user_admin(tempid) )
        {
            //Get the players name and id as strings             get_user_name(tempid, szName, 31);             num_to_str(tempid, szTempid, 9);             //Add the item for this player             menu_additem(menu, szName, szTempid, 0);
        }
    }     //We now have all players in the menu, lets display the menu     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);     //Get the id of the player that was selected     new tempid = str_to_num(data);     //If the player is alive     if( is_user_alive(tempid) )         //Set their health to 100         set_user_health(tempid, 100);     menu_destroy(menu);     return PLUGIN_HANDLED;  }

VMAN 07-08-2009 20:41

Re: New AMXX Menu System
 
This topic is very helpful.


All times are GMT -4. The time now is 16:52.

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