Config options now supports on/off along with yes/no.

Fixed ZMenu and player names in infect menu being truncated.
Added Hitgroup Management to ZAdmin.
This commit is contained in:
Greyscale 2009-06-26 00:00:05 -07:00
parent 069627b620
commit 194eb9f2b8
8 changed files with 223 additions and 46 deletions

View File

@ -12,7 +12,7 @@
// Attribute: Values: Description:
// ----------------------------------------------------------------------------
// index number The hitgroup index.
// damage yes/no Allow damage to be done on this hitgroup for zombies.
// damage on/off Allow damage to be done on this hitgroup for zombies.
// knockback decimal The knockback multiplier for this hitgroup.
"hitgroups" // Counter-Strike: Source hitgroups
@ -23,7 +23,7 @@
"index" "0"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.0"
@ -35,7 +35,7 @@
"index" "1"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "2.0"
@ -47,7 +47,7 @@
"index" "2"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.3"
@ -59,7 +59,7 @@
"index" "3"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.2"
@ -71,7 +71,7 @@
"index" "4"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.0"
@ -83,7 +83,7 @@
"index" "5"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.0"
@ -95,7 +95,7 @@
"index" "6"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "0.9"
@ -107,7 +107,7 @@
"index" "7"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "0.9"
@ -119,7 +119,7 @@
"index" "8"
// Damage
"damage" "yes"
"damage" "on"
// Knockback
"knockback" "1.0"

View File

@ -143,7 +143,7 @@
"Config command reload all stats begin"
{
"en" "Reloading all Zombie:Reloaded config files...\n ------------------------------------------------"
"en" "Reloading all Zombie:Reloaded config files...\n------------------------------------------------"
}
"Config command reload all stats successful"
@ -432,37 +432,37 @@
"Menu main zclass"
{
"#format" "{1:s}"
"en" "ZClass - Configure your class settings. (Command: {1})"
"en" "ZClass - Configure class settings. (Command: {1})"
}
"Menu main zcookies"
{
"#format" "{1:s}"
"en" "ZCookies - Toggle your personal ZR settings here. (Command: {1})"
"en" "ZCookies - Toggle personal ZR settings here. (Command: {1})"
}
"Menu main zspawn"
{
"#format" "{1:s}"
"en" "ZSpawn - Join late? Use this to spawn. (Command: {1})"
"en" "ZSpawn - Join late? Spawn with this. (Command: {1})"
}
"Menu main ztele"
{
"#format" "{1:s}"
"en" "ZTele - Teleport back to your spawn location. (Command: {1})"
"en" "ZTele - Stuck? Teleport back to spawn. (Command: {1})"
}
"Menu main zhp"
{
"#format" "{1:s}"
"en" "ZHP - Toggle real HP display when infected. (Command: {1})"
"en" "ZHP - Shows real HP as zombie. (Command: {1})"
}
"Menu main zmarket"
{
"#format" "{1:s}"
"en" "ZMarket - Need a weapon? Buy them here. (Command: {1})"
"en" "ZMarket - Customize loadouts here. (Command: {1})"
}
// ===========================
@ -634,7 +634,7 @@
"Weapons menu restrict types unrestrict all"
{
"#format" "{1:s}"
"en" "Unrestrict weapon type {1}\n "
"en" "Unrestrict weapon type {1}"
}
"Weapons menu restrict zmarket title"
@ -747,6 +747,25 @@
// Hitgroups (core)
// ===========================
// Menu
"Hitgroups menu hitgroups title"
{
"en" "Hitgroup Management\nCommands: zr_hitgroup(_enable_all/_headshots_only)\nSelect a Hitgroup to Toggle:"
}
"Hitgroups menu hitgroups enable all"
{
"en" "Enable All Hitgroups"
}
"Hitgroups menu hitgroups headshots only"
{
"en" "Headshots Only"
}
// Commands
"Hitgroups command syntax"
{
"en" "Toggles or sets if a zombie's hitgroup can be damaged. Usage: zr_hitgroup <hitgroup alias> [1/0]"
@ -796,7 +815,7 @@
"ZAdmin main title"
{
"en" "ZAdmin\n Select Category:"
"en" "ZAdmin\nSelect Category:"
}
"ZAdmin main class multipliers"
@ -809,6 +828,11 @@
"en" "Weapon Management"
}
"ZAdmin main hitgroups"
{
"en" "Hitgroup Management"
}
"ZAdmin main zombie"
{
"en" "Zombie Management"

View File

@ -884,15 +884,15 @@ public Action:ConfigReloadAllCommand(client, argc)
}
/**
* Converts string of "yes" or "no" to a boolean value.
* Converts string of "yes/on" or "no/off" to a boolean value.
*
* @param option "yes" or "no" string to be converted.
* @param option "yes/on" or "no/off" string to be converted.
* @return True if string is "yes", false otherwise.
*/
stock bool:ConfigSettingToBool(const String:option[])
{
// If option is equal to "yes," then return true.
if (StrEqual(option, "yes", false))
if (StrEqual(option, "yes", false) || StrEqual(option, "on", false))
{
return true;
}
@ -904,8 +904,8 @@ stock bool:ConfigSettingToBool(const String:option[])
/**
* Converts boolean value to "yes" or "no".
*
* @param bOption True/false value to be converted to "yes"/"no", respectively.
* @param option Destination string buffer to store "yes" or "no" in.
* @param bOption True/false value to be converted to "yes/on"/"no/off", respectively.
* @param option Destination string buffer to store "yes/on" or "no/off" in.
* @param maxlen Length of destination string buffer (wont't be more than 4).
* @param yesno When true, returns "yes/no", false returns "on/off."
*/

View File

@ -170,6 +170,13 @@ public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damag
// Here we know that attacker and client are different teams.
// If client is a human, then allow damage.
if (InfectIsClientHuman(client))
{
// Allow damage.
return ZRTools_Continue;
}
// If damage hitgroups cvar is disabled, then allow damage.
new bool:damagehitgroups = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_HITGROUPS]);
if (!damagehitgroups)

View File

@ -349,6 +349,154 @@ stock Float:HitgroupsGetKnockback(index)
return Float:GetArrayCell(arrayHitgroup, _:HITGROUPS_DATA_KNOCKBACK);
}
/**
* Sends list of hitgroups to client.
*
* @param client The client index.
* @return True if sent successfully, false if not.
*/
bool:HitgroupsMenuHitgroups(client)
{
// If hitgroups is disabled, then stop.
new bool:hitgroups = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]);
if (!hitgroups)
{
return false;
}
// Create menu handle.
new Handle:menu_hitgroups = CreateMenu(HitgroupsMenuHitgroupsHandle);
// Set client as translation target.
SetGlobalTransTarget(client);
SetMenuTitle(menu_hitgroups, "%t\n ", "Hitgroups menu hitgroups title");
decl String:enableall[32];
decl String:headshotsonly[32];
// Format menu options.
Format(enableall, sizeof(enableall), "%t", "Hitgroups menu hitgroups enable all");
Format(headshotsonly, sizeof(headshotsonly), "%t\n ", "Hitgroups menu hitgroups headshots only");
// Add options to menu.
AddMenuItem(menu_hitgroups, "Enable All", enableall);
AddMenuItem(menu_hitgroups, "Headshots Only", headshotsonly);
decl String:hitgroupoption[MAX_NAME_LENGTH];
decl String:hitgroupcandamage[MAX_NAME_LENGTH];
decl String:hitgroupid[4];
// x = Hitgroup index.
new size = GetArraySize(arrayHitgroups);
for (new x = 0; x < size; x++)
{
// Get hitgroup name.
HitgroupsGetName(x, hitgroupoption, sizeof(hitgroupoption));
IntToString(x, hitgroupid, sizeof(hitgroupid));
// Convert bool to "On/Off"
ConfigBoolToSetting(HitgroupsCanDamage(x), hitgroupcandamage, sizeof(hitgroupcandamage), false);
// Format "on/off" to the option.
Format(hitgroupoption, sizeof(hitgroupoption), "%s: %s", hitgroupoption, hitgroupcandamage);
// Add option to menu.
AddMenuItem(menu_hitgroups, hitgroupid, hitgroupoption);
}
// Create a "Back" button to the main admin menu.
SetMenuExitBackButton(menu_hitgroups, true);
// Send menu.
DisplayMenu(menu_hitgroups, client, MENU_TIME_FOREVER);
return true;
}
/**
* Called when client selects option in the infect clients menu, and handles it.
* @param menu_weapons_main Handle of the menu being used.
* @param action The action done on the menu (see menus.inc, enum MenuAction).
* @param client The client index.
* @param slot The slot index selected (starting from 0).
*/
public HitgroupsMenuHitgroupsHandle(Handle:menu_hitgroups, MenuAction:action, client, slot)
{
// Client selected an option.
if (action == MenuAction_Select)
{
switch(slot)
{
// Enable all hitgroups.
case 0:
{
// x = Hitgroup index.
new size = GetArraySize(arrayHitgroups);
for (new x = 0; x < size; x++)
{
// Enable hitgroup.
HitgroupsSetDamage(x, true);
}
// Tell the server that all hitgroups have been enabled.
TranslationPrintToChatAll(true, false, "Hitgroups command enable all successful");
}
// Headshots only.
case 1:
{
// x = Hitgroup index.
new size = GetArraySize(arrayHitgroups);
for (new x = 0; x < size; x++)
{
if (HitgroupsGetIndex(x) == HITGROUP_HEAD)
{
// Enable hitgroup.
HitgroupsSetDamage(x, true);
continue;
}
// Disable hitgroup.
HitgroupsSetDamage(x, false);
}
// Tell the server that headshots only been enabled.
TranslationPrintToChatAll(true, false, "Hitgroups command headshots only successful");
}
default:
{
// Get selected hitgroup index.
decl String:hitgroupid[4];
GetMenuItem(menu_hitgroups, slot, hitgroupid, sizeof(hitgroupid));
new hitgroup = StringToInt(hitgroupid);
// Toggle value.
new bool:hitgroupcandamage = HitgroupsCanDamage(hitgroup);
HitgroupsSetDamage(hitgroup, !hitgroupcandamage);
}
}
// Re-send menu.
HitgroupsMenuHitgroups(client);
}
// Client closed the menu.
if (action == MenuAction_Cancel)
{
// Client hit "Back" button.
if (slot == MenuCancel_ExitBack)
{
// Re-open admin menu.
ZAdminMenu(client);
}
}
// Client hit "Exit" button.
else if (action == MenuAction_End)
{
CloseHandle(menu_hitgroups);
}
}
/**
* Command callback (zr_hitgroup)
* Toggles or sets if a zombie's hitgroup can be damaged.
@ -436,17 +584,12 @@ public Action:HitgroupsCommand(client, argc)
*/
public Action:HitgroupsEnableAllCommand(client, argc)
{
new hitgroup;
// x = Hitgroup index.
new size = GetArraySize(arrayHitgroups);
for (new x = 0; x < size; x++)
{
// Get CS:S hitgroup index.
hitgroup = HitgroupsGetIndex(x);
// Set that hitgroup index to true for damage.
HitgroupsSetDamage(hitgroup, true);
HitgroupsSetDamage(x, true);
}
// Tell the server that all hitgroups have been enabled.
@ -467,27 +610,22 @@ public Action:HitgroupsEnableAllCommand(client, argc)
*/
public Action:HitgroupsHeadshotsOnlyCommand(client, argc)
{
new hitgroup;
// x = Hitgroup index.
new size = GetArraySize(arrayHitgroups);
for (new x = 0; x < size; x++)
{
// Get CS:S hitgroup index.
hitgroup = HitgroupsGetIndex(x);
// If this hitgroup is the head, then enable it and stop.
if (hitgroup == HITGROUP_HEAD)
if (HitgroupsGetIndex(x) == HITGROUP_HEAD)
{
HitgroupsSetDamage(hitgroup, true);
HitgroupsSetDamage(x, true);
continue;
}
// Set that hitgroup index to true for damage.
HitgroupsSetDamage(hitgroup, false);
HitgroupsSetDamage(x, false);
}
// Tell the server that all hitgroups have been enabled.
// Tell the server that headshots only been enabled.
TranslationPrintToChatAll(true, false, "Hitgroups command headshots only successful");
// Log action to game events.

View File

@ -807,7 +807,7 @@ InfectMenuClients(client)
SetMenuTitle(menu_infect_clients, "%t\n ", "Infect menu clients title");
decl String:clientoption[MAX_NAME_LENGTH];
decl String:clientoption[64];
decl String:clientuserid[8];
// x = Client index.

View File

@ -210,7 +210,7 @@ WeaponsMenuTypeWeapons(client)
decl String:unrestrictall[64];
Format(restrictall, sizeof(restrictall), "%t", "Weapons menu restrict types restrict all", typename);
Format(unrestrictall, sizeof(unrestrictall), "%t", "Weapons menu restrict types unrestrict all", typename);
Format(unrestrictall, sizeof(unrestrictall), "%t\n ", "Weapons menu restrict types unrestrict all", typename);
// Draw items as selectable only if not all weapons within the type are restricted or unrestricted.
AddMenuItem(menu_weapons_typeweapons, "restrictall", restrictall, MenuGetItemDraw(!RestrictIsTypeUniform(true, g_iWeaponsCurType[client])));

View File

@ -80,14 +80,16 @@ bool:ZAdminMenu(client)
SetMenuTitle(menu_zadmin, "%t\n ", "ZAdmin main title");
decl String:classmultipliers[64];
decl String:weapons[64];
decl String:hitgroups[64];
decl String:infect[64];
decl String:zspawn[64];
decl String:ztele[64];
decl String:weapons[64];
decl String:infect[64];
//decl String:logflags[64];
Format(classmultipliers, sizeof(classmultipliers), "%t", "ZAdmin main class multipliers");
Format(weapons, sizeof(weapons), "%t", "ZAdmin main weapons");
Format(hitgroups, sizeof(hitgroups), "%t", "ZAdmin main hitgroups");
Format(infect, sizeof(infect), "%t", "ZAdmin main zombie");
Format(zspawn, sizeof(zspawn), "%t", "ZAdmin main force zspawn");
Format(ztele, sizeof(ztele), "%t", "ZAdmin main force ztele");
@ -95,6 +97,7 @@ bool:ZAdminMenu(client)
AddMenuItem(menu_zadmin, "classmultipliers", classmultipliers);
AddMenuItem(menu_zadmin, "weapons", weapons);
AddMenuItem(menu_zadmin, "hitgroups", hitgroups);
AddMenuItem(menu_zadmin, "infect", infect);
AddMenuItem(menu_zadmin, "zspawn", zspawn);
AddMenuItem(menu_zadmin, "ztele", ztele);
@ -137,8 +140,13 @@ public ZAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot)
{
resend = !WeaponsMenuMain(client);
}
// Zombie management.
// Hitgroup management.
case 2:
{
resend = !HitgroupsMenuHitgroups(client);
}
// Zombie management.
case 3:
{
// We're not resending this menu.
resend = false;
@ -147,7 +155,7 @@ public ZAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot)
InfectMenuClients(client);
}
// Force ZSpawn.
case 3:
case 4:
{
// We're not resending this menu.
resend = false;
@ -156,7 +164,7 @@ public ZAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot)
MenuClientList(client, ZSpawnForceHandle, "ZSpawn clients title");
}
// Force ZTele.
case 4:
case 5:
{
// We're not resending this menu.
resend = false;