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