Raised This Month: $32 Target: $400
 8% 

Menu & Team Help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stressful
Senior Member
Join Date: Feb 2011
Old 06-24-2011 , 04:55   Menu & Team Help!
Reply With Quote #1

Hello ,
  1. I need help with this menu , I need this menu to appear at the start when the player first join . Once only & it should remember the players choice.
  2. And by typing /menu , The player can renable the menu just like how it is done in Zombie Plague Mod . The /gun renabling part .
  3. As for the "Team" Code , I need it to be like , For T : Case 1 / 2 / 3 menu is for them . And another Cases 1/2/3 for CT .
PHP Code:
#include <amxmodx>

 
public plugin_init()
 {
    
//..stuff for your plugin

    
register_clcmd"my_awesome_menu","AwesomeMenu");
    
//note that we do not need to register the menu anymore, but just a way to get to it
 
}
 
//lets make the function that will make the menu
 
public AwesomeMenu(id)
 {
    
//first we need to make a variable that will hold the menu
    
new menu menu_create("\rLook at this awesome Menu!:""menu_handler");
    
//Note - menu_create
    //The first parameter  is what the menu will be titled (what is at the very top)
    //The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)

    //Now lets add some things to select from the menu
    
menu_additem(menu"\wI'm Selection #1""1"0);
    
menu_additem(menu"\wI'm Selection #2""2"0);
    
menu_additem(menu"\wI'm Secret Selection #3""3"ADMIN_ADMIN);
    
//Note - menu_additem
    //The first parameter is which menu we will be adding this item/selection to
    //The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
    //The third parameter is data that we want to send with this item
    //The fourth parameter is which admin flag we want to be able to access this item (I have had no experience with this, so I am just assuming this is how it works. It uses the admin flags from the amxconst.inc)

    //Set a property on the menu
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
//Note - menu_setprop
    //The first parameter is the menu to modify
    //The second parameter is what to modify (found in amxconst.inc)
    //The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)

    //Lets display the menu
    
menu_display(idmenu0);
    
//Note - menu_display
    //The first parameter is which index to show it to (you cannot show this to everyone at once)
    //The second parameter is which menu to show them (in this case, the one we just made)
    //The third parameter is which page to start them on
 
}
 
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
 
public menu_handler(idmenuitem)
 {
    
//we don't want to deal with them if they exited a menu
    
if( item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
//Note that you will want to destroy the menu after they do something
        
return PLUGIN_HANDLED;
    }

    
//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
    
new data[6], szName[64];
    new 
accesscallback;
    
//heres the function that will give us that information (since it doesnt magicaly appear)
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    
//Note - that you can do this next step how you want, this is just the way I prefer

    //looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
    
new key str_to_num(data);
    
//note that all my datas were numbers (you can do it with whatever type of string you want)

    //now lets find which item was pressed
    
switch(key)
    {
        case 
1:
        {
            
client_print(idprint_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(idprint_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(idprint_chat"You have selected the Awesome Admin Selection! Hail Teh Bail!");
        }
    }

    
//lets finish up this function with a menu_destroy, and a return
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 } 

Last edited by Stressful; 06-24-2011 at 05:07.
Stressful is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2011 , 05:20   Re: Menu & Team Help!
Reply With Quote #2

No need to post code from a tutorial. This should be in scripting help as it seems you are asking for advice on how to write the code.

1a. Call the menu on client_putinserver() or on first spawn.
1b. Use a global array (g_iPlayerSetting[33]) to save the players setting (g_iPlayerSetting[id]).
2. Just register the client command "say /menu".
3. Build one menu for T and different one for CT.
__________________
fysiks is offline
Stressful
Senior Member
Join Date: Feb 2011
Old 06-24-2011 , 05:37   Re: Menu & Team Help!
Reply With Quote #3

Ok the 2nd & 3rd one understood . Thanks
But is there anyway to mix the T & CT menu tgt? :O

Last edited by Stressful; 06-24-2011 at 10:39.
Stressful is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2011 , 13:41   Re: Menu & Team Help!
Reply With Quote #4

Quote:
Originally Posted by Stressful View Post
But is there anyway to mix the T & CT menu tgt? :O
What does that mean?
__________________
fysiks is offline
Stressful
Senior Member
Join Date: Feb 2011
Old 06-24-2011 , 22:17   Re: Menu & Team Help!
Reply With Quote #5

Like case 1 /2 /3 for T then another cases for CT.
Stressful is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2011 , 00:13   Re: Menu & Team Help!
Reply With Quote #6

Quote:
Originally Posted by Stressful View Post
Like case 1 /2 /3 for T then another cases for CT.
You mean you want two different menus, one for each team? That is easy, you make the CT menu if the person is CT and the T menu if the person is T.
__________________
fysiks is offline
Stressful
Senior Member
Join Date: Feb 2011
Old 06-25-2011 , 11:46   Re: Menu & Team Help!
Reply With Quote #7

Yeah . Means what? :O
PHP Code:
    if ( cs_get_user_team(id) == CS_TEAM_T )
   switch(
key
    { 
        case 
1
        { 
            
client_print(idprint_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(idprint_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(idprint_chat"You have selected the Awesome Admin Selection! Hail Teh Bail!"); 
        } 
    } 
PHP Code:
if ( cs_get_user_team(id) == CS_TEAM_CT )
   switch(
key
    { 
        case 
1
        { 
            
client_print(idprint_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(idprint_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(idprint_chat"You have selected the Awesome Admin Selection! Hail Teh Bail!"); 
        } 
    } 
?? Lol but I think this doesn't seem to work .
Stressful is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2011 , 15:48   Re: Menu & Team Help!
Reply With Quote #8

Use two separate menus and only show the correct menu to the player. So, you will only need to check their team when you are showing the menus. Then you already have two separate menu handlers so you don't need to check the team there.
__________________
fysiks is offline
Stressful
Senior Member
Join Date: Feb 2011
Old 06-25-2011 , 22:59   Re: Menu & Team Help!
Reply With Quote #9

Orh Ok thanks
Stressful is offline
Reply


Thread Tools
Display Modes

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 15:44.


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