New feature for blocking class selection. Changes in translations. See details.

Finished norwegian translation.
Fixed missing quote in english translation file.
Added cvars for blocking players from changing classes.
Minior typo fixes in log module.
Changed TranslationReplyToCommand to use the ReplyToCommand function.
This commit is contained in:
richard
2009-08-09 22:44:28 +02:00
parent 50a7e5ab99
commit 06771e6d15
10 changed files with 234 additions and 209 deletions

View File

@ -59,7 +59,14 @@ public Action:ZClassCommand(client, argc)
// If client is console, then stop and tell them this feature is for players only.
if (ZRIsConsole(client))
{
TranslationPrintToServer("Must be player");
TranslationReplyToCommand(client, "Must be player");
return Plugin_Handled;
}
// Check if class selection is allowed.
if (!ClassAllowSelection(client))
{
TranslationReplyToCommand(client, "Classes Selection Not Allowed");
return Plugin_Handled;
}

View File

@ -65,18 +65,19 @@ ClassMenuMain(client)
// Get number of enabled classes per team.
new zombiecount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
new humancount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
new admincount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
new admincount = ClassCountTeam(ZR_CLASS_TEAM_ADMINS);
// Get previously selected class indexes, if set.
new nextzombie = ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES];
new nexthuman = ClassSelectedNext[client][ZR_CLASS_TEAM_HUMANS];
new nextadmin = ClassSelectedNext[client][ZR_CLASS_TEAM_ADMINS];
// Set draw style on class options depending on number of enabled classes.
// Disable class selection if there's only one class.
new zombie_itemdraw = (zombiecount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
new human_itemdraw = (humancount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
new admin_itemdraw = (admincount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
// Set draw style on class options depending on number of enabled classes
// and selection permissions. Disable class selection if there's only one
// class.
new zombie_itemdraw = (zombiecount > 1 && ClassAllowSelection(client, ZR_CLASS_TEAM_ZOMBIES)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
new human_itemdraw = (humancount > 1 && ClassAllowSelection(client, ZR_CLASS_TEAM_HUMANS)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
new admin_itemdraw = (admincount > 1 && ClassAllowSelection(client, ZR_CLASS_TEAM_ADMINS)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
// Check if the player is in admin mode.
if (ClassPlayerInAdminMode[client])

View File

@ -515,6 +515,64 @@ stock bool:ClassFlagFilterMatch(index, require, deny, cachetype)
}
}
/**
* Decides whether a class selection menu should be enabled. The decision is
* based on zr_class_allow_* console variables.
*
* @param team Optional. Team ID to match. Default is all.
* @return True if allowed, false otherwise.
*/
bool:ClassAllowSelection(client, team = -1)
{
// Get selection settings.
new bool:zombie = GetConVarBool(g_hCvarsList[CVAR_CLASSES_ZOMBIE_SELECT]);
new bool:human = GetConVarBool(g_hCvarsList[CVAR_CLASSES_HUMAN_SELECT]);
new bool:admin = GetConVarBool(g_hCvarsList[CVAR_CLASSES_ADMIN_SELECT]);
// Since admin mode classes are optional they must be counted to verify
// that they exist.
new bool:adminexist;
// Check if player is admin.
new bool:isadmin = ZRIsClientAdmin(client);
// Only count admin mode classes if client is admin for better performance.
if (isadmin)
{
adminexist = ClassCountTeam(ZR_CLASS_TEAM_ADMINS) > 0;
}
// Check if a team id is specified.
if (team >= 0)
{
// Check team and return the corresponding selection setting.
switch (team)
{
case ZR_CLASS_TEAM_ZOMBIES:
{
return zombie;
}
case ZR_CLASS_TEAM_HUMANS:
{
return human;
}
case ZR_CLASS_TEAM_ADMINS:
{
// Player must be admin to select admin mode classes.
return admin && isadmin && adminexist;
}
}
// Team ID didn't match.
return false;
}
else
{
// Check zombie and human.
return zombie || human;
}
}
/**
* Gets all class indexes or from a specified team, and adds them to the
* specified array.