2009-04-14 23:33:06 +02:00
/*
* ============================================================================
*
2009-07-05 08:49:23 +02:00
* Zombie : Reloaded
2009-04-14 23:33:06 +02:00
*
2009-06-12 05:51:26 +02:00
* File : classmenus . inc
* Type : Core
* Description : Provides functions for managing class menus .
*
* Copyright ( C ) 2009 Greyscale , Richard Helgeby
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2009-04-14 23:33:06 +02:00
*
* ============================================================================
*/
2009-06-18 02:09:55 +02:00
2009-04-15 23:40:45 +02:00
/* ------------------------------------
*
* MAIN CLASS MENU
*
* ------------------------------------
*/
2009-04-14 23:33:06 +02:00
/**
* Displays the main class menu with the players class settings .
2009-04-15 23:40:45 +02:00
*
* @ param client The client index .
2009-04-14 23:33:06 +02:00
*/
ClassMenuMain ( client )
{
2009-04-15 23:40:45 +02:00
new Handle : menu = CreateMenu ( ClassMenuMainHandle );
2009-04-14 23:33:06 +02:00
SetGlobalTransTarget ( client );
2009-07-28 02:09:15 +02:00
decl String : title [ MENU_LINE_TITLE_LENGTH ];
2009-04-14 23:33:06 +02:00
2009-07-28 02:02:49 +02:00
decl String : zombieclass [ MENU_LINE_REG_LENGTH ];
decl String : humanclass [ MENU_LINE_REG_LENGTH ];
decl String : adminclass [ MENU_LINE_REG_LENGTH ];
2009-07-23 23:26:14 +02:00
2009-07-28 02:02:49 +02:00
decl String : nextzombiename [ MENU_LINE_REG_LENGTH ];
decl String : nexthumanname [ MENU_LINE_REG_LENGTH ];
decl String : nextadminname [ MENU_LINE_REG_LENGTH ];
2009-04-14 23:33:06 +02:00
2009-07-28 02:02:49 +02:00
decl String : zombieselect [ MENU_LINE_BIG_LENGTH ];
decl String : humanselect [ MENU_LINE_BIG_LENGTH ];
decl String : adminselect [ MENU_LINE_BIG_LENGTH ];
2009-04-14 23:33:06 +02:00
2009-07-28 02:02:49 +02:00
decl String : inadminmnode [ MENU_LINE_BIG_LENGTH ];
decl String : adminmode [ MENU_LINE_BIG_LENGTH ];
decl String : toggleadminmode [ MENU_LINE_BIG_LENGTH ];
2009-04-14 23:33:06 +02:00
2010-07-03 23:39:34 +02:00
// Setup filtering.
// ----------------
new filter [ ClassFilter ];
// Hide mother zombie classes.
filter [ ClassFilter_DenyFlags ] = ZR_CLASS_FLAG_MOTHER_ZOMBIE ;
// Hide admin-only classes if not admin.
filter [ ClassFilter_DenyFlags ] += ! ZRIsClientAdmin ( client ) ? ZR_CLASS_FLAG_ADMIN_ONLY : 0 ;
// Specify client for checking class group permissions.
filter [ ClassFilter_Client ] = client ;
// Setup item draw style.
// ----------------------
2009-04-18 02:22:13 +02:00
// Get number of enabled classes per team.
2010-07-03 23:39:34 +02:00
new zombiecount = ClassCountTeam ( ZR_CLASS_TEAM_ZOMBIES , filter );
2010-07-04 03:56:42 +02:00
new humancount = ClassCountTeam ( ZR_CLASS_TEAM_HUMANS , filter );
2010-07-03 23:39:34 +02:00
new admincount = ClassCountTeam ( ZR_CLASS_TEAM_ADMINS , filter );
2009-04-18 02:22:13 +02:00
2009-08-15 01:28:28 +02:00
// Get next class indexes, if set.
2009-07-23 23:26:14 +02:00
new nextzombie = ClassSelectedNext [ client ][ ZR_CLASS_TEAM_ZOMBIES ];
new nexthuman = ClassSelectedNext [ client ][ ZR_CLASS_TEAM_HUMANS ];
new nextadmin = ClassSelectedNext [ client ][ ZR_CLASS_TEAM_ADMINS ];
2009-08-09 22:44:28 +02:00
// Set draw style on class options depending on number of enabled classes
// and selection permissions. Disable class selection if there's only one
// class.
2010-07-03 23:39:34 +02:00
new zombie_itemdraw = ( zombiecount > 1 && ClassAllowSelection ( client , ZR_CLASS_TEAM_ZOMBIES , filter )) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED ;
new human_itemdraw = ( humancount > 1 && ClassAllowSelection ( client , ZR_CLASS_TEAM_HUMANS , filter )) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED ;
new admin_itemdraw = ( admincount > 1 && ClassAllowSelection ( client , ZR_CLASS_TEAM_ADMINS , filter )) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED ;
2009-04-18 02:22:13 +02:00
2009-04-14 23:33:06 +02:00
// Check if the player is in admin mode.
2009-04-15 23:40:45 +02:00
if ( ClassPlayerInAdminMode [ client ])
2009-04-14 23:33:06 +02:00
{
// Notify the player.
2009-05-14 02:28:26 +02:00
Format ( inadminmnode , sizeof ( inadminmnode ), " %t \n " , " Classes admin mode enabled " );
2009-04-15 23:40:45 +02:00
AddMenuItem ( menu , " " , inadminmnode , ITEMDRAW_RAWLINE );
2009-04-14 23:33:06 +02:00
}
// List zombie class options.
2009-07-23 23:26:14 +02:00
// --------------------------
// Get current class name.
2009-04-15 23:40:45 +02:00
ClassGetName ( ClassSelected [ client ][ ZR_CLASS_TEAM_ZOMBIES ], zombieclass , sizeof ( zombieclass ), ZR_CLASS_CACHE_MODIFIED );
2009-07-23 23:26:14 +02:00
2009-08-15 01:28:28 +02:00
// Check if next index is set.
2009-07-23 23:26:14 +02:00
if ( ClassValidateIndex ( nextzombie ))
{
// Get name of previous class index and format item text.
ClassGetName ( nextzombie , nextzombiename , sizeof ( nextzombiename ), ZR_CLASS_CACHE_MODIFIED );
2009-07-28 02:02:49 +02:00
2009-08-15 01:28:28 +02:00
Format ( zombieselect , sizeof ( zombieselect ), " %t \n %t \n %t " , " Classes menu select zombie " , " Classes menu active " , zombieclass , " Classes menu next " , nextzombiename );
2009-07-23 23:26:14 +02:00
}
else
{
// Use current class name and format item text.
2009-08-15 01:28:28 +02:00
Format ( zombieselect , sizeof ( zombieselect ), " %t \n %s " , " Classes menu select zombie " , zombieclass );
2009-07-23 23:26:14 +02:00
}
// Add item to list.
2009-04-18 02:22:13 +02:00
AddMenuItem ( menu , " " , zombieselect , zombie_itemdraw );
2009-04-14 23:33:06 +02:00
2009-07-23 23:26:14 +02:00
2009-04-14 23:33:06 +02:00
// List human class options.
2009-07-23 23:26:14 +02:00
// -------------------------
// Get current class name.
2009-04-15 23:40:45 +02:00
ClassGetName ( ClassSelected [ client ][ ZR_CLASS_TEAM_HUMANS ], humanclass , sizeof ( humanclass ), ZR_CLASS_CACHE_MODIFIED );
2009-07-23 23:26:14 +02:00
2009-08-15 01:28:28 +02:00
// Check if next index is set.
2009-07-23 23:26:14 +02:00
if ( ClassValidateIndex ( nexthuman ))
{
// Get name of previous class index and format item text.
ClassGetName ( nexthuman , nexthumanname , sizeof ( nexthumanname ), ZR_CLASS_CACHE_MODIFIED );
2009-07-28 02:02:49 +02:00
2009-08-15 01:28:28 +02:00
Format ( humanselect , sizeof ( humanselect ), " %t \n %t \n %t " , " Classes menu select human " , " Classes menu active " , humanclass , " Classes menu next " , nexthumanname );
2009-07-23 23:26:14 +02:00
}
else
{
// Use current class name and format item text.
2009-08-15 01:28:28 +02:00
Format ( humanselect , sizeof ( humanselect ), " %t \n %s " , " Classes menu select human " , humanclass );
2009-07-23 23:26:14 +02:00
}
// Add item to list.
2009-04-18 02:22:13 +02:00
AddMenuItem ( menu , " " , humanselect , human_itemdraw );
2009-04-14 23:33:06 +02:00
2009-07-23 23:26:14 +02:00
// List admin class options, if they exist.
// ----------------------------------------
2009-04-29 02:50:25 +02:00
// Only display admin class options for admins, and if admin classes exist.
if ( ZRIsClientAdmin ( client ) && ClassCountTeam ( ZR_CLASS_TEAM_ADMINS ))
2009-04-14 23:33:06 +02:00
{
2009-07-23 23:26:14 +02:00
// Get current class name.
2009-04-15 23:40:45 +02:00
ClassGetName ( ClassSelected [ client ][ ZR_CLASS_TEAM_ADMINS ], adminclass , sizeof ( adminclass ), ZR_CLASS_CACHE_MODIFIED );
2009-07-23 23:26:14 +02:00
2009-08-15 01:28:28 +02:00
// Check if next index is set.
2009-07-23 23:26:14 +02:00
if ( ClassValidateIndex ( nextadmin ))
{
// Get name of previous class index and format item text.
ClassGetName ( nextadmin , nextadminname , sizeof ( nextadminname ), ZR_CLASS_CACHE_MODIFIED );
2009-08-15 01:28:28 +02:00
Format ( adminselect , sizeof ( adminselect ), " %t \n %t \n %t " , " Classes menu select admin " , " Classes menu active " , adminclass , " Classes menu next " , nextadminname );
2009-07-23 23:26:14 +02:00
}
else
{
// Use current class name and format item text.
2009-08-15 01:28:28 +02:00
Format ( adminselect , sizeof ( adminselect ), " %t \n %s " , " Classes menu select admin " , adminclass );
2009-07-23 23:26:14 +02:00
}
// Add item to list.
2009-04-18 02:22:13 +02:00
AddMenuItem ( menu , " " , adminselect , admin_itemdraw );
2009-04-14 23:33:06 +02:00
2009-04-15 23:40:45 +02:00
// Set admin mode status string.
2009-07-23 23:26:14 +02:00
if ( ClassPlayerInAdminMode [ client ])
2009-04-14 23:33:06 +02:00
{
2009-04-15 23:40:45 +02:00
Format ( adminmode , sizeof ( adminmode ), " %t " , " On " );
2009-04-14 23:33:06 +02:00
}
else
{
2009-04-15 23:40:45 +02:00
Format ( adminmode , sizeof ( adminmode ), " %t " , " Off " );
2009-04-14 23:33:06 +02:00
}
2009-04-18 02:22:13 +02:00
// Spacer. ITEMDRAW_SPACER not used because it use a slot.
AddMenuItem ( menu , " " , " " , ITEMDRAW_RAWLINE );
2009-04-15 23:40:45 +02:00
// Show admin mode toggle option.
2009-05-14 02:28:26 +02:00
Format ( toggleadminmode , sizeof ( toggleadminmode ), " %t \n %s " , " Classes menu admin mode toggle " , adminmode );
2009-04-18 02:22:13 +02:00
AddMenuItem ( menu , " " , toggleadminmode , admin_itemdraw );
2009-04-14 23:33:06 +02:00
}
2009-07-28 02:09:15 +02:00
Format ( title , sizeof ( title ), " %t \n " , " Classes menu title " );
SetMenuTitle ( menu , title );
2009-04-15 23:40:45 +02:00
SetMenuExitBackButton ( menu , true );
DisplayMenu ( menu , client , MENU_TIME_FOREVER );
}
/**
2009-06-18 02:09:55 +02:00
* Main class menu handler .
2009-04-15 23:40:45 +02:00
*/
public ClassMenuMainHandle ( Handle : menu , MenuAction : action , client , slot )
{
switch ( action )
2009-04-14 23:33:06 +02:00
{
2009-04-15 23:40:45 +02:00
case MenuAction_Select :
2009-04-14 23:33:06 +02:00
{
2009-04-15 23:40:45 +02:00
switch ( slot )
2009-04-14 23:33:06 +02:00
{
2009-04-15 23:40:45 +02:00
case 0 :
{
ClassMenuSelect ( client , ZR_CLASS_TEAM_ZOMBIES );
}
case 1 :
{
ClassMenuSelect ( client , ZR_CLASS_TEAM_HUMANS );
}
case 2 :
{
ClassMenuSelect ( client , ZR_CLASS_TEAM_ADMINS );
}
case 3 :
{
2009-04-18 02:22:13 +02:00
// ClassToggleAdminMode(client);
ClassMenuMain ( client );
2009-04-15 23:40:45 +02:00
}
2009-04-14 23:33:06 +02:00
}
}
2009-04-15 23:40:45 +02:00
case MenuAction_End :
2009-04-14 23:33:06 +02:00
{
2009-04-15 23:40:45 +02:00
CloseHandle ( menu );
2009-04-14 23:33:06 +02:00
}
2009-04-15 23:40:45 +02:00
case MenuAction_Cancel :
{
if ( slot == MenuCancel_ExitBack )
{
2009-06-22 06:08:26 +02:00
ZMenuMain ( client );
2009-04-15 23:40:45 +02:00
}
}
}
}
/* ------------------------------------
*
* ZOMBIE CLASS SELECTION MENU
*
* ------------------------------------
*/
/**
* Displays the class selection menu .
*
* @ param client The client index .
* @ param teamid What class types to display .
*/
ClassMenuSelect ( client , teamid )
{
new Handle : menu = CreateMenu ( ClassMenuSelectHandle );
new arraycount ;
new classindex ;
2009-07-28 02:02:49 +02:00
decl String : title [ MENU_LINE_TITLE_LENGTH ];
decl String : classname [ MENU_LINE_REG_LENGTH ];
decl String : description [ MENU_LINE_BIG_LENGTH ];
decl String : menuitem [ MENU_LINE_HUGE_LENGTH ];
2009-04-15 23:40:45 +02:00
SetGlobalTransTarget ( client );
// Set correct menu title depending on team ID.
switch ( teamid )
{
case ZR_CLASS_TEAM_ZOMBIES :
{
2009-08-15 01:28:28 +02:00
Format ( title , sizeof ( title ), " %t: \n " , " Classes menu select zombie " );
2009-04-15 23:40:45 +02:00
}
case ZR_CLASS_TEAM_HUMANS :
{
2009-08-15 01:28:28 +02:00
Format ( title , sizeof ( title ), " %t: \n " , " Classes menu select human " );
2009-04-15 23:40:45 +02:00
}
case ZR_CLASS_TEAM_ADMINS :
{
2009-08-15 01:28:28 +02:00
Format ( title , sizeof ( title ), " %t: \n " , " Classes menu select admin " );
2009-04-15 23:40:45 +02:00
}
}
SetMenuTitle ( menu , title );
// Create buffer array.
new Handle : classarray = CreateArray ();
2009-08-14 22:10:52 +02:00
// Set up filtering
// ----------------
new filter [ ClassFilter ];
// Hide mother zombie classes.
filter [ ClassFilter_DenyFlags ] = ZR_CLASS_FLAG_MOTHER_ZOMBIE ;
// Hide admin-only classes if not admin.
filter [ ClassFilter_DenyFlags ] += ! ZRIsClientAdmin ( client ) ? ZR_CLASS_FLAG_ADMIN_ONLY : 0 ;
// Specify client for checking class group permissions.
filter [ ClassFilter_Client ] = client ;
// Get classes
// -----------
2009-06-22 01:09:51 +02:00
// Copy all class indexes into the array, with the specified filter settings.
2009-08-14 22:10:52 +02:00
if ( ClassAddToArray ( classarray , teamid , filter ))
2009-04-15 23:40:45 +02:00
{
// Get number of classes.
arraycount = GetArraySize ( classarray );
2009-04-14 23:33:06 +02:00
2009-04-15 23:40:45 +02:00
// Loop through each class.
for ( new i = 0 ; i < arraycount ; i ++ )
{
// Get index, name and description.
classindex = GetArrayCell ( classarray , i );
ClassGetName ( classindex , classname , sizeof ( classname ), ZR_CLASS_CACHE_MODIFIED );
ClassGetDescription ( classindex , description , sizeof ( description ), ZR_CLASS_CACHE_MODIFIED );
2009-06-22 01:09:51 +02:00
// Add menu item. Using extra spaces for indention on the second line.
2009-04-15 23:40:45 +02:00
Format ( menuitem , sizeof ( menuitem ), " %s \n %s " , classname , description );
AddMenuItem ( menu , classname , menuitem );
}
2009-04-14 23:33:06 +02:00
}
2009-06-22 18:11:31 +02:00
// Destroy array.
CloseHandle ( classarray );
2009-04-15 23:40:45 +02:00
SetMenuExitBackButton ( menu , true );
DisplayMenu ( menu , client , MENU_TIME_FOREVER );
}
/**
2009-06-18 02:09:55 +02:00
* Class selection menu handler .
2009-04-15 23:40:45 +02:00
*/
public ClassMenuSelectHandle ( Handle : menu , MenuAction : action , client , slot )
{
2012-09-08 22:34:31 +02:00
decl String : className [ MENU_LINE_REG_LENGTH ];
new classIndex ;
2009-05-15 07:25:07 +02:00
new bool : autoclose = GetConVarBool ( g_hCvarsList [ CVAR_CLASSES_MENU_AUTOCLOSE ]);
2009-04-15 23:40:45 +02:00
switch ( action )
{
case MenuAction_Select :
{
// Get class name from the information string.
2012-09-08 22:34:31 +02:00
GetMenuItem ( menu , slot , className , sizeof ( className ));
2009-04-15 23:40:45 +02:00
// Solve class index from the name.
2012-09-08 22:34:31 +02:00
classIndex = ClassGetIndex ( className );
2009-12-09 14:57:33 +01:00
2012-09-08 22:34:31 +02:00
// Select (and eventually apply) class.
ClassSelectClientClass ( client , classIndex );
2009-04-15 23:40:45 +02:00
}
case MenuAction_Cancel :
{
if ( slot == MenuCancel_ExitBack )
{
ClassMenuMain ( client );
}
2009-04-30 07:36:57 +02:00
// Stop so menu doesn't reopen.
return ;
2009-04-15 23:40:45 +02:00
}
case MenuAction_End :
{
CloseHandle ( menu );
2009-04-29 01:58:41 +02:00
// Stop so menu doesn't reopen.
return ;
2009-04-15 23:40:45 +02:00
}
}
2009-04-14 23:33:06 +02:00
2009-04-15 23:40:45 +02:00
// Redisplay the main class menu if autoclose is disabled.
if ( ! autoclose )
{
ClassMenuMain ( client );
}
2009-04-14 23:33:06 +02:00
}
2009-06-18 02:09:55 +02:00
/* ------------------------------------
*
* TEAM SELECT MENU ( ADMIN )
*
* ------------------------------------
*/
/**
* Displays the team selection admin menu .
*
* @ param client The client index .
* @ return True if displayed , false otherwise .
*/
bool : ClassTeamSelect ( client )
2009-08-11 03:29:22 +02:00
{
2009-06-18 02:09:55 +02:00
// Validate permissions.
2009-08-11 03:29:22 +02:00
if ( ! ZRIsClientPrivileged ( client , OperationType_Configuration ))
2009-06-18 02:09:55 +02:00
{
return false ;
}
// Create menu.
new Handle : menu = CreateMenu ( ClassTeamSelectHandle );
2009-07-28 02:02:49 +02:00
decl String : title [ MENU_LINE_TITLE_LENGTH ];
decl String : zombies [ MENU_LINE_SMALL_LENGTH ];
decl String : humans [ MENU_LINE_SMALL_LENGTH ];
2009-06-18 02:09:55 +02:00
// Set translation language.
SetGlobalTransTarget ( client );
// Translate phrases.
Format ( title , sizeof ( title ), " %t " , " Classes Menu Team Select Title " );
Format ( zombies , sizeof ( zombies ), " %t " , " Classes Menu Zombies " );
Format ( humans , sizeof ( humans ), " %t " , " Classes Menu Humans " );
SetMenuTitle ( menu , title );
AddMenuItem ( menu , " zombies " , zombies );
AddMenuItem ( menu , " humans " , humans );
SetMenuExitBackButton ( menu , true );
DisplayMenu ( menu , client , MENU_TIME_FOREVER );
return true ;
}
/**
* Team selection menu handler .
*/
public ClassTeamSelectHandle ( Handle : menu , MenuAction : action , client , slot )
{
switch ( action )
{
case MenuAction_Select :
{
switch ( slot )
{
case 0 :
{
ClassAdminTeamSelected [ client ] = ZR_CLASS_TEAM_ZOMBIES ;
}
case 1 :
{
ClassAdminTeamSelected [ client ] = ZR_CLASS_TEAM_HUMANS ;
}
}
// Display multiplier menu.
ClassMultiplierSelectMenu ( client );
}
case MenuAction_End :
{
CloseHandle ( menu );
}
case MenuAction_Cancel :
{
if ( slot == MenuCancel_ExitBack )
{
2009-06-26 02:03:34 +02:00
ZAdminMenu ( client );
2009-06-18 02:09:55 +02:00
}
}
}
}
/* ------------------------------------
*
* MULTIPLIER SELECT MENU ( ADMIN )
*
* ------------------------------------
*/
/**
* Displays the multiplier selection admin menu .
*
* @ param client The client index .
*/
ClassMultiplierSelectMenu ( client )
{
// Create menu.
new Handle : menu = CreateMenu ( ClassMultiplierSelectHandle );
new teamid = ClassAdminTeamSelected [ client ];
new bool : zombiesselected = bool : ( teamid == ZR_CLASS_TEAM_ZOMBIES );
2009-07-28 02:02:49 +02:00
decl String : title [ MENU_LINE_TITLE_LENGTH ];
decl String : napalmtime [ MENU_LINE_REG_LENGTH ];
decl String : health [ MENU_LINE_REG_LENGTH ];
decl String : regeninterval [ MENU_LINE_REG_LENGTH ];
decl String : regenamount [ MENU_LINE_REG_LENGTH ];
decl String : infectgain [ MENU_LINE_REG_LENGTH ];
decl String : speed [ MENU_LINE_REG_LENGTH ];
decl String : knockback [ MENU_LINE_REG_LENGTH ];
decl String : jumpheight [ MENU_LINE_REG_LENGTH ];
decl String : jumpdistance [ MENU_LINE_REG_LENGTH ];
2009-06-18 02:09:55 +02:00
new Float : currentnapalmtime ;
new Float : currenthealth ;
new Float : currentregeninterval ;
new Float : currentregenamount ;
new Float : currentinfectgain ;
new Float : currentspeed ;
new Float : currentknockback ;
new Float : currentjumpheight ;
new Float : currentjumpdistance ;
// Get current multipliers.
currentnapalmtime = Float : ClassMultiplierCache [ teamid ][ ClassM_NapalmTime ];
currenthealth = Float : ClassMultiplierCache [ teamid ][ ClassM_Health ];
currentregeninterval = Float : ClassMultiplierCache [ teamid ][ ClassM_HealthRegenInterval ];
currentregenamount = Float : ClassMultiplierCache [ teamid ][ ClassM_HealthRegenAmount ];
currentinfectgain = Float : ClassMultiplierCache [ teamid ][ ClassM_HealthInfectGain ];
currentspeed = Float : ClassMultiplierCache [ teamid ][ ClassM_Speed ];
currentknockback = Float : ClassMultiplierCache [ teamid ][ ClassM_Knockback ];
currentjumpheight = Float : ClassMultiplierCache [ teamid ][ ClassM_JumpHeight ];
currentjumpdistance = Float : ClassMultiplierCache [ teamid ][ ClassM_JumpDistance ];
2009-07-28 02:02:49 +02:00
SetGlobalTransTarget ( client );
2009-06-18 02:09:55 +02:00
// Translate phrases.
Format ( title , sizeof ( title ), " %t \n " , " Classes Menu Multiplier Select Title " );
Format ( health , sizeof ( health ), " %t \n %.2f " , " Classes Attrib Health " , currenthealth );
Format ( regeninterval , sizeof ( regeninterval ), " %t \n %.2f " , " Classes Attrib Regen Interval " , currentregeninterval );
Format ( regenamount , sizeof ( regenamount ), " %t \n %.2f " , " Classes Attrib Regen Amount " , currentregenamount );
Format ( speed , sizeof ( speed ), " %t \n %.2f " , " Classes Attrib Speed " , currentspeed );
Format ( jumpheight , sizeof ( jumpheight ), " %t \n %.2f " , " Classes Attrib Jump Height " , currentjumpheight );
Format ( jumpdistance , sizeof ( jumpdistance ), " %t \n %.2f " , " Classes Attrib Jump Distance " , currentjumpdistance );
// Only translate zombie phrases if zombie team is selected.
if ( zombiesselected )
{
Format ( napalmtime , sizeof ( napalmtime ), " %t \n %.2f " , " Classes Attrib Napalm Time " , currentnapalmtime );
Format ( infectgain , sizeof ( infectgain ), " %t \n %.2f " , " Classes Attrib Infect Gain " , currentinfectgain );
Format ( knockback , sizeof ( knockback ), " %t \n %.2f " , " Classes Attrib Knockback " , currentknockback );
}
SetMenuTitle ( menu , title );
// Add items. Don't add zombie attributes if human team is selected.
if ( zombiesselected ) AddMenuItem ( menu , " napalmtime " , napalmtime );
AddMenuItem ( menu , " health " , health );
AddMenuItem ( menu , " regeninterval " , regeninterval );
AddMenuItem ( menu , " regenamount " , regenamount );
if ( zombiesselected ) AddMenuItem ( menu , " infectgain " , infectgain );
AddMenuItem ( menu , " speed " , speed );
if ( zombiesselected ) AddMenuItem ( menu , " knockback " , knockback );
AddMenuItem ( menu , " jumpheight " , jumpheight );
AddMenuItem ( menu , " jumpdistance " , jumpdistance );
SetMenuExitBackButton ( menu , true );
DisplayMenu ( menu , client , MENU_TIME_FOREVER );
}
/**
* Multiplier select menu handler .
*/
public ClassMultiplierSelectHandle ( Handle : menu , MenuAction : action , client , slot )
{
decl String : attributename [ 48 ];
new ClassMultipliers : attribute ;
switch ( action )
{
case MenuAction_Select :
{
// Get attribute name.
GetMenuItem ( menu , slot , attributename , sizeof ( attributename ));
// Initialize in case of errors.
attribute = ClassM_Knockback ;
// Convert type.
if ( StrEqual ( attributename , " napalmtime " , false ))
{
attribute = ClassM_NapalmTime ;
}
else if ( StrEqual ( attributename , " health " , false ))
{
attribute = ClassM_Health ;
}
else if ( StrEqual ( attributename , " regeninterval " , false ))
{
attribute = ClassM_HealthRegenInterval ;
}
else if ( StrEqual ( attributename , " regenamount " , false ))
{
attribute = ClassM_HealthRegenAmount ;
}
else if ( StrEqual ( attributename , " infectgain " , false ))
{
attribute = ClassM_HealthInfectGain ;
}
else if ( StrEqual ( attributename , " speed " , false ))
{
attribute = ClassM_Speed ;
}
else if ( StrEqual ( attributename , " knockback " , false ))
{
attribute = ClassM_Knockback ;
}
else if ( StrEqual ( attributename , " jumpheight " , false ))
{
attribute = ClassM_JumpHeight ;
}
else if ( StrEqual ( attributename , " jumpdistance " , false ))
{
attribute = ClassM_JumpDistance ;
}
// Display multiplier menu for the selected attribute.
ClassMultiplierMenu ( client , attribute );
}
case MenuAction_End :
{
CloseHandle ( menu );
}
case MenuAction_Cancel :
{
if ( slot == MenuCancel_ExitBack )
{
ClassTeamSelect ( client );
}
}
}
}
/* ------------------------------------
*
* MULTIPLIER MENU ( ADMIN )
*
* ------------------------------------
*/
/**
* Displays multiplier menu for the specified attribute .
*/
ClassMultiplierMenu ( client , ClassMultipliers : attribute )
{
// Cache selected attribute.
ClassAdminAttributeSelected [ client ] = attribute ;
new Handle : menu = CreateMenu ( ClassMultiplierHandle );
2009-07-28 02:02:49 +02:00
decl String : title [ MENU_LINE_TITLE_LENGTH ];
decl String : attributename [ MENU_LINE_REG_LENGTH ];
decl String : linebuffer [ MENU_LINE_REG_LENGTH ];
2009-06-18 02:09:55 +02:00
// Get attribute string.
2009-07-28 02:02:49 +02:00
ClassMultiplierToString ( client , attribute , attributename , sizeof ( attributename ));
2009-06-18 02:09:55 +02:00
2009-07-28 02:02:49 +02:00
SetGlobalTransTarget ( client );
2009-06-18 02:09:55 +02:00
Format ( title , sizeof ( title ), " %t %s \n %t %.2f \n " , " Classes Menu Adjust Value " , attributename , " Current Value " , Float : ClassMultiplierCache [ ClassAdminTeamSelected [ client ]][ attribute ]);
SetMenuTitle ( menu , title );
2009-07-28 02:02:49 +02:00
SetGlobalTransTarget ( client );
2009-06-18 02:09:55 +02:00
Format ( linebuffer , sizeof ( linebuffer ), " %t " , " Increase by " , " 0.5 " );
AddMenuItem ( menu , " increasehalf " , linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " %t " , " Increase by " , " 0.1 " );
AddMenuItem ( menu , " increasedeci " , linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " %t " , " Decrease by " , " 0.1 " );
AddMenuItem ( menu , " decreasedeci " , linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " %t " , " Decrease by " , " 0.5 " );
AddMenuItem ( menu , " decreasehalf " , linebuffer );
SetMenuExitBackButton ( menu , true );
DisplayMenu ( menu , client , MENU_TIME_FOREVER );
}
public ClassMultiplierHandle ( Handle : menu , MenuAction : action , client , slot )
{
new Float : value ;
switch ( action )
{
case MenuAction_Select :
{
switch ( slot )
{
case 0 :
{
value = 0.5 ;
}
case 1 :
{
value = 0.1 ;
}
case 2 :
{
value = - 0.1 ;
}
case 3 :
{
value = - 0.5 ;
}
}
// Update multiplier.
ClassAddToMultiplier ( ClassAdminTeamSelected [ client ], ClassAdminAttributeSelected [ client ], value );
// Re-display menu.
ClassMultiplierMenu ( client , ClassAdminAttributeSelected [ client ]);
}
case MenuAction_End :
{
CloseHandle ( menu );
}
case MenuAction_Cancel :
{
if ( slot == MenuCancel_ExitBack )
{
ClassMultiplierSelectMenu ( client );
}
}
}
}
/**
* Add to the specified multiplier .
*
* @ param teamid The team to filter .
* @ param attribute The attribute to add to .
* @ param value Value to add .
*/
ClassAddToMultiplier ( teamid , ClassMultipliers : attribute , Float : value )
2009-04-14 23:33:06 +02:00
{
2009-06-18 02:09:55 +02:00
ClassMultiplierCache [ teamid ][ attribute ] = ClassMultiplierCache [ teamid ][ attribute ] + value ;
2009-04-15 23:40:45 +02:00
}