Added config override for stat hacks. This makes updating for 1.12 easy as well since these will change then, small part of #525

This commit is contained in:
Zack Piispanen 2013-09-21 16:04:41 -04:00
parent b23cdb41c3
commit 4fed645fde
3 changed files with 12 additions and 8 deletions

View file

@ -263,6 +263,10 @@ namespace TShockAPI
[Description("A dictionary of REST tokens that external applications may use to make queries to your server.")]
public Dictionary<string, SecureRest.TokenData> ApplicationRestTokens = new Dictionary<string, SecureRest.TokenData>();
[Description("The maximum value that a character may have for health.")] public int MaxHealth = 400;
[Description("The maximum value that a character may have for health.")] public int MaxMana = 400;
/// <summary>
/// Reads a configuration file from a given path
/// </summary>

View file

@ -1251,7 +1251,7 @@ namespace TShockAPI
if (args.Player.FirstMaxHP == 0)
args.Player.FirstMaxHP = max;
if (max > 400 && max > args.Player.FirstMaxHP)
if (max > TShock.Config.MaxHealth && max > args.Player.FirstMaxHP)
{
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true);
return false;
@ -1277,7 +1277,7 @@ namespace TShockAPI
if (args.Player.FirstMaxMP == 0)
args.Player.FirstMaxMP = max;
if (max > 400 && max > args.Player.FirstMaxMP)
if (max > TShock.Config.MaxMana && max > args.Player.FirstMaxMP)
{
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true);
return false;
@ -1450,7 +1450,7 @@ namespace TShockAPI
TShock.Utils.ForceKick(args.Player, "Blank name.", true);
return true;
}
if (TShock.HackedHealth(args.Player) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection))
if (TShock.HackedStats(args.Player) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection))
{
TShock.Utils.ForceKick(args.Player, "You have hacked health/mana, please use a different character.", true);
return true;

View file

@ -1455,12 +1455,12 @@ namespace TShockAPI
return (float) Math.Sqrt(num3);
}
public static bool HackedHealth(TSPlayer player)
public static bool HackedStats(TSPlayer player)
{
return (player.TPlayer.statManaMax > 400) ||
(player.TPlayer.statMana > 400) ||
(player.TPlayer.statLifeMax > 400) ||
(player.TPlayer.statLife > 400);
return (player.TPlayer.statManaMax > TShock.Config.MaxMana) ||
(player.TPlayer.statMana > TShock.Config.MaxMana) ||
(player.TPlayer.statLifeMax > TShock.Config.MaxHealth) ||
(player.TPlayer.statLife > TShock.Config.MaxHealth);
}
public static bool HackedInventory(TSPlayer player)