AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Old Menu Command (https://forums.alliedmods.net/showthread.php?t=141234)

CryWolf 10-21-2010 08:14

Old Menu Command
 
Hy, all first i have the folowing code
And when i press 1 for case1 doesn't work apears in chat Players Rank but it doesn't execute say /rank for player

So i don't know where to add the question and where to add command

If anyone know please help me with an example

Thank You!

EDIT: I succeded, normal must start with case 0: for old menus.

Thanks

CryWolf 10-21-2010 09:27

Re: Old Menu Command
 
New HELP Needed

For the second page of the menu when i click nr 1. it redirects me back to chase 0:

How i can create a case for the second menu and bind it to the first option

I tryed creating case 10: but doesnt work

Any help ?

abdul-rehman 10-21-2010 09:38

Re: Old Menu Command
 
Use Case 8 !

CryWolf 10-21-2010 09:41

Re: Old Menu Command
 
I'm using this model
Code:


/* Multi-page menu */



#include <amxmod>
#include <amxmisc>

#define MAX_MENU 16    //  This is the number of options u have
#define MAX_DISPLAY 8    //  This is the number of Options per page (Dont change)
#define MAX_PAGES 2    //  This is the number of pages (MAX_MENU / MAX_DISPLAY [if Remainder>0 Then +1])

new g_szOptions[ MAX_MENU ][ ] = {
 "PG 1: Option 1",
 "PG 1: Option 2",
 "PG 1: Option 3",
 "PG 1: Option 4",
 "PG 1: Option 5",
 "PG 1: Option 6",
 "PG 1: Option 7",
 "PG 1: Option 8",

 "PG 2: Option 1",
 "PG 2: Option 2",
 "PG 2: Option 3",
 "PG 2: Option 4",
 "PG 2: Option 5",
 "PG 2: Option 6",
 "PG 2: Option 7",
 "PG 2: Option 8"
}

new g_nMenuPosition[33]


public plugin_init()
{
    register_menucmd( register_menuid("\yOptions Menu:"), 1023, "MenuCommand" )

    register_clcmd( "say /menu","DoShowMenu", ADMIN_MENU, "Shows The menu" )

    return PLUGIN_CONTINUE
}


public MenuCommand( id, key )
{
    switch( key )
    {
        case 8: ShowMenu( id, ++g_nMenuPosition[id] )
        case 9: ShowMenu( id, --g_nMenuPosition[id] )
          default:
                {
                    new iIndex = g_nMenuPosition[id] * MAX_DISPLAY + key
                    client_print( id, print_chat, "%s", g_szOptions[iIndex] )
                }
      }

      return PLUGIN_HANDLED
}


public ShowMenu( id, pos )
{
    if( pos < 0 ) return

    new i, j = 0
    new nKeys, nStart, nEnd, nLen
    new szMenuBody[512]

    nStart = pos * MAX_DISPLAY

    if( nStart >= MAX_MENU )
        nStart = pos = g_nMenuPosition[id] = 0

    nLen = format( szMenuBody, 511, "\yOptions Menu:\R%d/%d^n\w^n", pos + 1, MAX_PAGES )
    nEnd = nStart + MAX_DISPLAY
    nKeys = (1<<9)

    if( nEnd > MAX_MENU ) nEnd = MAX_MENU

    for( i = nStart; i < nEnd; i++ )
    {
        nKeys |= (1<<j++)
        nLen += format( szMenuBody[nLen], (511-nLen), "\d%d. %s^n\w", j, g_szOptions[i] )
    }

    if( nEnd != MAX_MENU )
      {
        format( szMenuBody[nLen], (511-nLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )
        nKeys |= (1<<8)
    }
      else format( szMenuBody[nLen], (511-nLen), "^n0. %s", pos ? "Back" : "Exit" )
   
    show_menu( id, nKeys, szMenuBody, -1 )
}


public DoShowMenu( id, lvl, cid )
{
    if( cmd_access( id, lvl, cid, 1 ) )
        ShowMenu( id, g_nMenuPosition[id] = 0 )

    return PLUGIN_HANDLED
}

case 8 and 9 is taken i don't know how to bind another option for second page 2/2 to another case

fysiks 10-21-2010 13:27

Re: Old Menu Command
 
That code looks fine to me. You can look at plmenu.sma for examples. Also, if something is not working correctly you need to debug.


All times are GMT -4. The time now is 10:19.

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