[WC3FT] How to create second page in a race change menu?
Hello, everyone, i would like to add some race in war3ft, and i want to ask, how i could make next/back or new page.
Code:
public MENU_ChangeRace( idUser, iRaceXP[MAX_RACES] )
{
new szRaceName[MAX_RACES+1][64], i, pos, iKeys = 0, szMenu[512], szXP[16];
// Get our race names
for ( i = 0; i < 10; i++ )
{
lang_GetRaceName( i + 1, idUser, szRaceName[i], 63 );
}
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "%L", LANG_PLAYER, "MENU_SELECT_RACE" );
// Then add the experience column
if ( get_pcvar_num( CVAR_wc3_save_xp ) )
{
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "\R%L^n^n", LANG_PLAYER, "MENU_WORD_EXPERIENCE" );
}
else
{
//pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "^n^n" );
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "^n" );
}
// Build the changerace menu (for every race)
for ( i = 0; i < 10; i++ )
{
num_to_str( iRaceXP[i], szXP, 15 );
// Add the "Select a Hero" message if necessary
if ( i == 4 )
{
pos += format( szMenu[pos], charsmax(szMenu)-pos, "%L", LANG_PLAYER, "SELECT_HERO" );
}
// User's current race
if ( i == p_data[idUser][P_RACE] - 1 )
{
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "\d%d. %s\d\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
iKeys |= (1<<i);
}
// Race the user wants to change to
else if ( i == p_data[idUser][P_CHANGERACE] - 1 )
{
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "\r%d. %s\r\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
iKeys |= (1<<i);
}
// All other cases
else
{
new bool:bAllowRace = true;
// Check to see if the user can choose this race (are there too many of this race?)
if ( bAllowRace )
{
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "\w%d. %s\y\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
iKeys |= (1<<i);
}
// If not, display the race, but don't give them a key to press
else
{
pos += formatex( szMenu[pos], charsmax(szMenu)-pos, "\d%d. %s\y\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
}
}
}
iKeys |= (1<<i);
// Show the menu to the user!
show_menu( idUser, iKeys, szMenu, -1 );
return;
}
public _MENU_ChangeRace( idUser, key )
{
if ( !WC3_Check() )
{
return PLUGIN_HANDLED;
}
// Save the current race data before we change
DB_SaveXP( idUser, false );
new iRace;
iRace = key + 1;
// User currently has a race
if ( p_data[idUser][P_RACE] != 0 )
{
// Change the user's race at the start of next round
if ( iRace != p_data[idUser][P_RACE] )
{
// Special message for csdm
if ( CVAR_csdm_active > 0 && get_pcvar_num( CVAR_csdm_active ) == 1 )
{
client_print( idUser, print_center, "%L",LANG_PLAYER,"CLIENT_PRINT_MENU_CHANGE_RACE");
}
else
{
client_print( idUser, print_center, "%L",LANG_PLAYER,"CENTER_CHANGED_NEXT");
}
p_data[idUser][P_CHANGERACE] = iRace;
}
// Do nothing
else
{
p_data[idUser][P_CHANGERACE] = 0;
}
}
// User doesn't have a race so give it to him!!!
else
{
WC3_SetRace( idUser, iRace );
}
return PLUGIN_HANDLED;
}
|