Raised This Month: $ Target: $400
 0% 

Menu to change knives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 05-04-2013 , 12:20   Menu to change knives
Reply With Quote #1

Hello,

I would like to create menu, that contains 20 models of different knives, but I don't know how to start with that, and I don't know how to do it aswell. Can I have some tips for that?
It should look like that:

1. BlaBlaKnife (Sets Blablabla model knife)
.....
20. ASDASDASDKnife (Sets ASDASDASD model knife)

Thanks

Last edited by danonix; 05-04-2013 at 12:21.
danonix is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 05-04-2013 , 12:26   Re: Menu to change knives
Reply With Quote #2

You can start by reading this.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
danonix
Senior Member
Join Date: Dec 2012
Old 05-04-2013 , 16:28   Re: Menu to change knives
Reply With Quote #3

Thanks for the link, I think this menu would be the best there, wouldn't be it?

But I should make there 4~ handlers, for each one 5 choices. Isn't there a simplier way?
Code:
 #include <amxmodx>   public plugin_init()  {     register_clcmd( "my_awesome_menu","AwesomeMenu" );  }  public AwesomeMenu( id )  {     new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" )      //Note that our data is 'm' to know it is from the main menu     menu_additem( menu, "\wI'm Selection #1", "m", 0 );     menu_additem( menu, "\wGo to SubMenu", "m", 0 );      menu_display( id, menu, 0 );  }  SubMenu( id )  {     new menu = menu_create( "\rLook at this awesome Sub-Menu!:", "menu_handler" )      //Note that our data is 's' to know it is from the sub menu     menu_additem( menu, "\wI'm Sub-Selection #1", "s", 0 );     menu_additem( menu, "\wI'm Sub-Selection #2", "s", 0 );      menu_display( id, menu, 0 );  }  public menu_handler( id, menu, item )  {     if ( item == MENU_EXIT )     {         menu_destroy( menu );         return PLUGIN_HANDLED;     }      new szData[6], szName[64];     new item_access, item_callback;     menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );      //Switch based on the first character of the data ( the 'm' or the 's')     switch( szData[0] )     {         //All our main menu data will be handled in this case         case 'm':         {             switch( item )             {                 case 0:                 {                     client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );                 }                 case 1:                 {                     SubMenu( id );                 }             }         }         //All our sub menu data will be handled in this case         case 's':         {             switch( item )             {                 case 0:                 {                     client_print( id, print_chat, "Hooray! You selected the Awesome 1st Sub-Selection" );                 }                 case 1:                 {                     client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Sub-Selection! BEWARE!" );                 }             }              //Note that this is still only for our sub menu             AwesomeMenu( id );         }     }      menu_destroy( menu );     return PLUGIN_HANDLED;  }


Last edited by danonix; 05-04-2013 at 16:29.
danonix is offline
danonix
Senior Member
Join Date: Dec 2012
Old 05-04-2013 , 16:29   Re: Menu to change knives
Reply With Quote #4

PHP Code:
 #include <amxmodx>   public plugin_init()  {     register_clcmd( "my_awesome_menu","AwesomeMenu" );  }  public AwesomeMenu( id )  {     new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" )      //Note that our data is 'm' to know it is from the main menu     menu_additem( menu, "\wI'm Selection #1", "m", 0 );     menu_additem( menu, "\wGo to SubMenu", "m", 0 );      menu_display( id, menu, 0 );  }  SubMenu( id )  {     new menu = menu_create( "\rLook at this awesome Sub-Menu!:", "menu_handler" )      //Note that our data is 's' to know it is from the sub menu     menu_additem( menu, "\wI'm Sub-Selection #1", "s", 0 );     menu_additem( menu, "\wI'm Sub-Selection #2", "s", 0 );      menu_display( id, menu, 0 );  }  public menu_handler( id, menu, item )  {     if ( item == MENU_EXIT )     {         menu_destroy( menu );         return PLUGIN_HANDLED;     }      new szData[6], szName[64];     new item_access, item_callback;     menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );      //Switch based on the first character of the data ( the 'm' or the 's')     switch( szData[0] )     {         //All our main menu data will be handled in this case         case 'm':         {             switch( item )             {                 case 0:                 {                     client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );                 }                 case 1:                 {                     SubMenu( id );                 }             }         }         //All our sub menu data will be handled in this case         case 's':         {             switch( item )             {                 case 0:                 {                     client_print( id, print_chat, "Hooray! You selected the Awesome 1st Sub-Selection" );                 }                 case 1:                 {                     client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Sub-Selection! BEWARE!" );                 }             }              //Note that this is still only for our sub menu             AwesomeMenu( id );         }     }      menu_destroy( menu );     return PLUGIN_HANDLED;  } 
Watts wrong with this code lol. So I would like to use this menu - "Multiple Menus with 1 Handler [top]" at all.

Last edited by danonix; 05-04-2013 at 16:30.
danonix is offline
danonix
Senior Member
Join Date: Dec 2012
Old 05-05-2013 , 15:21   Re: Menu to change knives
Reply With Quote #5

Ok, I know how to do the menu, but what with 29 cases? How I can do it, so I dont have to make 5 handlers in menu, but plugin will read itself and make new pages, when one is full? Is it possible?
danonix is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-05-2013 , 15:36   Re: Menu to change knives
Reply With Quote #6

Quote:
Originally Posted by danonix View Post
Ok, I know how to do the menu, but what with 29 cases? How I can do it, so I dont have to make 5 handlers in menu, but plugin will read itself and make new pages, when one is full? Is it possible?
this new menu system what you have will do it for you.
.Dare Devil. is offline
danonix
Senior Member
Join Date: Dec 2012
Old 05-06-2013 , 09:18   Re: Menu to change knives
Reply With Quote #7

Quote:
Originally Posted by .Dare Devil. View Post
this new menu system what you have will do it for you.

Could you show me plugin that contains it? It would be great.

Last edited by danonix; 05-06-2013 at 09:18.
danonix is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-06-2013 , 11:27   Re: Menu to change knives
Reply With Quote #8

There is a Tutorial for it, go search
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
yan1255
Senior Member
Join Date: Jul 2011
Old 05-06-2013 , 14:20   Re: Menu to change knives
Reply With Quote #9

hmmm... I made this quickly... try to understand...
this code is 112 lines
PHP Code:
/* Includes */
    #include < amxmodx >
    #include < fakemeta_util >
    #include < engine >

/* Enums */
    
enum KnivesData
    
{
        
KnifeName32 ],
        
KnifeModel64 ]
    };
    
/* Arrays */    
    
new Info][ ] =
    {
        
"Knife Change",
        
"1.0",
        
"Rejack"
    
};
    
    new 
g_iKnives[ ][ KnivesData ] =
    {
        { 
"Knife 1""models/v_knife1" },
        { 
"Knife 2""models/v_knife2" },
        { 
"Knife 3""models/v_knife3" },
        { 
"Knife 4""models/v_knife4" },
        { 
"Knife 5""models/v_knife5" },
        { 
"Knife 6""models/v_knife6" },
        { 
"Knife 7""models/v_knife7" },
        { 
"Knife 8""models/v_knife8" },
        { 
"Knife 9""models/v_knife9" },
        { 
"Knife 10""models/v_knife10" },
        { 
"Knife 11""models/v_knife11" },
        { 
"Knife 12""models/v_knife12" },
        { 
"Knife 13""models/v_knife13" },
        { 
"Knife 14""models/v_knife14" },
        { 
"Knife 15""models/v_knife15" },
        { 
"Knife 16""models/v_knife16" },
        { 
"Knife 17""models/v_knife17" },
        { 
"Knife 18""models/v_knife18" },
        { 
"Knife 19""models/v_knife19" },
        { 
"Knife 20""models/v_knife20" }
    };
    
    new 
Knife33 ];

public 
plugin_init()
{
    
register_pluginInfo], Info], Info] );
    
    
register_clcmd"say /knife""CmdKnife" );
    
    
register_event"CurWeapon""evCurWeapon""be""1=1" );
}

public 
CmdKnifeclient )
{
    if ( !
is_user_aliveclient ) )
        return 
1;
    
    new 
Menu menu_create"\r[AMXX]\w Knife Changer""SubKnife" );
    
    new 
szItem128 ];
    
    for ( new 
isizeof g_iKnivesi++ )
    {
        
formatexszItemcharsmaxszItem ), "%s - \d[\r Sets %s Model \d]"g_iKnives][ KnifeName ], g_iKnives][ KnifeName ] );
        
        
menu_additemMenuszItem );
    }
    
    
menu_displayclientMenu );
    
    return 
0;
}

public 
SubKnifeclientMenuItem )
{
    if ( 
Item == MENU_EXIT || !is_user_aliveclient ) )
    {
        
menu_destroyMenu );
        
        return 
1;
    }
    
    
Knifeclient ] = Item;
    
    
client_printclientprint_chat"Your current knife is '%s'"g_iKnivesKnifeclient ] ][ KnifeName ] );
    
    
fm_strip_user_gunclient_"weapon_knife" );
    
    
fm_give_itemclient"weapon_knife" );
    
    
menu_destroyMenu );
    
    return 
1;
}

public 
evCurWeaponclient )
{
    if ( !
is_user_aliveclient ) || !is_user_connectedclient ) )
        return 
1;
        
    new 
Trash];
    
    
Trash] = get_user_weaponclientTrash], Trash] );
    
    if ( 
Trash] == CSW_KNIFE )
        
entity_set_stringclientEV_SZ_viewmodelg_iKnivesKnifeclient ] ][ KnifeModel ] );
    
    return 
0;

In case you want me to shorten the code... I did...
this code is 51 lines
PHP Code:
#include < amxmodx >
#include < fakemeta_util >
#include < engine >
enum KnivesData{
    
KnifeName32 ],
    
KnifeModel64 ]
};
new 
g_iKnives[ ][ KnivesData ] = {
    { 
"Knife 1""models/v_knife1" },{ "Knife 2""models/v_knife2" },{ "Knife 3""models/v_knife3" },{ "Knife 4""models/v_knife4" },{ "Knife 5""models/v_knife5" },
    { 
"Knife 6""models/v_knife6" },{ "Knife 7""models/v_knife7" },{ "Knife 8""models/v_knife8" },{ "Knife 9""models/v_knife9" },{ "Knife 10""models/v_knife10" },
    { 
"Knife 11""models/v_knife11" },{ "Knife 12""models/v_knife12" },{ "Knife 13""models/v_knife13" },{ "Knife 14""models/v_knife14" },{ "Knife 15""models/v_knife15" },
    { 
"Knife 16""models/v_knife16" },{ "Knife 17""models/v_knife17" },    { "Knife 18""models/v_knife18" },{ "Knife 19""models/v_knife19" },{ "Knife 20""models/v_knife20" }
};
new 
Knife33 ];
public 
plugin_init(){
    
register_plugin"Knife Changer""1.0""Rejack" );
    
register_clcmd"say /knife""CmdKnife" );
    
register_event"CurWeapon""evCurWeapon""be""1=1" );
}
public 
CmdKnifeclient ){
    if ( !
is_user_aliveclient ) )
        return 
1;
    new 
Menu menu_create"\r[AMXX]\w Knife Changer""SubKnife" );
    new 
szItem128 ];
    for ( new 
isizeof g_iKnivesi++ ){
        
formatexszItemcharsmaxszItem ), "%s - \d[\r Sets %s Model \d]"g_iKnives][ KnifeName ], g_iKnives][ KnifeName ] );    
        
menu_additemMenuszItem );
    }
    
menu_displayclientMenu );
    return 
0;
}
public 
SubKnifeclientMenuItem ){
    if ( 
Item == MENU_EXIT || !is_user_aliveclient ) ){
        
menu_destroyMenu );
        return 
1;
    }
    
Knifeclient ] = Item;
    
client_printclientprint_chat"Your current knife is '%s'"g_iKnivesKnifeclient ] ][ KnifeName ] );
    
fm_strip_user_gunclient_"weapon_knife" );
    
fm_give_itemclient"weapon_knife" );
    
menu_destroyMenu );
    return 
1;
}
public 
evCurWeaponclient ){
    if ( !
is_user_aliveclient ) || !is_user_connectedclient ) )
        return 
1;
    new 
Trash];Trash] = get_user_weaponclientTrash], Trash] );
    if ( 
Trash] == CSW_KNIFE )
        
entity_set_stringclientEV_SZ_viewmodelg_iKnivesKnifeclient ] ][ KnifeModel ] );
    return 
0;

__________________

Last edited by yan1255; 05-06-2013 at 14:28.
yan1255 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-06-2013 , 14:31   Re: Menu to change knives
Reply With Quote #10

Quote:
Originally Posted by yan1255 View Post
In case you want me to shorten the code... I did...
The code is identical, you didn't shorten it. Getting rid of white space does not constitute smaller code. The number of lines doesn't mean anything. Also, I would get into the habit of NOT using fakemeta_util, it is not efficient.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou 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 10:51.


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