Just an example, I didnt actually test this, but it is pretty straight-forward:
Code:
#include <amxmodx>
#include <amxmisc>
#define MAX_DISPLAY 8 // This is the number of Options per page (Dont change)
// Tracks what page in menu admin is on..
new g_nMenuPosition[33]
public plugin_init()
{
register_menucmd( register_menuid("\yPlayer Menu:"), 1023, "MenuCommand" )
register_clcmd( "player_menu", "DoShowMenu", ADMIN_MENU, "Shows The Player menu" )
}
public MenuCommand( id, key )
{
switch( key )
{
case 8: PlayerMenu( id, ++g_nMenuPosition[id] )
case 9: PlayerMenu( id, --g_nMenuPosition[id] )
default:
{
// This is the Chosen Player Index
new iIndex = g_nMenuPosition[id] * MAX_DISPLAY + key
// Get the Chosen Players Name
new szUsername[32]
get_user_name( iIndex, szUsername, 31 )
// Print Username to Admin who called Menu
client_print( id, print_chat, "You Selected: %s", szUsername )
}
}
return PLUGIN_HANDLED
}
public PlayerMenu( id, pos )
{
if( pos < 0 ) return
new iMenuPlayers[32], iNum
get_players( iMenuPlayers, iNum )
new i, j, nCurrKey = 0
new szUserName[32]
new szMenuBody[256]
new nStart = pos * MAX_DISPLAY
if( nStart >= iNum )
nStart = pos = g_nMenuPosition[id-1] = 0
new nLen = format( szMenuBody, 255, "\yPlayer Menu:\R%d/%d^n\w^n", (pos+1), (iNum / MAX_DISPLAY + ((iNum % MAX_DISPLAY) ? 1 : 0 )) )
new nEnd = nStart + MAX_DISPLAY
new nKeys = (1<<9)
if( nEnd > iNum ) nEnd = iNum
for( i = nStart; i < nEnd; i++ )
{
j = iMenuPlayers[i]
get_user_name( j, szUserName, 31 )
if( access( j, ADMIN_IMMUNITY ) )
{
nCurrKey++
nLen += format( szMenuBody[nLen], (255-nLen), "\d%d. %s^n\w", nCurrKey, szUserName )
}else
{
nKeys |= (1<<nCurrKey++)
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", nCurrKey, szUserName )
}
}
if( nEnd != iNum )
{
format( szMenuBody[nLen], (255-nLen), "^n9. More...^n0. Back" )
nKeys |= (1<<8)
}
else
{
format( szMenuBody[nLen], (255-nLen), "^n0. Back" )
}
show_menu( id, nKeys, szMenuBody )
return
}
public DoShowMenu( id, lvl, cid )
{
if( cmd_access( id, lvl, cid, 0 ) )
PlayerMenu( id, g_nMenuPosition[id] = 0 )
return PLUGIN_HANDLED
}