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:
@ -62,6 +62,9 @@ enum CvarsList
|
||||
Handle:CVAR_CLASSES_OVERLAY_TOGGLE,
|
||||
Handle:CVAR_CLASSES_OVERLAY_TOGGLECMDS,
|
||||
Handle:CVAR_CLASSES_OVERLAY_DEFAULT,
|
||||
Handle:CVAR_CLASSES_ZOMBIE_SELECT,
|
||||
Handle:CVAR_CLASSES_HUMAN_SELECT,
|
||||
Handle:CVAR_CLASSES_ADMIN_SELECT,
|
||||
Handle:CVAR_WEAPONS,
|
||||
Handle:CVAR_WEAPONS_RESTRICT,
|
||||
Handle:CVAR_WEAPONS_ZMARKET,
|
||||
@ -214,7 +217,7 @@ CvarsCreate()
|
||||
// ===========================
|
||||
g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", "Enable logging of events in the plugin. Fatal errors are logged independent on this setting.");
|
||||
g_hCvarsList[CVAR_LOG_FLAGS] = CreateConVar("zr_log_flags", "3", "A bit field that specify what event types to log. See logging section (3.3) in manual for details.");
|
||||
g_hCvarsList[CVAR_LOG_MODULE_FILTER] = CreateConVar("zr_log_module_filter", "0", "Enable module filtering. Only log events from listed modules will be logged.");
|
||||
g_hCvarsList[CVAR_LOG_MODULE_FILTER] = CreateConVar("zr_log_module_filter", "0", "Enable module filtering. Only events from listed modules will be logged.");
|
||||
g_hCvarsList[CVAR_LOG_IGNORE_CONSOLE] = CreateConVar("zr_log_ignore_console", "1", "Don't log events triggered by console commands that are executed by the console itself, like commands in configs. Enable this command to avoid spamming logs with events like weapon restrictions.");
|
||||
g_hCvarsList[CVAR_LOG_ERROR_OVERRIDE] = CreateConVar("zr_log_error_override", "1", "Always log error messages. Overrides module filter and logging flags.");
|
||||
g_hCvarsList[CVAR_LOG_PRINT_ADMINS] = CreateConVar("zr_log_print_admins", "0", "Print log events to admin chat in addition to the log file.");
|
||||
@ -242,6 +245,9 @@ CvarsCreate()
|
||||
g_hCvarsList[CVAR_CLASSES_DEFAULT_M_ZOMB] = CreateConVar("zr_classes_default_mother_zombie", "motherzombies","Zombie class assigned to mother zombies. [\"motherzombies\" = Random mother zombie class | \"random\" = Random regular zombie class | \"disabled\" = Don't change class on mother zombies]");
|
||||
g_hCvarsList[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "random", "Human class assigned to players on connect. [\"random\" = Random human class | \"\" = Class config default]");
|
||||
g_hCvarsList[CVAR_CLASSES_DEFAULT_ADMIN] = CreateConVar("zr_classes_default_admin", "random", "Admin class assigned to admins on connect. [\"random\" = Random admin class | \"\" = Class config default]");
|
||||
g_hCvarsList[CVAR_CLASSES_ZOMBIE_SELECT] = CreateConVar("zr_classes_zombie_select", "1", "Allow players to select zombie classes.");
|
||||
g_hCvarsList[CVAR_CLASSES_HUMAN_SELECT] = CreateConVar("zr_classes_human_select", "1", "Allow players to select human classes.");
|
||||
g_hCvarsList[CVAR_CLASSES_ADMIN_SELECT] = CreateConVar("zr_classes_admin_select", "1", "Allow admins to select admin mode classes. (Not to be confused by admin-only classes!)");
|
||||
|
||||
// Menu
|
||||
g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE] = CreateConVar("zr_classes_menu_autoclose", "0", "Automatically close class selection menu after selecting a class.");
|
||||
|
@ -624,7 +624,7 @@ public Action:Command_LogRemoveModule(client, argc)
|
||||
if (argc < 1)
|
||||
{
|
||||
// Display syntax info.
|
||||
StrCat(buffer, sizeof(buffer), "Add one or more modules to the module filter. Usage: zr_log_add_module <module> [module] ...\n");
|
||||
StrCat(buffer, sizeof(buffer), "Remove one or more modules to the module filter. Usage: zr_log_remove_module <module> [module] ...\n");
|
||||
StrCat(buffer, sizeof(buffer), "See zr_log_list to list available module names (short names).");
|
||||
ReplyToCommand(client, buffer);
|
||||
}
|
||||
|
@ -117,7 +117,10 @@ ZMenuMain(client)
|
||||
new bool:admin = ZRIsClientAdmin(client);
|
||||
AddMenuItem(menu_main, "zadmin", zadmin, MenuGetItemDraw(admin));
|
||||
|
||||
AddMenuItem(menu_main, "zclass", zclass);
|
||||
// Decide whether the client can use zclass.
|
||||
new zclassdraw = ClassAllowSelection(client) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||
|
||||
AddMenuItem(menu_main, "zclass", zclass, zclassdraw);
|
||||
AddMenuItem(menu_main, "zcookies", zcookies);
|
||||
AddMenuItem(menu_main, "zspawn", zspawn);
|
||||
AddMenuItem(menu_main, "ztele", ztele);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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])
|
||||
|
@ -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.
|
||||
|
@ -333,16 +333,13 @@ stock TranslationReplyToCommand(client, any:...)
|
||||
{
|
||||
// Format string to create plugin style. (color)
|
||||
TranslationPluginFormatString(translation, sizeof(translation));
|
||||
|
||||
// Print translated phrase to client's chat/console.
|
||||
PrintToChat(client, translation);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Format string to create plugin style. (no color)
|
||||
TranslationPluginFormatString(translation, sizeof(translation), false);
|
||||
|
||||
// Print to server.
|
||||
PrintToServer(translation);
|
||||
}
|
||||
|
||||
// Print translated phrase to server or client's chat/console.
|
||||
ReplyToCommand(client, translation);
|
||||
}
|
||||
|
Reference in New Issue
Block a user