Raised This Month: $ Target: $400
 0% 

Menu help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iPro
Junior Member
Join Date: Jun 2012
Old 06-27-2012 , 10:16   Menu help.
Reply With Quote #1

How to create a menu that opens when players press a key? Like he/she presses M and there pops a menu up.
Thanx.
iPro is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-27-2012 , 10:26   Re: Menu help.
Reply With Quote #2

I do that for you : Do you want that ?
Code:
#include < amxmodx > #include < fun > public plugin_init( ) {     register_plugin( "test menu" , "1.0" , "Aooka" );         register_clcmd( "say m" , "CmdMenu" ); } public CmdMenu( const id ) {     new iMenu = menu_create( "TITLE OF MY MENU" , "FUNCTION" );     menu_additem( iMenu , "I want an Awp" , "1" , 0 );     menu_additem( iMenu , "I want an Ak" , "2" , 0 );     // you can add other menu_additem         menu_display( id , iMenu , 0 ); // show the menu         menu_setprop( iMenu , MPROP_EXITNAME , "Exit" ); // Close it } public FUNCTION( const id , iMenu , item ) {     if( iMenu != MENU_EXIT )     {         switch( item )         {             case 1:                 give_item( id , "weapon_awp" );             case 2:                 give_item( id , "weapon_ak47" );         }     }     else         return 1;     return 0; }
__________________
Pawn ? Useless
Aooka is offline
iPro
Junior Member
Join Date: Jun 2012
Old 06-27-2012 , 10:39   Re: Menu help.
Reply With Quote #3

Quote:
Originally Posted by Aooka View Post
I do that for you : Do you want that ?
Code:
#include < amxmodx > #include < fun > public plugin_init( ) { &nbsp;&nbsp;&nbsp;&nbsp;register_plugin( "test menu" , "1.0" , "Aooka" ); &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;register_clcmd( "say m" , "CmdMenu" ); } public CmdMenu( const id ) { &nbsp;&nbsp;&nbsp;&nbsp;new iMenu = menu_create( "TITLE OF MY MENU" , "FUNCTION" ); &nbsp;&nbsp;&nbsp;&nbsp;menu_additem( iMenu , "I want an Awp" , "1" , 0 ); &nbsp;&nbsp;&nbsp;&nbsp;menu_additem( iMenu , "I want an Ak" , "2" , 0 ); &nbsp;&nbsp;&nbsp;&nbsp;// you can add other menu_additem &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;menu_display( id , iMenu , 0 ); // show the menu &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;menu_setprop( iMenu , MPROP_EXITNAME , "Exit" ); // Close it } public FUNCTION( const id , iMenu , item ) { &nbsp;&nbsp;&nbsp;&nbsp;if( iMenu != MENU_EXIT ) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;switch( item ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;case 1: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;give_item( id , "weapon_awp" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;case 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;give_item( id , "weapon_ak47" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;} &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;return 1; &nbsp;&nbsp;&nbsp;&nbsp;return 0; }
I didnt really want the whole code, but thanx! Now i figured out!
iPro is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-27-2012 , 10:47   Re: Menu help.
Reply With Quote #4

No problem and guy, you can look the tuto by Emp` , very good !
http://forums.alliedmods.net/showthread.php?t=46364
__________________
Pawn ? Useless
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-27-2012 , 10:47   Re: Menu help.
Reply With Quote #5

Hook jointeam and chooseteam commands and show the menu there. You should also check if the user is a CT/T and block them with PLUGIN_HANDLED.
__________________
<VeCo> is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-27-2012 , 12:36   Re: Menu help.
Reply With Quote #6

Quote:
Originally Posted by Aooka View Post
I do that for you : Do you want that ?
Code:
#include < amxmodx > #include < fun > public plugin_init( ) { &nbsp;&nbsp;&nbsp;&nbsp;register_plugin( "test menu" , "1.0" , "Aooka" ); &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;register_clcmd( "say m" , "CmdMenu" ); } public CmdMenu( const id ) { &nbsp;&nbsp;&nbsp;&nbsp;new iMenu = menu_create( "TITLE OF MY MENU" , "FUNCTION" ); &nbsp;&nbsp;&nbsp;&nbsp;menu_additem( iMenu , "I want an Awp" , "1" , 0 ); &nbsp;&nbsp;&nbsp;&nbsp;menu_additem( iMenu , "I want an Ak" , "2" , 0 ); &nbsp;&nbsp;&nbsp;&nbsp;// you can add other menu_additem &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;menu_display( id , iMenu , 0 ); // show the menu &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;menu_setprop( iMenu , MPROP_EXITNAME , "Exit" ); // Close it } public FUNCTION( const id , iMenu , item ) { &nbsp;&nbsp;&nbsp;&nbsp;if( iMenu != MENU_EXIT ) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;switch( item ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;case 1: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;give_item( id , "weapon_awp" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;case 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;give_item( id , "weapon_ak47" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;} &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;return 1; &nbsp;&nbsp;&nbsp;&nbsp;return 0; }
This is wrong, he want's a menu opens on keypress and not by saying 'm'.

Like @<VeCo> said you have to hook chooseteam & jointeam commands.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-27-2012 , 12:40   Re: Menu help.
Reply With Quote #7

Oh yes , I did not pay attention
__________________
Pawn ? Useless
Aooka is offline
iPro
Junior Member
Join Date: Jun 2012
Old 06-27-2012 , 14:31   Re: Menu help.
Reply With Quote #8

Quote:
Originally Posted by <VeCo> View Post
Hook jointeam and chooseteam commands and show the menu there. You should also check if the user is a CT/T and block them with PLUGIN_HANDLED.
how?
iPro is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-27-2012 , 14:40   Re: Menu help.
Reply With Quote #9

PHP Code:
// ...
register_clcmd("jointeam","ClCmd_Player_ChangeTeam")
register_clcmd("chooseteam","ClCmd_Player_ChangeTeam")
// ...
 
public ClCmd_Player_ChangeTeam(id)
{
new 
CsTeams:i_team cs_get_user_team(id)
 
if(
CS_TEAM_UNASSIGNED i_team CS_TEAM_SPECTATOR)
{
// call menu func here...
return PLUGIN_HANDLED
}
 
return 
PLUGIN_CONTINUE

__________________
<VeCo> 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 06:14.


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