Raised This Month: $ Target: $400
 0% 

Menus :: Non-selectable text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gamerfm_max
Junior Member
Join Date: Apr 2010
Old 07-04-2010 , 17:02   Menus :: Non-selectable text
Reply With Quote #1

Hi,

How would i go about putting both selectable options in my menu and having text that cant be selected? I Cant seem to find anything on the wiki about it

Regards,
Max
gamerfm_max is offline
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 07-04-2010 , 17:12   Re: Menus :: Non-selectable text
Reply With Quote #2

Just change the style.

http://docs.sourcemod.net/api/index....d=show&id=184&

native AddMenuItem(Handle:menu, const String:info[], const String:display[], style=ITEMDRAW_DEFAULT);
Quote:
#define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */
#define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */
#define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */
#define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */
#define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
__________________
FoxMulder is offline
gamerfm_max
Junior Member
Join Date: Apr 2010
Old 07-04-2010 , 17:32   Re: Menus :: Non-selectable text
Reply With Quote #3

Any chance of an example script? i tried myself but keep getting compile errors.

Code:
#define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */
#define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */
#define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */
#define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */
#define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */

public OnPluginStart()
{
    RegConsoleCmd("menu_test1", Menu_Test1);
}
 
public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
{
    /* If an option was selected, tell the client about the item. */
    if (action == MenuAction_Select)
    {
        new String:info[32];
        new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
        PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info);
    }
    /* If the menu was cancelled, print a message to the server about it. */
    else if (action == MenuAction_Cancel)
    {
        PrintToServer("Client %d's menu was cancelled.  Reason: %d", param1, param2);
    }
    /* If the menu has ended, destroy it */
    else if (action == MenuAction_End)
    {
        CloseHandle(menu);
    }
}
 
public Action:Menu_Test1(client, args)
{
    new Handle:menu = CreateMenu(MenuHandler1);
    SetMenuTitle(menu, "Do you like apples?");
        native AddMenuItem(Handle:menu, "test", "Test", style=ITEMDRAW_DISABLED);
    AddMenuItem(menu, "no", "No");
    SetMenuExitButton(menu, false);
    DisplayMenu(menu, client, 20);
 
    return Plugin_Handled;
}
My script so far.

Compile Errors

Code:
/groups/sourcemod/upload_tmp/textkTha5U.sp(39) : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/textkTha5U.sp(39) : error 017: undefined symbol "style"
/groups/sourcemod/upload_tmp/textkTha5U.sp(39) : warning 215: expression has no effect
/groups/sourcemod/upload_tmp/textkTha5U.sp(39) : error 001: expected token: ";", but found ")"
/groups/sourcemod/upload_tmp/textkTha5U.sp(39) : fatal error 127: too many error messages on one line

Last edited by gamerfm_max; 07-04-2010 at 17:37.
gamerfm_max is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-04-2010 , 19:21   Re: Menus :: Non-selectable text
Reply With Quote #4

PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("menu_test1"Menu_Test1);
}
 
public 
MenuHandler1(Handle:menuMenuAction:actionparam1param2)
{
    
/* If an option was selected, tell the client about the item. */
    
if (action == MenuAction_Select)
    {
        new 
String:info[32];
        new 
bool:found GetMenuItem(menuparam2infosizeof(info));
        
PrintToConsole(param1"You selected item: %d (found? %d info: %s)"param2foundinfo);
    }
    
/* If the menu was cancelled, print a message to the server about it. */
    
else if (action == MenuAction_Cancel)
    {
        
PrintToServer("Client %d's menu was cancelled.  Reason: %d"param1param2);
    }
    
/* If the menu has ended, destroy it */
    
else if (action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}
 
public 
Action:Menu_Test1(clientargs)
{
    new 
Handle:menu CreateMenu(MenuHandler1);
    
SetMenuTitle(menu"Do you like apples?");
    
AddMenuItem(menu"test""Test"ITEMDRAW_DISABLED);
    
AddMenuItem(menu"no""No");
    
SetMenuExitButton(menufalse);
    
DisplayMenu(menuclient20);
 
    return 
Plugin_Handled;

__________________
Peace-Maker is offline
gamerfm_max
Junior Member
Join Date: Apr 2010
Old 07-04-2010 , 20:15   Re: Menus :: Non-selectable text
Reply With Quote #5

Thanks, is there any way to remove the numbers on the disabled bits? so there plain text with no numbers, and the selectable ones get the numbers starting from 1? i want to use disabled bits for infomation, so i dont need numbers next to them

Max

Last edited by gamerfm_max; 07-04-2010 at 20:21.
gamerfm_max is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-05-2010 , 02:29   Re: Menus :: Non-selectable text
Reply With Quote #6

The only way to do that is to kind of cheat a little bit.

A menu is just a string. In memory SM is building a string each time you use AddMenuItem. And putting "->" before a single digit integer will turn the line yellow.

So in your above example it would look like "1. Test\n->2. No"

The way you can make unselectable text with no numbers is to do

Code:
AddMenuItem(menu, "test", "Test\nNo");
That would make "Test" be a selectable option with a "1." next to it, and "No" will be in grey text under it.

This method will make grey text below the option. Making it above would be more difficult.
__________________
Greyscale is offline
gamerfm_max
Junior Member
Join Date: Apr 2010
Old 07-05-2010 , 06:27   Re: Menus :: Non-selectable text
Reply With Quote #7

Right ok thanks, is it not possible to add disabled items as a non-menu item but to still be displayed? also how do i change the limit of options per menu? when i put in spacers and blank text it goes over to a new page on the menu

Last edited by gamerfm_max; 07-05-2010 at 06:31.
gamerfm_max 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 13:36.


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