From 8bf948b540f3a69712a6e1550b4806f8dc901e10 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 2 Jul 2009 01:44:41 -0700 Subject: [PATCH] Disable hitgroups in the menu if cvar is disabled, stop hitgroup commands from working if hitgroups are disabled. --- src/zr/hitgroups.inc | 24 ++++++++++++++++++++++++ src/zr/zadmin.inc | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/zr/hitgroups.inc b/src/zr/hitgroups.inc index 944e7b3..2a41583 100644 --- a/src/zr/hitgroups.inc +++ b/src/zr/hitgroups.inc @@ -506,6 +506,14 @@ public HitgroupsMenuHitgroupsHandle(Handle:menu_hitgroups, MenuAction:action, cl */ public Action:HitgroupsCommand(client, argc) { + // If module is disabled, then stop. + new bool:hitgroups = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]); + if (!hitgroups) + { + TranslationReplyToCommand(client, "Feature is disabled"); + return; + } + // If not enough arguments given, then stop. if (argc < 1) { @@ -584,6 +592,14 @@ public Action:HitgroupsCommand(client, argc) */ public Action:HitgroupsEnableAllCommand(client, argc) { + // If module is disabled, then stop. + new bool:hitgroups = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]); + if (!hitgroups) + { + TranslationReplyToCommand(client, "Feature is disabled"); + return; + } + // x = Hitgroup index. new size = GetArraySize(arrayHitgroups); for (new x = 0; x < size; x++) @@ -610,6 +626,14 @@ public Action:HitgroupsEnableAllCommand(client, argc) */ public Action:HitgroupsHeadshotsOnlyCommand(client, argc) { + // If module is disabled, then stop. + new bool:hitgroups = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]); + if (!hitgroups) + { + TranslationReplyToCommand(client, "Feature is disabled"); + return; + } + // x = Hitgroup index. new size = GetArraySize(arrayHitgroups); for (new x = 0; x < size; x++) diff --git a/src/zr/zadmin.inc b/src/zr/zadmin.inc index 8ae5a94..86250c6 100644 --- a/src/zr/zadmin.inc +++ b/src/zr/zadmin.inc @@ -95,9 +95,13 @@ bool:ZAdminMenu(client) Format(ztele, sizeof(ztele), "%t", "ZAdmin main force ztele"); //Format(logflags, sizeof(logflags), "%t", "!zadmin main logflags"); + // Get conditions for options. + new bool:hitgroups = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]); + + // Add items to menu. AddMenuItem(menu_zadmin, "classmultipliers", classmultipliers); AddMenuItem(menu_zadmin, "weapons", weapons); - AddMenuItem(menu_zadmin, "hitgroups", hitgroups); + AddMenuItem(menu_zadmin, "hitgroups", hitgroups, MenuGetItemDraw(hitgroups)); AddMenuItem(menu_zadmin, "infect", infect); AddMenuItem(menu_zadmin, "zspawn", zspawn); AddMenuItem(menu_zadmin, "ztele", ztele);