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

New AMXX Menu System


Post New Thread Reply   
 
Thread Tools Display Modes
Drak
Veteran Member
Join Date: Jul 2005
Old 05-22-2009 , 20:52   Re: New AMXX Menu System
Reply With Quote #101

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.");     } }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 05-22-2009 , 21:12   Re: New AMXX Menu System
Reply With Quote #102

Quote:
Originally Posted by Drak View Post
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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
anchit211
Member
Join Date: Mar 2009
Old 05-29-2009 , 07:01   Re: New AMXX Menu System
Reply With Quote #103

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??
anchit211 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-29-2009 , 18:12   Re: New AMXX Menu System
Reply With Quote #104

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.
__________________
fysiks is offline
anchit211
Member
Join Date: Mar 2009
Old 05-30-2009 , 05:11   Re: New AMXX Menu System
Reply With Quote #105

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
anchit211 is offline
edga85
BANNED
Join Date: Jan 2009
Old 07-02-2009 , 17:06   Re: New AMXX Menu System
Reply With Quote #106

So somebody can make example how to make that menu shows only admins....
edga85 is offline
Send a message via Skype™ to edga85
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 07-02-2009 , 19:48   Re: New AMXX Menu System
Reply With Quote #107

Quote:
Originally Posted by edga85 View Post
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

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

__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
edga85
BANNED
Join Date: Jan 2009
Old 07-03-2009 , 06:26   Re: New AMXX Menu System
Reply With Quote #108

Quote:
Originally Posted by AntiBots View Post
I dont code any thing time ago, so sorry if I do something wrong

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...
edga85 is offline
Send a message via Skype™ to edga85
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-03-2009 , 18:41   Re: New AMXX Menu System
Reply With Quote #109

Quote:
Originally Posted by edga85 View Post
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;  }
__________________
fysiks is offline
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 07-08-2009 , 19:41   Re: New AMXX Menu System
Reply With Quote #110

This topic is very helpful.
VMAN 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 07:15.


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