Either learn the way that Sylwester showed (there are more examples of it in plmenu.sma)
Or convert it to the new menu system like fysiks suggested.
Here is how I changed it at one point. Note that there are probably more changes in the code than you need.
Code:
// Function will display the changerace menu
public MENU_ChangeRace( id, iRaceXP[MAX_RACES], page )
{
if ( XP_FreeXP( id, false ) )
{
MENU_FreeRaceXP( id, page )
return;
}
new szRaceName[64], i, pos, iKeys = 0, szMenu[512], szXP[16];
new iTotalRaces = get_pcvar_num( CVAR_wc3_races );
pos += formatex( szMenu[pos], 512-pos, "%L", id, ( page == 2 ) ? "MENU_SELECT_LOCKED" : "MENU_SELECT_RACE" );
// Then add the experience column
if ( get_pcvar_num( CVAR_wc3_save_xp ) )
{
pos += formatex( szMenu[pos], 512-pos, "\R%L^n^n", id, "MENU_WORD_EXPERIENCE" );
}
else
{
pos += formatex( szMenu[pos], 512-pos, "^n^n" );
}
new iSaveXP = get_pcvar_num( CVAR_wc3_save_xp );
new iRace;
// Build the changerace menu (for every race)
for ( i = 0; i < 8; i++ )
{
iRace = MENU_Race( page, i + 1, iTotalRaces );
if( iRace > iTotalRaces )
break;
if( iRace == RACE_NONE )
continue;
if ( iSaveXP )
num_to_str( iRaceXP[iRace - 1], szXP, 15 );
else
copy( szXP, charsmax(szXP), "" );
/*
// Add the "Select a Hero" message if necessary
if ( iRace == 4 )
{
pos += format( szMenu[pos], 512-pos, "%L", id, "SELECT_HERO" );
}
*/
switch( iRace )
{
case RACE_BLOOD,RACE_SEAWITCH: pos += format( szMenu[pos], 512-pos, "%L", id, "SELECT_HERO" );
}
// User's current race
if ( iRace == p_data[id][P_RACE] )
{
lang_GetRaceName( iRace, id, szRaceName, charsmax(szRaceName) );
pos += formatex( szMenu[pos], 512-pos, "\d%d. %s\d\R%s^n", i + 1, szRaceName, szXP );
iKeys |= (1<<i);
}
// Race the user wants to change to
else if ( iRace == p_data[id][P_CHANGERACE] )
{
lang_GetRaceName( iRace, id, szRaceName, charsmax(szRaceName) );
pos += formatex( szMenu[pos], 512-pos, "\r%d. %s\r\R%s^n", i + 1, szRaceName, szXP );
iKeys |= (1<<i);
}
// All other cases
else
{
/*
new iRaceLimit = get_pcvar_num( CVAR_wc3_race_limit );
new bool:bAllowRace = true;
if ( iRaceLimit > 0 )
{
new iTotal[MAX_RACES];
// Get how many people are using each race
new iPlayers[32], iNumPlayers, i, iTarget;
get_players( iPlayers, iNumPlayers );
for ( i = 0; i < iNumPlayers; i++ )
{
iTarget = iPlayers[i];
if ( iTarget != id && p_data[iTarget][P_RACE] > 0 && p_data[iTarget][P_RACE] <= iTotalRaces )
{
iTotal[p_data[iTarget][P_RACE]]++;
}
}
// Now if we have more races selected than iRaceLimit provides us with, then we need to increase iRaceLimit
while ( HLPR_TotalUsingRaces( iTotal ) > iRaceLimit * get_playersnum() )
{
iRaceLimit++;
}
// Check to see if there was an increase that was necessary
if ( iRaceLimit > get_pcvar_num( CVAR_wc3_race_limit ) )
{
WC3_Log( true, "Error, increase wc3_race_limit to at least %d", iRaceLimit );
}
if ( iTotal[i+1] >= iRaceLimit )
{
bAllowRace = false;
}
}*/
// Check to see if the user can choose this race (are there too many of this race?)
if ( MENU_AddRace( szMenu, pos, i, id, iRace, szXP ) )
{
iKeys |= (1<<i);
}
}
}
// Add a cancel button to the bottom
if ( iTotalRaces > 8 )
{
iKeys |= (1<<8);
pos += format( szMenu[pos], 512-pos, "^n\w9. \y%L", id, "WORD_NEXT" );
}
iKeys |= (1<<9);
pos += format( szMenu[pos], 512-pos, "^n\w0. %L", id, "WORD_CANCEL" );
// Show the menu to the user!
show_menu( id, iKeys, szMenu, -1 );
return;
}
public _MENU_ChangeRace( id, key )
{
if ( !WC3_Check() )
{
return PLUGIN_HANDLED;
}
new page = g_menuPosition[id];
new iTotalRaces = clamp( get_pcvar_num( CVAR_wc3_races ), 1, MAX_RACES );
if( key == KEY_0 )
{
return PLUGIN_HANDLED;
}
else if( key == KEY_9 )
{
new iMaxPages = MENU_RacePages( iTotalRaces );
page = ( page + 1 ) % iMaxPages;
WC3_ChangeRaceStart( id, ( g_menuPosition[id] = page ) )
return PLUGIN_HANDLED;
}
new iRace = MENU_Race( page, key + 1, iTotalRaces );
// Save the current race data before we change
DB_SaveXP( id, false );
// User currently has a race
if ( p_data[id][P_RACE] != 0 )
{
// Change the user's race at the start of next round
if ( iRace != p_data[id][P_RACE] )
{
// Special message for csdm
if ( CVAR_csdm_active > 0 && get_pcvar_num( CVAR_csdm_active ) == 1 )
{
client_print( id, print_center, "Your race will be changed when you respawn" );
}
else
{
client_print( id, print_center, "%L", id, "CENTER_CHANGED_NEXT" );
}
p_data[id][P_CHANGERACE] = iRace;
}
// Do nothing
else
{
p_data[id][P_CHANGERACE] = 0;
}
}
// User doesn't have a race so give it to him!!!
else
{
WC3_SetRace( id, iRace );
}
return PLUGIN_HANDLED;
}