Raised This Month: $ Target: $400
 0% 

[WC3FT] How to create second page in a race change menu?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SKAT
Junior Member
Join Date: Jan 2014
Old 01-20-2014 , 01:48   [WC3FT] How to create second page in a race change menu?
Reply With Quote #1

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; 
}

Last edited by SKAT; 01-20-2014 at 01:49.
SKAT is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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