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
Miu
Veteran Member
Join Date: Nov 2013
Old 07-20-2015 , 18:09   Re: [Menu API]How to disable item in menu?
Reply With Quote #11

Yes, you'll need an array instead
Miu is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 07-20-2015 , 18:10   Re: [Menu API]How to disable item in menu?
Reply With Quote #12

Use a per client bool
PHP Code:
g_bAllowGreen[MAXPLAYERS+1] = true
__________________
DeathChaos25 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-20-2015 , 18:21   Re: [Menu API]How to disable item in menu?
Reply With Quote #13

Quote:
Originally Posted by DeathChaos25 View Post
Use a per client bool
PHP Code:
g_bAllowGreen[MAXPLAYERS+1] = true
True!!!!

My Bad!

Doing what I did will disable it for every player!

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

Quote:
Originally Posted by DeathChaos25 View Post
Use a per client bool
PHP Code:
g_bAllowGreen[MAXPLAYERS+1] = true
Where does it belong? Somehow I do not know.
PHP Code:
new bool:g_bAllowGreen[MAXPLAYERS+1] = true
I try compiling and error:
PHP Code:
array must be indexed (variable "g_bAllowGreen"

Last edited by Fastmancz; 07-20-2015 at 18:38.
Fastmancz is offline
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 07-21-2015 , 00:19   Re: [Menu API]How to disable item in menu?
Reply With Quote #15

This code
PHP Code:
public Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) { 
    
g_bAllowGreen true

Should be changed to

PHP Code:
public Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) {
    for (new 
1<= MAXPLAYERSi++) {
        
g_bAllowGreen[i] = true;
    }

Remember that the bool has to be individually edited for each client, so replace every instance of g_bAllowGreen with g_bAllowGreen[client] as it is now an array that holds a bool for each client.
__________________
DeathChaos25 is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-21-2015 , 00:52   Re: [Menu API]How to disable item in menu?
Reply With Quote #16

Thanks for reply, DeathChaos25.

So here is code: Problem solved -> (but not working, because item is still available after the selection).

PHP Code:
....
#include <sourcemod>
new bool:g_bAllowGreen[MAXPLAYERS+1] = true;

public 
OnPluginStart()  

    
HookEvent("round_start"restart_menu


public 
Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) { 
    for (new 
1<= MAXPLAYERSi++) {
        
g_bAllowGreen[i] = true;
    }
}  

public 
Action:test(clientargs)
{
    new 
Handle:menuhandle CreateMenu(MenuCallBack);
    
SetMenuTitle(menuhandle"Welcome in menu!");
    
AddMenuItem(menuhandle"green""Green", (g_bAllowGreen[client])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED); //problem solved - g_bAllowGreen must be g_bAllowGreen[client]
    
AddMenuItem(menuhandle"yellow""Yellow");
    
SetMenuPagination(menuhandle7);
    
SetMenuExitButton(menuhandletrue);
    
DisplayMenu(menuhandleclient250);
}

public 
MenuCallBack(Handle:menuhandleMenuAction:actionclientPosition

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

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

Where is problem?
Thanks for reply.

Last edited by Fastmancz; 07-21-2015 at 01:01. Reason: problem solved - g_bAllowGreen must be g_bAllowGreen[client]
Fastmancz is offline
R1KO
Member
Join Date: Sep 2013
Old 07-21-2015 , 05:30   Re: [Menu API]How to disable item in menu?
Reply With Quote #17

PHP Code:
#include <sourcemod>
new bool:g_bAllowGreen[MAXPLAYERS+1] = true;

public 
OnPluginStart()  

    
HookEvent("round_start"restart_menu


public 
Action:restart_menu(Handle:event, const String:Name[], bool:Broadcast) { 
    for (new 
1<= MAXPLAYERSi++) {
        
g_bAllowGreen[i] = true;
    }
}  

public 
Action:test(clientargs)
{
    new 
Handle:hMenu CreateMenu(MenuCallBack);
    
SetMenuTitle(hMenu"Welcome in menu!");
    
AddMenuItem(hMenu"green""Green", (g_bAllowGreen[client]) ? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED); //problem solved - g_bAllowGreen must be g_bAllowGreen[client]
    
AddMenuItem(hMenu"yellow""Yellow");
    
SetMenuPagination(hMenu7);
    
SetMenuExitButton(hMenutrue);
    
DisplayMenu(hMenuclient250);
}

public 
MenuCallBack(Handle:hMenuMenuAction:actionclientPosition

    switch(
action
    {
        case 
MenuAction_EndCloseHandle(hMenu);
        case 
MenuAction_Select:
        {
            
decl String:Item[20]; 
            
GetMenuItem(hMenuPositionItemsizeof(Item)); 
            
            if(
StrEqual(Item"green")) 
            { 
                
g_bAllowGreen[client] = false
                
PrintToChat(client"You have selected item Greeen."); 
            } 

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

R1KO is offline
Send a message via Skype™ to R1KO
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 05:25.


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