This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[Menu API]How to disable item in menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-20-2015 , 16:50   [Menu API]How to disable item in menu?
Reply With Quote #1

Hello,

I have easy menu, how to disable item in menu? Example:

PHP Code:
public Action:test(clientargs)
{
    new 
Handle:menuhandle CreateMenu(MenuCallBack);
    
SetMenuTitle(menuhandle"Welcome in menu!");
    
AddMenuItem(menuhandle"green""Green");
    
AddMenuItem(menuhandle"yellow""Yellow");
    
SetMenuPagination(menuhandle7);
    
SetMenuExitButton(menuhandletrue);
    
DisplayMenu(menuhandleclient250);

PHP Code:
public MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:Item[20];
        
GetMenuItem(menuhandlePositionItemsizeof(Item));
        
        if(
StrEqual(Item"green"))
        {
                 
PrintToChat(client"You have selected item Greeen.");
        }

        if(
StrEqual(Item"yellow"))
        {
                 
PrintToChat(client"You have selected item Yellow.");
        }

Ok, I selected item "Green" and how to disable item "Green" and next round is item "Green" enabled. How to make?

Thanks for reply.

Last edited by Fastmancz; 07-20-2015 at 16:55.
Fastmancz is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 07-20-2015 , 16:54   Re: [Menu API]How to disable item in menu?
Reply With Quote #2

AddMenuItem(menuhandle, "green", "Green", ITEMDRAW_DISABLED);
Miu is offline
R1KO
Member
Join Date: Sep 2013
Old 07-20-2015 , 16:56   Re: [Menu API]How to disable item in menu?
Reply With Quote #3

PHP Code:
public MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:Item[20], String:sName[32];
        
GetMenuItem(menuhandlePositionItemsizeof(Item), _sNamesizeof(sName));
        
        if(
StrEqual(Item"green"))
        {
            
PrintToChat(client"You have selected item Greeen.");
        }

        if(
StrEqual(Item"yellow"))
        {
            
PrintToChat(client"You have selected item Yellow.");
        }
        
        
InsertMenuItem(menuhandlePositionItemsNameITEMDRAW_DISABLED);
        
RemoveMenuItem(menuhandlePosition 1);
    } 

Or use MenuAction_DrawItem

Last edited by R1KO; 07-20-2015 at 16:56.
R1KO is offline
Send a message via Skype™ to R1KO
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-20-2015 , 16:57   Re: [Menu API]How to disable item in menu?
Reply With Quote #4

PHP Code:
public Action:test(clientargs)
{
    new 
Handle:menuhandle CreateMenu(MenuCallBack);
    
SetMenuTitle(menuhandle"Welcome in menu!");
    
AddMenuItem(menuhandle"green""Green"ITEMDRAW_DISABLED);
    
AddMenuItem(menuhandle"yellow""Yellow");
    
SetMenuPagination(menuhandle7);
    
SetMenuExitButton(menuhandletrue);
    
DisplayMenu(menuhandleclient250);


Last edited by headline; 07-20-2015 at 16:57.
headline is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-20-2015 , 16:58   Re: [Menu API]How to disable item in menu?
Reply With Quote #5

Quote:
Originally Posted by Miu View Post
AddMenuItem(menuhandle, "green", "Green", ITEMDRAW_DISABLED);
Thanks for reply.
PHP Code:
if(StrEqual(Item"green"))
        {
                 
PrintToChat(client"You have selected item Greeen.");
                 
AddMenuItem(menuhandle"green""Green"ITEMDRAW_DISABLED);
        } 
Or how? I need disabled item "Green" when i selected item.
Fastmancz is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-20-2015 , 17:00   Re: [Menu API]How to disable item in menu?
Reply With Quote #6

Quote:
Originally Posted by R1KO View Post
PHP Code:
public MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:Item[20], String:sName[32];
        
GetMenuItem(menuhandlePositionItemsizeof(Item), _sNamesizeof(sName));
        
        if(
StrEqual(Item"green"))
        {
            
PrintToChat(client"You have selected item Greeen.");
        }

        if(
StrEqual(Item"yellow"))
        {
            
PrintToChat(client"You have selected item Yellow.");
        }
        
        
InsertMenuItem(menuhandlePositionItemsNameITEMDRAW_DISABLED);
        
RemoveMenuItem(menuhandlePosition 1);
    } 

Or use MenuAction_DrawItem
Thanks for reply!
PHP Code:
        InsertMenuItem(menuhandlePositionItemsNameITEMDRAW_DISABLED);
        
RemoveMenuItem(menuhandlePosition 1); 
How would it look in my case? Thanks for reply.
Fastmancz is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-20-2015 , 17:03   Re: [Menu API]How to disable item in menu?
Reply With Quote #7

Quote:
Originally Posted by Fastmancz View Post
Thanks for reply.
PHP Code:
if(StrEqual(Item"green"))
        {
                 
PrintToChat(client"You have selected item Greeen.");
                 
AddMenuItem(menuhandle"green""Green"ITEMDRAW_DISABLED);
        } 
Or how? I need disabled item "Green" when i selected item.
You'd have to create a bool something like this (I think!?!?)

PHP Code:
public Action:test(clientargs)
{
    new 
Handle:menuhandle CreateMenu(MenuCallBack);
    
SetMenuTitle(menuhandle"Welcome in menu!");
    
AddMenuItem(menuhandle"green""Green", (g_bAllowGreen)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED); //if g_bAllowGreen = true then it will show 
    
AddMenuItem(menuhandle"yellow""Yellow");
    
SetMenuPagination(menuhandle7);
    
SetMenuExitButton(menuhandletrue);
    
DisplayMenu(menuhandleclient250);

PHP Code:
public MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:Item[20];
        
GetMenuItem(menuhandlePositionItemsizeof(Item));
    
        if(
StrEqual(Item"green"))
        {
            
g_bAllowGreen false;
            
PrintToChat(client"You have selected item Greeen.");
        }

        if(
StrEqual(Item"yellow"))
        {
                 
PrintToChat(client"You have selected item Yellow.");
        }

If you'd want to re-enable it you'd have to set g_bAllowGreen = to true again

EDIT: Dont forget
PHP Code:
new bool:g_bAllowGreen true

Last edited by headline; 07-20-2015 at 17:08.
headline is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-20-2015 , 17:37   Re: [Menu API]How to disable item in menu?
Reply With Quote #8

Quote:
Originally Posted by Headline22 View Post
You'd have to create a bool something like this (I think!?!?)

PHP Code:
public Action:test(clientargs)
{
    new 
Handle:menuhandle CreateMenu(MenuCallBack);
    
SetMenuTitle(menuhandle"Welcome in menu!");
    
AddMenuItem(menuhandle"green""Green", (g_bAllowGreen)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED); //if g_bAllowGreen = true then it will show 
    
AddMenuItem(menuhandle"yellow""Yellow");
    
SetMenuPagination(menuhandle7);
    
SetMenuExitButton(menuhandletrue);
    
DisplayMenu(menuhandleclient250);

PHP Code:
public MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:Item[20];
        
GetMenuItem(menuhandlePositionItemsizeof(Item));
    
        if(
StrEqual(Item"green"))
        {
            
g_bAllowGreen false;
            
PrintToChat(client"You have selected item Greeen.");
        }

        if(
StrEqual(Item"yellow"))
        {
                 
PrintToChat(client"You have selected item Yellow.");
        }

If you'd want to re-enable it you'd have to set g_bAllowGreen = to true again

EDIT: Dont forget
PHP Code:
new bool:g_bAllowGreen true
Thanks for help, man!

Supplement (for restart items in menu every round):
PHP Code:
public OnPluginStart() 
{
    
HookEvent("round_start"restart_menu)
}

public 
Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) {
    
g_bAllowGreen true;

Fastmancz is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-20-2015 , 17:43   Re: [Menu API]How to disable item in menu?
Reply With Quote #9

Quote:
Originally Posted by Fastmancz View Post
Thanks for help, man!

Supplement (for restart items in menu every round):
PHP Code:
public OnPluginStart() 
{
    
HookEvent("round_start"restart_menu)
}

public 
Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) {
    
g_bAllowGreen true;

Yup! I am glad I could help.
headline is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-20-2015 , 18:04   Re: [Menu API]How to disable item in menu?
Reply With Quote #10

But still I'm thinking.

It is only for client (Not for all) - (g_bAllowGreen = false;) ?
PHP Code:
 if(StrEqual(Item"green")) 
        { 
            
g_bAllowGreen false
            
PrintToChat(client"You have selected item Greeen."); 
        } 
Fastmancz 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:42.


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